Skip to content

Commit b20b378

Browse files
authored
feat(IAM Identity): add few new account settings (#308)
Signed-off-by: Hari K Arla <[email protected]>
1 parent 43d8c65 commit b20b378

File tree

5 files changed

+2855
-2254
lines changed

5 files changed

+2855
-2254
lines changed

.secrets.baseline

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-01-09T22:39:35Z",
6+
"generated_at": "2025-10-30T10:03:11Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -78,19 +78,27 @@
7878
],
7979
"results": {
8080
"examples/test_iam_identity_v1_examples.py": [
81+
{
82+
"hashed_secret": "469f62fa9e1c6afe62e8808180668934ee548e8f",
83+
"is_secret": false,
84+
"is_verified": false,
85+
"line_number": 1598,
86+
"type": "Secret Keyword",
87+
"verified_result": null
88+
},
8189
{
8290
"hashed_secret": "a2190c299b60e882d9fb33736d5e6ab6ffe42708",
8391
"is_secret": false,
8492
"is_verified": false,
85-
"line_number": 939,
93+
"line_number": 1697,
8694
"type": "Secret Keyword",
8795
"verified_result": null
8896
},
8997
{
9098
"hashed_secret": "cf4d2385b84329a52ca542285b93d9c4618420df",
9199
"is_secret": false,
92100
"is_verified": false,
93-
"line_number": 1618,
101+
"line_number": 1816,
94102
"type": "Secret Keyword",
95103
"verified_result": null
96104
}
@@ -117,18 +125,18 @@
117125
],
118126
"test/integration/test_iam_identity_v1.py": [
119127
{
120-
"hashed_secret": "a2190c299b60e882d9fb33736d5e6ab6ffe42708",
128+
"hashed_secret": "469f62fa9e1c6afe62e8808180668934ee548e8f",
121129
"is_secret": false,
122130
"is_verified": false,
123-
"line_number": 1148,
131+
"line_number": 1874,
124132
"type": "Secret Keyword",
125133
"verified_result": null
126134
},
127135
{
128-
"hashed_secret": "cf4d2385b84329a52ca542285b93d9c4618420df",
136+
"hashed_secret": "a2190c299b60e882d9fb33736d5e6ab6ffe42708",
129137
"is_secret": false,
130138
"is_verified": false,
131-
"line_number": 1702,
139+
"line_number": 1964,
132140
"type": "Secret Keyword",
133141
"verified_result": null
134142
}
@@ -270,31 +278,23 @@
270278
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
271279
"is_secret": false,
272280
"is_verified": false,
273-
"line_number": 1575,
281+
"line_number": 1969,
274282
"type": "Secret Keyword",
275283
"verified_result": null
276284
},
277285
{
278-
"hashed_secret": "cf4d2385b84329a52ca542285b93d9c4618420df",
286+
"hashed_secret": "b8473b86d4c2072ca9b08bd28e373e8253e865c4",
279287
"is_secret": false,
280288
"is_verified": false,
281-
"line_number": 4055,
289+
"line_number": 12008,
282290
"type": "Secret Keyword",
283291
"verified_result": null
284292
},
285293
{
286294
"hashed_secret": "469f62fa9e1c6afe62e8808180668934ee548e8f",
287295
"is_secret": false,
288296
"is_verified": false,
289-
"line_number": 9511,
290-
"type": "Secret Keyword",
291-
"verified_result": null
292-
},
293-
{
294-
"hashed_secret": "b8473b86d4c2072ca9b08bd28e373e8253e865c4",
295-
"is_secret": false,
296-
"is_verified": false,
297-
"line_number": 10632,
297+
"line_number": 12086,
298298
"type": "Secret Keyword",
299299
"verified_result": null
300300
}
@@ -352,7 +352,7 @@
352352
}
353353
]
354354
},
355-
"version": "0.13.1+ibm.62.dss",
355+
"version": "0.13.1+ibm.64.dss",
356356
"word_list": {
357357
"file": null,
358358
"hash": null

examples/test_iam_identity_v1_examples.py

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def waitUntilTrustedProfileAssignmentFinished(cls, service, assignmentId):
171171
profile_template_assignment_etag is not None
172172
break
173173
except ApiException as e:
174-
if e.code == 404:
174+
if getattr(e, "status_code", None) == 404:
175175
finished = True
176176
break
177177
time.sleep(10)
@@ -191,7 +191,7 @@ def waitUntilAccountSettingsAssignmentFinished(cls, service, assignmentId):
191191
account_settings_template_assignment_etag is not None
192192
break
193193
except ApiException as e:
194-
if e.code == 404:
194+
if getattr(e, "status_code", None) == 404:
195195
finished = True
196196
break
197197
time.sleep(10)
@@ -1576,15 +1576,42 @@ def test_create_account_settings_template(self):
15761576
print('\ncreate_account_settings_template() result:')
15771577
# begin-create_account_settings_template
15781578

1579-
account_settings = {}
1580-
account_settings['mfa'] = 'LEVEL1'
1581-
account_settings['system_access_token_expiration_in_seconds'] = 3000
1579+
# Construct a dict representation of a UserMfa model
1580+
user_mfa_model = {
1581+
'iam_id': iam_id,
1582+
'mfa': 'LEVEL2',
1583+
}
1584+
# Construct a dict representation of a AccountSettingsUserDomainRestriction model
1585+
account_settings_user_domain_restriction_model = {
1586+
'realm_id': 'IBMid',
1587+
'invitation_email_allow_patterns': ["*.*@ibm.com"],
1588+
'restrict_invitation': True,
1589+
}
1590+
# Construct a dict representation of a TemplateAccountSettingsRestrictUserDomains model
1591+
template_account_settings_restrict_user_domains_model = {
1592+
'account_sufficient': True,
1593+
'restrictions': [account_settings_user_domain_restriction_model],
1594+
}
1595+
# Construct a dict representation of a TemplateAccountSettings model
1596+
template_account_settings_model = {
1597+
'restrict_create_service_id': 'NOT_SET',
1598+
'restrict_create_platform_apikey': 'NOT_SET',
1599+
'mfa': 'LEVEL1',
1600+
'user_mfa': [user_mfa_model],
1601+
'session_expiration_in_seconds': '86400',
1602+
'session_invalidation_in_seconds': '7200',
1603+
'max_sessions_per_identity': '10',
1604+
'system_access_token_expiration_in_seconds': '3600',
1605+
'system_refresh_token_expiration_in_seconds': '259200',
1606+
'restrict_user_list_visibility': 'RESTRICTED',
1607+
'restrict_user_domains': template_account_settings_restrict_user_domains_model,
1608+
}
15821609

15831610
create_response = iam_identity_service.create_account_settings_template(
15841611
name=account_settings_template_name,
15851612
description='IAM enterprise account settings template example',
15861613
account_id=enterprise_account_id,
1587-
account_settings=account_settings,
1614+
account_settings=template_account_settings_model,
15881615
)
15891616
account_settings_template = create_response.get_result()
15901617
print('\ncreate_account_settings_template() response: ', json.dumps(account_settings_template, indent=2))
@@ -1648,9 +1675,36 @@ def test_update_account_settings_template(self):
16481675
global account_settings_template_etag
16491676
# begin-update_account_settings_template_version
16501677

1651-
account_settings = {}
1652-
account_settings['mfa'] = 'LEVEL1'
1653-
account_settings['system_access_token_expiration_in_seconds'] = 3000
1678+
# Construct a dict representation of a UserMfa model
1679+
user_mfa_model = {
1680+
'iam_id': iam_id,
1681+
'mfa': 'LEVEL1',
1682+
}
1683+
# Construct a dict representation of a AccountSettingsUserDomainRestriction model
1684+
account_settings_user_domain_restriction_model = {
1685+
'realm_id': 'IBMid',
1686+
'invitation_email_allow_patterns': ["*.*@sap.com"],
1687+
'restrict_invitation': True,
1688+
}
1689+
# Construct a dict representation of a TemplateAccountSettingsRestrictUserDomains model
1690+
template_account_settings_restrict_user_domains_model = {
1691+
'account_sufficient': False,
1692+
'restrictions': [account_settings_user_domain_restriction_model],
1693+
}
1694+
# Construct a dict representation of a TemplateAccountSettings model
1695+
template_account_settings_model = {
1696+
'restrict_create_service_id': 'NOT_RESTRICTED',
1697+
'restrict_create_platform_apikey': 'NOT_RESTRICTED',
1698+
'mfa': 'LEVEL2',
1699+
'user_mfa': [user_mfa_model],
1700+
'session_expiration_in_seconds': '72400',
1701+
'session_invalidation_in_seconds': '6000',
1702+
'max_sessions_per_identity': '5',
1703+
'system_access_token_expiration_in_seconds': '3000',
1704+
'system_refresh_token_expiration_in_seconds': '200000',
1705+
'restrict_user_list_visibility': 'NOT_RESTRICTED',
1706+
'restrict_user_domains': template_account_settings_restrict_user_domains_model,
1707+
}
16541708

16551709
update_response = iam_identity_service.update_account_settings_template_version(
16561710
account_id=enterprise_account_id,
@@ -1659,7 +1713,7 @@ def test_update_account_settings_template(self):
16591713
if_match=account_settings_template_etag,
16601714
name=account_settings_template_name,
16611715
description='IAM enterprise account settings template example - updated',
1662-
account_settings=account_settings,
1716+
account_settings=template_account_settings_model,
16631717
)
16641718
account_settings_template = update_response.get_result()
16651719
print('\nupdate_account_settings_template() response: ', json.dumps(account_settings_template, indent=2))
@@ -1761,6 +1815,18 @@ def test_create_new_account_settings_template_version(self):
17611815
account_settings['system_access_token_expiration_in_seconds'] = 2600
17621816
account_settings['restrict_create_platform_apikey'] = 'RESTRICTED'
17631817
account_settings['restrict_create_service_id'] = 'RESTRICTED'
1818+
account_settings['session_expiration_in_seconds'] = 75000
1819+
account_settings['session_invalidation_in_seconds'] = 5000
1820+
account_settings['max_sessions_per_identity'] = '7'
1821+
account_settings['restrict_user_list_visibility'] = 'RESTRICTED'
1822+
account_settings_user_mfa = {}
1823+
account_settings_user_mfa['iam_id'] = iam_id
1824+
account_settings_user_mfa['mfa'] = 'LEVEL2'
1825+
account_settings['user_mfa'] = [account_settings_user_mfa]
1826+
account_settings_user_domain_restriction_model = {}
1827+
account_settings_user_domain_restriction_model['realm_id'] = 'IBMid'
1828+
account_settings_user_domain_restriction_model['invitation_email_allow_patterns'] = ['*.*@example.com']
1829+
account_settings_user_domain_restriction_model['restrict_invitation'] = True
17641830

17651831
create_response = iam_identity_service.create_account_settings_template_version(
17661832
template_id=account_settings_template_id,

0 commit comments

Comments
 (0)