diff --git a/async_tests/test_async_ldap_model.py b/async_tests/test_async_ldap_model.py index b794a9d..c033c31 100644 --- a/async_tests/test_async_ldap_model.py +++ b/async_tests/test_async_ldap_model.py @@ -56,6 +56,14 @@ MISSING_AUTH_USER = [ "uid": ["existing_user"], } ] +EXISTING_SERVICE = [ + { + "dn": f"uid=existing_service,ou=Services,{BASE_DN}>", + "objectClass": ["account", "simpleSecurityObject", "top"], + "uid": ["existing_service"], + "userPassword": ["{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g="], + } +] class MockClient: @@ -83,8 +91,12 @@ class MockClient: return USER_LIST elif f"uid=existing_user,ou=Hackers,{BASE_DN}" in args: return EXISTING_USER + elif f"uid=existing_service,ou=Services,{BASE_DN}" in args: + return EXISTING_SERVICE elif f"uid=not_existing,ou=Hackers,{BASE_DN}" in args: return [] + elif f"uid=not_existing,ou=Services,{BASE_DN}" in args: + return [] elif f"uid=missing_auth_user,ou=Hackers,{BASE_DN}" in args: return MISSING_AUTH_USER @@ -700,26 +712,23 @@ def test_Service_singleton(client_fixture): assert c4 is not c1 -@pytest.mark.xfail @pytest.mark.asyncio async def test_Service_create_existing(client_fixture): - s = Service("existing_user", client_fixture) + s = Service("existing_service", client_fixture) with pytest.raises(PhiEntryExists) as e: - await s.create("existing@mail.org", sn="exists", cn="Existing Service") + await s.create("password") assert s.dn in str(e.value) -@pytest.mark.xfail @pytest.mark.asyncio async def test_Service_create_not_existing(client_fixture): s = Service("not_existing", client_fixture) - await s.create("not@existing.org") + await s.create("password") assert client_fixture.called_with_args["search"]["args"] == (s.dn, 0) - assert s._entry["mail"][0] == "not@existing.org" def test_Group(client_fixture):