Browse Source

feat: Add get_idp_mappers, fix #329

pull/330/head
Bruno Bonfils 3 years ago
parent
commit
9a13f67fea
  1. 14
      src/keycloak/keycloak_admin.py
  2. 6
      tests/test_keycloak_admin.py

14
src/keycloak/keycloak_admin.py

@ -413,6 +413,20 @@ class KeycloakAdmin:
) )
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201]) 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): def get_idps(self):
""" """
Returns a list of ID Providers, Returns a list of ID Providers,

6
tests/test_keycloak_admin.py

@ -336,6 +336,12 @@ def test_idps(admin: KeycloakAdmin, realm: str):
admin.add_mapper_to_idp(idp_alias="does-no-texist", payload=dict()) admin.add_mapper_to_idp(idp_alias="does-no-texist", payload=dict())
assert err.match('404: b\'{"error":"HTTP 404 Not Found"}\'') 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 # Test delete
res = admin.delete_idp(idp_alias="github") res = admin.delete_idp(idp_alias="github")
assert res == dict(), res assert res == dict(), res

Loading…
Cancel
Save