mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 00:11:59 +00:00
撤销分享链接交回的 page_title 是页面标题,和建、列的一样
验收:DELETE /api/apps/{app_id}/shares/{share_id} 的返回里 page_title 是页面 id("home"),建分享时返回的是页面标题。
revoke_share 调 share_out(row) 时没给标题表,share_out 就退回页面 id。
改法:撤销照列表的取法(应用当前的版本 _previous 的 spec)给 share_out 标题表;撤销过的再撤销也一样。
测试:test_shares 的撤销用例加断言:建出来的 page_title 是「首页」,撤销、再撤销交回的都是「首页」。去掉修复回跑挂。
This commit is contained in:
@@ -216,7 +216,9 @@ async def list_shares(app_id: str, session: AsyncSession = Depends(get_session),
|
||||
@_manage.delete("/{app_id}/shares/{share_id}")
|
||||
async def revoke_share(app_id: str, share_id: str, session: AsyncSession = Depends(get_session),
|
||||
x_actor: str | None = Header(default=None)) -> dict[str, Any]:
|
||||
"""撤销:之后打开回 410「链接已撤销」。撤销过的再撤销照旧交回它(不重复记审计)。管理员关了开关也能撤销。"""
|
||||
"""撤销:之后打开回 410「链接已撤销」。撤销过的再撤销照旧交回它(不重复记审计)。管理员关了开关也能撤销。交回的形状和
|
||||
建、列的同一个(page_title 是页面标题,取法同列表:应用当前的版本)。"""
|
||||
from app.api.apps import _previous
|
||||
from app.apps.audit import record
|
||||
|
||||
app, _ = await _managed(session, app_id, x_actor)
|
||||
@@ -228,7 +230,8 @@ async def revoke_share(app_id: str, share_id: str, session: AsyncSession = Depen
|
||||
await record(session, action="app.share_revoke", subject_kind="view_share", subject_id=row.id,
|
||||
actor=actor_of(x_actor), data={"app_id": app.id, "page_id": row.page_id, "prefix": row.prefix})
|
||||
await session.commit()
|
||||
return share_out(row)
|
||||
version = await _previous(session, app)
|
||||
return share_out(row, _titles(version.spec if version is not None else None))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
@@ -326,6 +326,10 @@ async def test_revoked_and_expired_links_say_so_with_410(world): # noqa: F811
|
||||
admin = await auth_env.login("root")
|
||||
r = await admin.delete(f"/api/apps/{app_id}/shares/{gone['id']}")
|
||||
assert r.status_code == 200 and r.json()["state"] == "revoked" and r.json()["revoked_by"] == "root"
|
||||
# 撤销交回的那一条和建、列的同一个形状:page_title 是页面标题,不是页面 id(下一轮验收:以前撤销回的是「home」)
|
||||
assert gone["page_title"] == "首页" and r.json()["page_title"] == gone["page_title"], r.json()["page_title"]
|
||||
again = await admin.delete(f"/api/apps/{app_id}/shares/{gone['id']}")
|
||||
assert again.json()["page_title"] == "首页", "撤销过的再撤销照旧交回它,标题一样"
|
||||
async with SessionLocal() as s:
|
||||
(await s.get(ViewShare, old["id"])).expires_at = utcnow() - timedelta(minutes=5)
|
||||
await s.commit()
|
||||
|
||||
Reference in New Issue
Block a user