Browse Source
Merge pull request #330 from asyd/issue/329
Add get_idp_mappers, fix #329
pull/333/head
v1.3.0
Richard Nemeth
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
20 additions and
0 deletions
-
src/keycloak/keycloak_admin.py
-
tests/test_keycloak_admin.py
|
|
@ -413,6 +413,20 @@ class KeycloakAdmin: |
|
|
|
) |
|
|
|
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201]) |
|
|
|
|
|
|
|
def get_idp_mappers(self, idp_alias): |
|
|
|
""" |
|
|
|
Returns a list of ID Providers mappers |
|
|
|
|
|
|
|
IdentityProviderMapperRepresentation |
|
|
|
https://www.keycloak.org/docs-api/18.0/rest-api/index.html#_getmappers |
|
|
|
|
|
|
|
:param: idp_alias: alias for Idp to fetch mappers |
|
|
|
:return: array IdentityProviderMapperRepresentation |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name, "idp-alias": idp_alias} |
|
|
|
data_raw = self.raw_get(urls_patterns.URL_ADMIN_IDP_MAPPERS.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
def get_idps(self): |
|
|
|
""" |
|
|
|
Returns a list of ID Providers, |
|
|
|
|
|
@ -336,6 +336,12 @@ def test_idps(admin: KeycloakAdmin, realm: str): |
|
|
|
admin.add_mapper_to_idp(idp_alias="does-no-texist", payload=dict()) |
|
|
|
assert err.match('404: b\'{"error":"HTTP 404 Not Found"}\'') |
|
|
|
|
|
|
|
# Test IdP mappers listing |
|
|
|
idp_mappers = admin.get_idp_mappers( |
|
|
|
idp_alias="github", |
|
|
|
) |
|
|
|
assert len(idp_mappers) == 1 |
|
|
|
|
|
|
|
# Test delete |
|
|
|
res = admin.delete_idp(idp_alias="github") |
|
|
|
assert res == dict(), res |
|
|
|