Browse Source
Merge pull request #335 from asyd/update_idp
feat: Add update_idp
pull/340/head
v1.5.0
Richard Nemeth
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
21 additions and
0 deletions
-
src/keycloak/keycloak_admin.py
-
tests/test_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, |
|
|
|
|
|
@ -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", |
|
|
|