Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def _create_read_only_permission(client: KeycloakAdmin, client_uuid: str):

def _create_admin_permission(client: KeycloakAdmin, client_uuid: str):
all_scopes = client.get_client_authz_scopes(client_uuid)
scopes = [scope["id"] for scope in all_scopes if scope["name"] in get_args(ExtendedResourceMethod)]
scope_names = get_args(ExtendedResourceMethod) + ("LIST",)
scopes = [scope["id"] for scope in all_scopes if scope["name"] in scope_names]
payload = {
"name": "Admin",
"type": "scope",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def get_url_login(self, **kwargs) -> str:

def refresh_user(self, *, user: KeycloakAuthManagerUser) -> KeycloakAuthManagerUser | None:
if self._token_expired(user.access_token):
log.debug("Refreshing the token")
client = self.get_keycloak_client()
tokens = client.refresh_token(user.refresh_token)
user.refresh_token = tokens["refresh_token"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ def test_create_permissions_read_only(self):

def test_create_permissions_admin(self):
client = Mock()
scopes = [{"id": "1", "name": "GET"}, {"id": "2", "name": "MENU"}, {"id": "3", "name": "PUT"}]
scopes = [
{"id": "1", "name": "GET"},
{"id": "2", "name": "MENU"},
{"id": "3", "name": "PUT"},
{"id": "4", "name": "LIST"},
{"id": "5", "name": "DUMMY"},
]

client.get_client_authz_scopes.return_value = scopes

Expand All @@ -291,7 +297,7 @@ def test_create_permissions_admin(self):
"type": "scope",
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"scopes": ["1", "2", "3"],
"scopes": ["1", "2", "3", "4"],
},
)

Expand Down