Skip to content

Commit

Permalink
add some test
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu committed Feb 25, 2025
1 parent 3b5e74c commit 5f6c8b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions authentik/lib/sync/outgoing/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def __init__(self, url: str, method: str, body: dict):
self.method = method
self.body = body

def __str__(self):
return f"{self.method} {self.url}"


class StopSync(BaseSyncException):
"""Exception raised when a configuration error should stop the sync process"""
Expand Down
26 changes: 26 additions & 0 deletions authentik/providers/scim/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,29 @@ def test_sync_task(self, mock: Mocker):
"userName": uid,
},
)

def test_user_create_dry_run(self):
"""Test user creation (dry_run)"""
# Update the provider before we start mocking as saving the provider triggers a full sync
self.provider.dry_run = True
self.provider.save()
with Mocker() as mock:
scim_id = generate_id()
mock.get(
"https://localhost/ServiceProviderConfig",
json={},
)
mock.post(
"https://localhost/Users",
json={
"id": scim_id,
},
)
uid = generate_id()
User.objects.create(
username=uid,
name=f"{uid} {uid}",
email=f"{uid}@goauthentik.io",
)
self.assertEqual(mock.call_count, 1, mock.request_history)
self.assertEqual(mock.request_history[0].method, "GET")

0 comments on commit 5f6c8b5

Please sign in to comment.