feat: 重构多轮RAG展示并完善报告协作、业务链审核与 agentfx 种子
抽出专用多轮RAG消息列表并升级会话模型;强化报告协作画布与检查器;业务链普通用户改为提交审核;扩展 agentfx 报告技能种子,并将含 admin 的用户名自动提权为管理员。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f109a95535
commit
db333a4c33
30 files changed
+2878
-1482
No files matched your search
@@ -187,3 +187,74 @@ async def test_password_lookup_uses_same_stable_username_account(
|
||||
|
||||
assert user is not None
|
||||
assert user.id == older.id
|
||||
|
||||
|
||||
# ── 用户名含 admin → 自动管理员(注册即 admin / 历史账号登录时提升)───────────
|
||||
|
||||
|
||||
def test_admin_username_rule_matches_substring_case_insensitive() -> None:
|
||||
from app.gateway.routers.auth import _is_admin_username
|
||||
|
||||
assert _is_admin_username("admin") is True
|
||||
assert _is_admin_username("b1admin") is True
|
||||
assert _is_admin_username("Admin_Planning") is True
|
||||
assert _is_admin_username("administrator") is True
|
||||
assert _is_admin_username("zhangsan") is False
|
||||
assert _is_admin_username("") is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_admin_substring_username_registers_as_admin(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
repo = FakeUserRepository()
|
||||
monkeypatch.setattr(auth_module, "get_local_provider", lambda: LocalAuthProvider(repo))
|
||||
|
||||
user, created = await _get_or_create_user_by_username("b1admin")
|
||||
|
||||
assert created is True
|
||||
assert user.system_role == "admin"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_plain_username_still_registers_as_user(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
repo = FakeUserRepository()
|
||||
monkeypatch.setattr(auth_module, "get_local_provider", lambda: LocalAuthProvider(repo))
|
||||
|
||||
user, created = await _get_or_create_user_by_username("zhangsan")
|
||||
|
||||
assert created is True
|
||||
assert user.system_role == "user"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_existing_admin_substring_account_promoted_on_login(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""历史已注册成普通用户的含 admin 账号,登录时自动提升为管理员。"""
|
||||
repo = FakeUserRepository()
|
||||
seeded = _seed(repo, "b1admin@cm.com", role="user")
|
||||
monkeypatch.setattr(auth_module, "get_local_provider", lambda: LocalAuthProvider(repo))
|
||||
|
||||
user, created = await _get_or_create_user_by_username("b1admin")
|
||||
|
||||
assert created is False
|
||||
assert user.id == seeded.id
|
||||
assert user.system_role == "admin"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_existing_plain_account_not_promoted_on_login(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
repo = FakeUserRepository()
|
||||
seeded = _seed(repo, "zhangsan@cm.com", role="user")
|
||||
monkeypatch.setattr(auth_module, "get_local_provider", lambda: LocalAuthProvider(repo))
|
||||
|
||||
user, created = await _get_or_create_user_by_username("zhangsan")
|
||||
|
||||
assert created is False
|
||||
assert user.id == seeded.id
|
||||
assert user.system_role == "user"
|
||||
Reference in new issue
Block a user