Browse Source

feat: Add update_idp

pull/335/head
Bruno Bonfils 3 years ago
parent
commit
bcdf1b825b
  1. 16
      src/keycloak/keycloak_admin.py
  2. 5
      tests/test_keycloak_admin.py

16
src/keycloak/keycloak_admin.py

@ -397,6 +397,22 @@ class KeycloakAdmin:
)
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201])
def update_idp(self, idp_alias, payload):
"""
Update an ID Provider
IdentityProviderRepresentation
https://www.keycloak.org/docs-api/15.0/rest-api/index.html#_identity_providers_resource
:param: alias: alias for IdP to update
:param: payload: The IdentityProviderRepresentation
"""
params_path = {"realm-name": self.realm_name, "alias": idp_alias}
data_raw = self.raw_put(
urls_patterns.URL_ADMIN_IDP.format(**params_path), data=json.dumps(payload)
)
return raise_error_from_response(data_raw, KeycloakPutError, expected_codes=[204])
def add_mapper_to_idp(self, idp_alias, payload):
"""
Create an ID Provider,

5
tests/test_keycloak_admin.py

@ -320,6 +320,11 @@ def test_idps(admin: KeycloakAdmin, realm: str):
assert len(idps) == 1
assert "github" == idps[0]["alias"]
# Test IdP update
res = admin.update_idp(idp_alias="github", payload=idps[0])
assert res == {}, res
# Test adding a mapper
res = admin.add_mapper_to_idp(
idp_alias="github",

Loading…
Cancel
Save