Skip to content

Commit 2fd55cd

Browse files
committed
add test
1 parent 85ba541 commit 2fd55cd

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
CommandName:
10+
- role definition show
11+
Connection:
12+
- keep-alive
13+
ParameterSetName:
14+
- --scope --name
15+
User-Agent:
16+
- AZURECLI/2.68.0 azsdk-python-core/1.31.0 Python/3.12.8 (Windows-11-10.0.26100-SP0)
17+
method: GET
18+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7?api-version=2022-05-01-preview
19+
response:
20+
body:
21+
string: '{"properties":{"roleName":"Reader","type":"BuiltInRole","description":"View
22+
all resources, but does not allow you to make any changes.","assignableScopes":["/"],"permissions":[{"actions":["*/read"],"notActions":[],"dataActions":[],"notDataActions":[]}],"createdOn":"2015-02-02T21:55:09.8806423Z","updatedOn":"2021-11-11T20:13:47.8628684Z","createdBy":null,"updatedBy":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7","type":"Microsoft.Authorization/roleDefinitions","name":"acdd72a7-3385-48ef-bd42-f606fba81ae7"}'
23+
headers:
24+
cache-control:
25+
- no-cache
26+
content-length:
27+
- '615'
28+
content-type:
29+
- application/json; charset=utf-8
30+
date:
31+
- Fri, 10 Jan 2025 07:54:33 GMT
32+
expires:
33+
- '-1'
34+
pragma:
35+
- no-cache
36+
strict-transport-security:
37+
- max-age=31536000; includeSubDomains
38+
x-cache:
39+
- CONFIG_NOCACHE
40+
x-content-type-options:
41+
- nosniff
42+
x-ms-ratelimit-remaining-subscription-global-reads:
43+
- '3749'
44+
x-msedge-ref:
45+
- 'Ref A: C77DCAED801740129F3CD473A8769DB3 Ref B: MAA201060514025 Ref C: 2025-01-10T07:54:33Z'
46+
status:
47+
code: 200
48+
message: OK
49+
- request:
50+
body: null
51+
headers:
52+
Accept:
53+
- application/json
54+
Accept-Encoding:
55+
- gzip, deflate
56+
CommandName:
57+
- role definition show
58+
Connection:
59+
- keep-alive
60+
ParameterSetName:
61+
- --id
62+
User-Agent:
63+
- AZURECLI/2.68.0 azsdk-python-core/1.31.0 Python/3.12.8 (Windows-11-10.0.26100-SP0)
64+
method: GET
65+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7?api-version=2022-05-01-preview
66+
response:
67+
body:
68+
string: '{"properties":{"roleName":"Reader","type":"BuiltInRole","description":"View
69+
all resources, but does not allow you to make any changes.","assignableScopes":["/"],"permissions":[{"actions":["*/read"],"notActions":[],"dataActions":[],"notDataActions":[]}],"createdOn":"2015-02-02T21:55:09.8806423Z","updatedOn":"2021-11-11T20:13:47.8628684Z","createdBy":null,"updatedBy":null},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7","type":"Microsoft.Authorization/roleDefinitions","name":"acdd72a7-3385-48ef-bd42-f606fba81ae7"}'
70+
headers:
71+
cache-control:
72+
- no-cache
73+
content-length:
74+
- '615'
75+
content-type:
76+
- application/json; charset=utf-8
77+
date:
78+
- Fri, 10 Jan 2025 07:54:33 GMT
79+
expires:
80+
- '-1'
81+
pragma:
82+
- no-cache
83+
strict-transport-security:
84+
- max-age=31536000; includeSubDomains
85+
x-cache:
86+
- CONFIG_NOCACHE
87+
x-content-type-options:
88+
- nosniff
89+
x-ms-ratelimit-remaining-subscription-global-reads:
90+
- '3749'
91+
x-msedge-ref:
92+
- 'Ref A: D49E3175E27F409E98371B2D445CFB62 Ref B: MAA201060513027 Ref C: 2025-01-10T07:54:34Z'
93+
status:
94+
code: 200
95+
message: OK
96+
version: 1

src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,26 @@ def test_create_for_rbac_argument_error(self):
198198

199199
class RoleDefinitionScenarioTest(RoleScenarioTestBase):
200200

201+
def test_built_in_role_definition_scenario(self):
202+
self.kwargs['sub_scope'] = '/subscriptions/{}'.format(self.cmd('account show').get_output_in_json()['id'])
203+
204+
# Show Reader built-in role definition by scope and name
205+
self.cmd('role definition show --scope {sub_scope} --name acdd72a7-3385-48ef-bd42-f606fba81ae7',
206+
checks=[
207+
self.check('name', 'acdd72a7-3385-48ef-bd42-f606fba81ae7'),
208+
self.check('roleName', 'Reader'),
209+
self.check('roleType', 'BuiltInRole')
210+
])
211+
212+
# Show Reader built-in role definition by resource ID
213+
self.cmd('role definition show --id '
214+
'{sub_scope}/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7',
215+
checks=[
216+
self.check('name', 'acdd72a7-3385-48ef-bd42-f606fba81ae7'),
217+
self.check('roleName', 'Reader'),
218+
self.check('roleType', 'BuiltInRole')
219+
])
220+
201221
@AllowLargeResponse()
202222
def test_role_definition_scenario(self):
203223
subscription_id = self.get_subscription_id()

0 commit comments

Comments
 (0)