feat: LDAP 账号管理 — OU管理/添加用户/删除用户/批量导入
后端新增 4 个 LDAP 管理端点: - POST /ldap-config/create-ou: 创建组织单元 - POST /ldap-config/create-user: 创建单个用户 (SSHA加密) - POST /ldap-config/delete-user: 删除用户 - POST /ldap-config/batch-import-ldap: 批量导入用户 - POST /ldap-config/user-list: 查询用户列表(恢复) 前端 LdapConfigPage 增强: - LDAP 账号管理折叠区(配置存在即显示) - OU 下拉选择 + 根节点选项 + 数量统计 - 用户列表表格(全选/单选/DN显示) - 新建 OU 弹框(名称+父级DN+描述) - 添加用户弹框(用户名+密码+显示名+邮箱+目标OU) - 删除选中用户按钮(确认后批量删除) 前端 UsersPage BatchImportModal 三 Tab: - 本地导入 / 导入到 LDAP / 从 LDAP 导入 测试修复: - test_user_endpoint.py: 分页格式兼容 - test_users.py: 分页格式兼容 - test_system_settings.py: 精简后配置项匹配
This commit is contained in:
1 parent
344c519209
commit
be2d6f3894
20 files changed
+2229
-1019
No files matched your search
@@ -25,8 +25,9 @@ class TestListUsers:
|
||||
resp = await client.get("/api/v1/users", headers=auth_header(admin_token))
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert isinstance(data, list)
|
||||
assert len(data) >= 1
|
||||
items = data.get("items", data) if isinstance(data, dict) else data
|
||||
assert isinstance(items, list)
|
||||
assert len(items) >= 1
|
||||
|
||||
async def test_list_users_role_filter(self, client: AsyncClient, admin_user, admin_token):
|
||||
"""按 role 筛选用户。"""
|
||||
@@ -35,7 +36,9 @@ class TestListUsers:
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
for u in resp.json():
|
||||
data = resp.json()
|
||||
items = data.get("items", data) if isinstance(data, dict) else data
|
||||
for u in items:
|
||||
assert u["role"] == "admin"
|
||||
|
||||
async def test_list_users_is_active_filter(
|
||||
@@ -47,7 +50,9 @@ class TestListUsers:
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
for u in resp.json():
|
||||
data = resp.json()
|
||||
items = data.get("items", data) if isinstance(data, dict) else data
|
||||
for u in items:
|
||||
assert u["is_active"] is False
|
||||
|
||||
async def test_list_users_combined_filters(
|
||||
@@ -59,7 +64,9 @@ class TestListUsers:
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
for u in resp.json():
|
||||
data = resp.json()
|
||||
items = data.get("items", data) if isinstance(data, dict) else data
|
||||
for u in items:
|
||||
assert u["role"] == "developer"
|
||||
assert u["is_active"] is False
|
||||
|
||||
@@ -70,7 +77,9 @@ class TestListUsers:
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == []
|
||||
data = resp.json()
|
||||
items = data.get("items", data) if isinstance(data, dict) else data
|
||||
assert items == []
|
||||
|
||||
async def test_list_users_non_admin_forbidden(
|
||||
self, client: AsyncClient, developer_token
|
||||
|
||||
Reference in new issue
Block a user