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