Skip to content

Commit e5cbd99

Browse files
mumoryanRyan Ren
andauthored
Fix abac condition not included in role definition payload 2 (#23904)
Co-authored-by: Ryan Ren <[email protected]>
1 parent f20e67a commit e5cbd99

File tree

12 files changed

+571
-300
lines changed

12 files changed

+571
-300
lines changed

src/Resources/Resources.Test/ScenarioTests/RoleDefinitionTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public void RDGetScenario()
117117
{
118118
TestRunner.RunTestScript("Test-RDGet");
119119
}
120+
121+
[Fact]
122+
[Trait(Category.AcceptanceType, Category.CheckIn)]
123+
public void RDWithConditionGetScenario()
124+
{
125+
TestRunner.RunTestScript("Test-RDWithAbacConditionsGet");
126+
}
120127

121128
[Fact]
122129
[Trait(Category.AcceptanceType, Category.CheckIn)]

src/Resources/Resources.Test/ScenarioTests/RoleDefinitionTests.ps1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,51 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
<#
16+
.SYNOPSIS
17+
Tests verify scenarios for RoleDefinitions creation.
18+
#>
19+
function Test-RDWithAbacConditionsGet
20+
{
21+
# Setup
22+
$subscription = $(Get-AzContext).Subscription
23+
24+
$resource = Get-AzResource | Select-Object -Last 1 -Wait
25+
Assert-NotNull $resource "Cannot find any resource to continue test execution."
26+
27+
$subScope = "/subscriptions/" + $subscription[0].SubscriptionId
28+
$rgScope = "/subscriptions/" + $subscription[0].SubscriptionId + "/resourceGroups/" + $resource.ResourceGroupName
29+
$resourceScope = $resource.ResourceId
30+
31+
# Task 1: Get Contributor role, verify condition doesn't exist
32+
$roleDef1 = Get-AzRoleDefinition -Name "Reader"
33+
Assert-AreEqual $roleDef1.Name "Reader"
34+
Assert-AreEqual $false $roleDef1.IsCustom
35+
36+
# TODO: replace the active code with the commented Permissions check after the breaking change
37+
# Assert-NotNull $roleDef1.Permissions
38+
# Assert-True { $roleDef1.Permissions.Length -gt 0 }
39+
# Assert-NotNull $roleDef1.Permissions[0].Actions
40+
# Assert-True { $roleDef1.Permissions[0].Actions.Length -gt 0 }
41+
Assert-NotNull $roleDef1.Actions
42+
Assert-True { $roleDef1.Actions.Length -gt 0 }
43+
44+
# Task 2: Get Key Vault role, verify condition exists
45+
$roleDef2 = Get-AzRoleDefinition -Id 8b54135c-b56d-4d72-a534-26097cfdc8d8
46+
Assert-AreEqual $false $roleDef1.IsCustom
47+
48+
# TODO: replace the active code with the commented Permissions check after the breaking change
49+
# Assert-NotNull $roleDef2.Permissions
50+
# Assert-True { $roleDef2.Permissions.Length -gt 0 }
51+
# Assert-NotNull $roleDef2.Permissions[0].Actions
52+
# Assert-NotNull $roleDef2.Permissions[0].Condition
53+
# Assert-NotNull $roleDef2.Permissions[0].ConditionVersion
54+
Assert-NotNull $roleDef2.Actions
55+
Assert-True { $roleDef2.Actions.Length -gt 0 }
56+
Assert-NotNull $roleDef2.ConditionVersion
57+
Assert-NotNull $roleDef2.Condition
58+
}
59+
1560
<#
1661
.SYNOPSIS
1762
Tests verify scenarios for RoleDefinitions creation.

src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests/RDFilter.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
"RequestMethod": "GET",
77
"RequestHeaders": {
88
"x-ms-client-request-id": [
9-
"8307b308-3ee7-47aa-96be-8a6a9c2cc774"
9+
"a2f0c6f1-d216-4b32-95d9-f1c0e5ff9d6b"
1010
],
1111
"Accept-Language": [
1212
"en-US"
1313
],
1414
"User-Agent": [
1515
"FxVersion/6.0.2523.51912",
1616
"OSName/Windows",
17-
"OSVersion/Microsoft.Windows.10.0.23606",
18-
"Microsoft.Azure.Management.Authorization.AuthorizationManagementClient/6.12.0"
17+
"OSVersion/Microsoft.Windows.10.0.23612",
18+
"Microsoft.Azure.Management.Authorization.AuthorizationManagementClient/6.13.0"
1919
]
2020
},
2121
"RequestBody": "",
@@ -27,7 +27,7 @@
2727
"no-cache"
2828
],
2929
"x-ms-request-id": [
30-
"b8bbf362-9f8a-4e3e-ad5d-885818fa77a4"
30+
"71225889-740a-4338-8a27-87cce6222d6d"
3131
],
3232
"X-Content-Type-Options": [
3333
"nosniff"
@@ -39,16 +39,16 @@
3939
"x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly"
4040
],
4141
"x-ms-ratelimit-remaining-subscription-reads": [
42-
"11998"
42+
"11999"
4343
],
4444
"x-ms-correlation-request-id": [
45-
"a6cb0a47-a7ad-43d6-91c3-ad88f16e5818"
45+
"5cc130f2-2628-4594-bfa8-9a36245d93e1"
4646
],
4747
"x-ms-routing-request-id": [
48-
"WESTUS2:20231219T080514Z:a6cb0a47-a7ad-43d6-91c3-ad88f16e5818"
48+
"WESTUS2:20240109T031247Z:5cc130f2-2628-4594-bfa8-9a36245d93e1"
4949
],
5050
"Date": [
51-
"Tue, 19 Dec 2023 08:05:13 GMT"
51+
"Tue, 09 Jan 2024 03:12:46 GMT"
5252
],
5353
"Content-Length": [
5454
"627"
@@ -72,16 +72,16 @@
7272
"RequestMethod": "GET",
7373
"RequestHeaders": {
7474
"x-ms-client-request-id": [
75-
"d7e52298-3f08-4933-b08b-25640b484d59"
75+
"96c667b6-3d64-4d85-9516-0769d84908d3"
7676
],
7777
"Accept-Language": [
7878
"en-US"
7979
],
8080
"User-Agent": [
8181
"FxVersion/6.0.2523.51912",
8282
"OSName/Windows",
83-
"OSVersion/Microsoft.Windows.10.0.23606",
84-
"Microsoft.Azure.Management.Authorization.AuthorizationManagementClient/6.12.0"
83+
"OSVersion/Microsoft.Windows.10.0.23612",
84+
"Microsoft.Azure.Management.Authorization.AuthorizationManagementClient/6.13.0"
8585
]
8686
},
8787
"RequestBody": "",
@@ -93,7 +93,7 @@
9393
"no-cache"
9494
],
9595
"x-ms-request-id": [
96-
"6e0db89b-3f49-4a3b-8d28-29f39ed52529"
96+
"28c5c972-c565-4dfa-a680-f79bc39894bc"
9797
],
9898
"X-Content-Type-Options": [
9999
"nosniff"
@@ -105,16 +105,16 @@
105105
"x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly"
106106
],
107107
"x-ms-ratelimit-remaining-subscription-reads": [
108-
"11998"
108+
"11999"
109109
],
110110
"x-ms-correlation-request-id": [
111-
"3a09c70f-f6d0-4b8b-a126-f0a9b82701ed"
111+
"6f095309-4a48-45ae-b3d1-b292099bf206"
112112
],
113113
"x-ms-routing-request-id": [
114-
"WESTUS2:20231219T080514Z:3a09c70f-f6d0-4b8b-a126-f0a9b82701ed"
114+
"WESTUS2:20240109T031247Z:6f095309-4a48-45ae-b3d1-b292099bf206"
115115
],
116116
"Date": [
117-
"Tue, 19 Dec 2023 08:05:13 GMT"
117+
"Tue, 09 Jan 2024 03:12:47 GMT"
118118
],
119119
"Content-Length": [
120120
"956286"

src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests/RDGetScenario.json

Lines changed: 117 additions & 117 deletions
Large diffs are not rendered by default.

src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests/RDWithConditionGetScenario.json

Lines changed: 203 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)