Skip to content

Commit 12d2b1c

Browse files
feat: ability to patch existing IdP
Fixture updates as well as `oauthIssuerId` is no longer an attripute of IdP JIRA: TRIVIAL risk: low
1 parent 0052c9e commit 12d2b1c

File tree

9 files changed

+538
-87
lines changed

9 files changed

+538
-87
lines changed

gooddata-sdk/gooddata_sdk/catalog/organization/entity_model/identity_provider.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from gooddata_api_client.model.json_api_identity_provider_in import JsonApiIdentityProviderIn
88
from gooddata_api_client.model.json_api_identity_provider_in_attributes import JsonApiIdentityProviderInAttributes
99
from gooddata_api_client.model.json_api_identity_provider_in_document import JsonApiIdentityProviderInDocument
10+
from gooddata_api_client.model.json_api_identity_provider_patch import JsonApiIdentityProviderPatch
11+
from gooddata_api_client.model.json_api_identity_provider_patch_attributes import JsonApiIdentityProviderPatchAttributes
12+
from gooddata_api_client.model.json_api_identity_provider_patch_document import JsonApiIdentityProviderPatchDocument
1013

1114
from gooddata_sdk.catalog.base import Base
1215
from gooddata_sdk.utils import safeget
@@ -72,6 +75,14 @@ def from_api(cls, entity: dict[str, Any]) -> CatalogIdentityProvider:
7275
attributes=attr,
7376
)
7477

78+
@classmethod
79+
def to_api_patch(cls, identity_provider_id: str, attributes: dict) -> JsonApiIdentityProviderPatchDocument:
80+
return JsonApiIdentityProviderPatchDocument(
81+
data=JsonApiIdentityProviderPatch(
82+
id=identity_provider_id, attributes=JsonApiIdentityProviderPatchAttributes(**attributes)
83+
)
84+
)
85+
7586

7687
@attr.s(auto_attribs=True, kw_only=True)
7788
class CatalogIdentityProviderAttributes(Base):

gooddata-sdk/gooddata_sdk/catalog/organization/service.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,23 @@ def update_identity_provider(self, identity_provider: CatalogIdentityProvider) -
407407
f"Can not update {identity_provider.id} identity provider. This identity provider does not exist."
408408
)
409409

410+
def patch_identity_provider_attributes(self, identity_provider_id: str, attributes: dict) -> None:
411+
"""Applies changes to the specified identity provider.
412+
413+
Args:
414+
identity_provider_id (str):
415+
Identity Provider identification string. e.g. "auth0"
416+
attributes (dict):
417+
A dictionary containing attributes of the identity provider to be changed.
418+
419+
Returns:
420+
None
421+
"""
422+
423+
self._entities_api.patch_entity_identity_providers(
424+
identity_provider_id, CatalogIdentityProvider.to_api_patch(identity_provider_id, attributes)
425+
)
426+
410427
# Layout APIs
411428

412429
def get_declarative_notification_channels(self) -> list[CatalogDeclarativeNotificationChannel]:

gooddata-sdk/tests/catalog/fixtures/organization/create_identity_provider.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ interactions:
66
uri: http://localhost:3000/api/v1/entities/identityProviders
77
body:
88
data:
9-
id: test_identity_provider
10-
type: identityProvider
119
attributes:
12-
customClaimMapping:
13-
email: email
1410
identifiers:
1511
- goodtesting.com
12+
customClaimMapping:
13+
email: email
1614
oauthClientId: test_client_id
1715
oauthClientSecret: test_client_secret
18-
oauthIssuerId: test_issuer_id
1916
oauthIssuerLocation: https://issuer.goodtesting.com
17+
id: test_identity_provider
18+
type: identityProvider
2019
headers:
2120
Accept:
2221
- application/vnd.gooddata.api+json
@@ -88,16 +87,15 @@ interactions:
8887
body:
8988
string:
9089
data:
91-
id: test_identity_provider
92-
type: identityProvider
9390
attributes:
9491
identifiers:
9592
- goodtesting.com
9693
customClaimMapping:
9794
email: email
9895
oauthClientId: test_client_id
9996
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id
97+
id: test_identity_provider
98+
type: identityProvider
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
103101
- request:
@@ -172,16 +170,15 @@ interactions:
172170
body:
173171
string:
174172
data:
175-
id: test_identity_provider
176-
type: identityProvider
177173
attributes:
178174
identifiers:
179175
- goodtesting.com
180176
customClaimMapping:
181177
email: email
182178
oauthClientId: test_client_id
183179
oauthIssuerLocation: https://issuer.goodtesting.com
184-
oauthIssuerId: test_issuer_id
180+
id: test_identity_provider
181+
type: identityProvider
185182
links:
186183
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
187184
- request:

gooddata-sdk/tests/catalog/fixtures/organization/delete_identity_provider.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ interactions:
66
uri: http://localhost:3000/api/v1/entities/identityProviders
77
body:
88
data:
9-
id: test_identity_provider
10-
type: identityProvider
119
attributes:
12-
customClaimMapping:
13-
email: email
1410
identifiers:
1511
- goodtesting.com
12+
customClaimMapping:
13+
email: email
1614
oauthClientId: test_client_id
1715
oauthClientSecret: test_client_secret
18-
oauthIssuerId: test_issuer_id
1916
oauthIssuerLocation: https://issuer.goodtesting.com
17+
id: test_identity_provider
18+
type: identityProvider
2019
headers:
2120
Accept:
2221
- application/vnd.gooddata.api+json
@@ -88,16 +87,15 @@ interactions:
8887
body:
8988
string:
9089
data:
91-
id: test_identity_provider
92-
type: identityProvider
9390
attributes:
9491
identifiers:
9592
- goodtesting.com
9693
customClaimMapping:
9794
email: email
9895
oauthClientId: test_client_id
9996
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id
97+
id: test_identity_provider
98+
type: identityProvider
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider
103101
- request:

