Skip to content

Commit

Permalink
providers/sync: update attributes in connection updates after updatin…
Browse files Browse the repository at this point in the history
…g remote object

Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu committed Jun 6, 2024
1 parent f278307 commit c1b0da3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ def update(self, group: Group, connection: GoogleWorkspaceProviderGroup):
google_group = self.to_schema(group, connection)
self.check_email_valid(google_group["email"])
try:
return self._request(
response = self._request(

Check warning on line 95 in authentik/enterprise/providers/google_workspace/clients/groups.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/google_workspace/clients/groups.py#L95

Added line #L95 was not covered by tests
self.directory_service.groups().update(
groupKey=connection.google_id,
body=google_group,
)
)
connection.attributes = response
connection.save()

Check warning on line 102 in authentik/enterprise/providers/google_workspace/clients/groups.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/google_workspace/clients/groups.py#L101-L102

Added lines #L101 - L102 were not covered by tests
except NotFoundSyncException:
# Resource missing is handled by self.write, which will re-create the group
raise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def update(self, user: User, connection: GoogleWorkspaceProviderUser):
self.check_email_valid(
google_user["primaryEmail"], *[x["address"] for x in google_user.get("emails", [])]
)
self._request(
response = self._request(

Check warning on line 91 in authentik/enterprise/providers/google_workspace/clients/users.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/google_workspace/clients/users.py#L91

Added line #L91 was not covered by tests
self.directory_service.users().update(userKey=connection.google_id, body=google_user)
)
connection.attributes = response
connection.save()

Check warning on line 95 in authentik/enterprise/providers/google_workspace/clients/users.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/google_workspace/clients/users.py#L94-L95

Added lines #L94 - L95 were not covered by tests

def discover(self):
"""Iterate through all users and connect them with authentik users if possible"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ def update(self, group: Group, connection: MicrosoftEntraProviderGroup):
microsoft_group = self.to_schema(group, connection)
microsoft_group.id = connection.microsoft_id
try:
return self._request(
response = self._request(

Check warning on line 107 in authentik/enterprise/providers/microsoft_entra/clients/groups.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/microsoft_entra/clients/groups.py#L107

Added line #L107 was not covered by tests
self.client.groups.by_group_id(connection.microsoft_id).patch(microsoft_group)
)
connection.attributes = self.entity_as_dict(response)
connection.save()

Check warning on line 111 in authentik/enterprise/providers/microsoft_entra/clients/groups.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/microsoft_entra/clients/groups.py#L110-L111

Added lines #L110 - L111 were not covered by tests
except NotFoundSyncException:
# Resource missing is handled by self.write, which will re-create the group
raise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ def update(self, user: User, connection: MicrosoftEntraProviderUser):
"""Update existing user"""
microsoft_user = self.to_schema(user, connection)
self.check_email_valid(microsoft_user.user_principal_name)
self._request(self.client.users.by_user_id(connection.microsoft_id).patch(microsoft_user))
response = self._request(

Check warning on line 113 in authentik/enterprise/providers/microsoft_entra/clients/users.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/microsoft_entra/clients/users.py#L113

Added line #L113 was not covered by tests
self.client.users.by_user_id(connection.microsoft_id).patch(microsoft_user)
)
connection.attributes = self.entity_as_dict(response)
connection.save()

Check warning on line 117 in authentik/enterprise/providers/microsoft_entra/clients/users.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/microsoft_entra/clients/users.py#L116-L117

Added lines #L116 - L117 were not covered by tests

def discover(self):
"""Iterate through all users and connect them with authentik users if possible"""
Expand Down

0 comments on commit c1b0da3

Please sign in to comment.