fix: 后端路由 group_id 启用 path 路径匹配转换器,完美兼容带斜杠的远端分组 ID
This commit is contained in:
@@ -314,7 +314,7 @@ def create_website_group(
|
|||||||
raise HTTPException(502, str(exc))
|
raise HTTPException(502, str(exc))
|
||||||
|
|
||||||
|
|
||||||
@router.put("/api/websites/{wid}/groups/{group_id}", response_model=dict)
|
@router.put("/api/websites/{wid}/groups/{group_id:path}", response_model=dict)
|
||||||
def update_website_group(
|
def update_website_group(
|
||||||
wid: int,
|
wid: int,
|
||||||
group_id: str,
|
group_id: str,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ def test_create_and_update_website_group(db_session, monkeypatch):
|
|||||||
|
|
||||||
b = WebsiteGroupBinding(
|
b = WebsiteGroupBinding(
|
||||||
website_id=w.id,
|
website_id=w.id,
|
||||||
target_group_id="g123",
|
target_group_id="g/123",
|
||||||
target_group_name="OldName",
|
target_group_name="OldName",
|
||||||
source_groups_json="[]",
|
source_groups_json="[]",
|
||||||
enabled=True
|
enabled=True
|
||||||
@@ -81,12 +81,12 @@ def test_create_and_update_website_group(db_session, monkeypatch):
|
|||||||
|
|
||||||
# 2. Test update_website_group
|
# 2. Test update_website_group
|
||||||
body_update = WebsiteGroupUpdate(name="UpdatedGroup", description="UpdatedDesc")
|
body_update = WebsiteGroupUpdate(name="UpdatedGroup", description="UpdatedDesc")
|
||||||
res_update = update_website_group(wid=w.id, group_id="g123", body=body_update, db=db_session)
|
res_update = update_website_group(wid=w.id, group_id="g/123", body=body_update, db=db_session)
|
||||||
assert res_update["id"] == "g123"
|
assert res_update["id"] == "g/123"
|
||||||
assert res_update["name"] == "UpdatedGroup"
|
assert res_update["name"] == "UpdatedGroup"
|
||||||
assert res_update["description"] == "UpdatedDesc"
|
assert res_update["description"] == "UpdatedDesc"
|
||||||
assert len(called_update) == 1
|
assert len(called_update) == 1
|
||||||
assert called_update[0][1] == "g123"
|
assert called_update[0][1] == "g/123"
|
||||||
assert called_update[0][2] == {"name": "UpdatedGroup", "description": "UpdatedDesc"}
|
assert called_update[0][2] == {"name": "UpdatedGroup", "description": "UpdatedDesc"}
|
||||||
|
|
||||||
# Verify that local binding was updated
|
# Verify that local binding was updated
|
||||||
|
|||||||
Reference in New Issue
Block a user