gooddata-sdk/tests/catalog/fixtures/organization/layout_identity_providers.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ interactions:
7878
uri: http://localhost:3000/api/v1/layout/identityProviders
7979
body:
8080
- id: test_identity_provider
81-
customClaimMapping:
82-
email: email
8381
identifiers:
8482
- goodtesting.com
83+
customClaimMapping:
84+
email: email
8585
oauthClientId: test_client_id
8686
oauthClientSecret: test_client_secret
87-
oauthIssuerId: test_issuer_id
8887
oauthIssuerLocation: https://issuer.goodtesting.com
8988
headers:
9089
Accept-Encoding:
@@ -222,13 +221,12 @@ interactions:
222221
Path=/; HTTPOnly; SameSite=Lax
223222
body:
224223
string:
225-
- customClaimMapping:
226-
email: email
227-
id: test_identity_provider
224+
- id: test_identity_provider
228225
identifiers:
229-
- goodtesting.com
226+
goodtesting.com
227+
customClaimMapping:
228+
email: email
230229
oauthClientId: test_client_id
231-
oauthIssuerId: test_issuer_id
232230
oauthIssuerLocation: https://issuer.goodtesting.com
233231
- request:
234232
method: PUT

gooddata-sdk/tests/catalog/fixtures/organization/list_identity_providers.yaml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ interactions:
66
uri: http://localhost:3000/api/v1/entities/identityProviders
77
body:
88
data:
9-
id: test_identity_provider_1
10-
type: identityProvider
119
attributes:
12-
customClaimMapping:
13-
email: email
1410
identifiers:
1511
- goodtesting.com
12+
customClaimMapping:
13+
email: email
1614
oauthClientId: test_client_id_1
1715
oauthClientSecret: test_client_secret_1
18-
oauthIssuerId: test_issuer_id_1
1916
oauthIssuerLocation: https://issuer.goodtesting.com
17+
id: test_identity_provider_1
18+
type: identityProvider
2019
headers:
2120
Accept:
2221
- application/vnd.gooddata.api+json
@@ -88,34 +87,32 @@ interactions:
8887
body:
8988
string:
9089
data:
91-
id: test_identity_provider_1
92-
type: identityProvider
9390
attributes:
9491
identifiers:
9592
- goodtesting.com
9693
customClaimMapping:
9794
email: email
9895
oauthClientId: test_client_id_1
9996
oauthIssuerLocation: https://issuer.goodtesting.com
100-
oauthIssuerId: test_issuer_id_1
97+
id: test_identity_provider_1
98+
type: identityProvider
10199
links:
102100
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_1
103101
- request:
104102
method: POST
105103
uri: http://localhost:3000/api/v1/entities/identityProviders
106104
body:
107105
data:
108-
id: test_identity_provider_2
109-
type: identityProvider
110106
attributes:
111-
customClaimMapping:
112-
email: email
113107
identifiers:
114108
- goodtesting.com
109+
customClaimMapping:
110+
email: email
115111
oauthClientId: test_client_id_2
116112
oauthClientSecret: test_client_secret_2
117-
oauthIssuerId: test_issuer_id_2
118113
oauthIssuerLocation: https://issuer.goodtesting.com
114+
id: test_identity_provider_2
115+
type: identityProvider
119116
headers:
120117
Accept:
121118
- application/vnd.gooddata.api+json
@@ -186,16 +183,15 @@ interactions:
186183
body:
187184
string:
188185
data:
189-
id: test_identity_provider_2
190-
type: identityProvider
191186
attributes:
192187
identifiers:
193188
- goodtesting.com
194189
customClaimMapping:
195190
email: email
196191
oauthClientId: test_client_id_2
197192
oauthIssuerLocation: https://issuer.goodtesting.com
198-
oauthIssuerId: test_issuer_id_2
193+
id: test_identity_provider_2
194+
type: identityProvider
199195
links:
200196
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_2
201197
- request:
@@ -270,28 +266,28 @@ interactions:
270266
body:
271267
string:
272268
data:
273-
- id: test_identity_provider_1
274-
type: identityProvider
275-
attributes:
269+
- attributes:
276270
identifiers:
277271
- goodtesting.com
278272
customClaimMapping:
279273
email: email
280274
oauthClientId: test_client_id_1
281-
oauthIssuerLocation: https://issuer.goodtesting.com
282-
oauthIssuerId: test_issuer_id_1
275+
oauthIssuerLocation:
276+
https://issuer.goodtesting.com
277+
id: test_identity_provider_1
278+
type: identityProvider
283279
links:
284280
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_1
285-
- id: test_identity_provider_2
286-
type: identityProvider
287-
attributes:
281+
- attributes:
288282
identifiers:
289283
- goodtesting.com
290284
customClaimMapping:
291285
email: email
292286
oauthClientId: test_client_id_2
293-
oauthIssuerLocation: https://issuer.goodtesting.com
294-
oauthIssuerId: test_issuer_id_2
287+
oauthIssuerLocation:
288+
https://issuer.goodtesting.com
289+
id: test_identity_provider_2
290+
type: identityProvider
295291
links:
296292
self: http://localhost:3000/api/v1/entities/identityProviders/test_identity_provider_2
297293
links:

0 commit comments

Comments
 (0)