init
This commit is contained in:
1 parent
c7fccf99c7
commit
8471f368eb
33 files changed
+444
-2095
No files matched your search
@@ -267,8 +267,8 @@ async def test_create_ldap_config_empty_password(client: AsyncClient, admin_toke
|
||||
# ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ldap_connection_mock_success(client: AsyncClient, admin_token: str):
|
||||
"""配置存在时 POST /test 在 mock 模式下应返回 success=True"""
|
||||
async def test_ldap_connection_real_failure(client: AsyncClient, admin_token: str):
|
||||
"""配置存在时 POST /test 应尝试真实连接,测试环境无 LDAP 服务器则返回 success=False"""
|
||||
await client.put(
|
||||
"/api/v1/ldap-config",
|
||||
json=VALID_LDAP_PAYLOAD,
|
||||
@@ -282,11 +282,10 @@ async def test_ldap_connection_mock_success(client: AsyncClient, admin_token: st
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["success"] is True
|
||||
# mock 模式消息中包含 Mock 字样
|
||||
assert "Mock" in data["message"]
|
||||
# 消息中应包含主机和测试用户信息
|
||||
assert "zhangsan" in data["message"]
|
||||
# 测试环境无真实 LDAP 服务器,连接应失败
|
||||
assert data["success"] is False
|
||||
# 消息中应包含连接错误信息
|
||||
assert any(kw in data["message"] for kw in ["error", "fail", "未安装", "连接失败", "LDAP"])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user