Skip to content

Commit ee3e640

Browse files
committed
Merge pull request Azure#1193 from surabhi-pandey/roledefinitionfix
RoleDefinition PUT and DELETE requests should use first assignable scope as the url scope
2 parents 01f2ffe + 4edfa6a commit ee3e640

File tree

8 files changed

+132
-132
lines changed

8 files changed

+132
-132
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.Management.Authorization">
74-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.2\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.1.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7575
</Reference>
7676
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7777
<SpecificVersion>False</SpecificVersion>

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"no-cache"
2929
],
3030
"x-ms-request-id": [
31-
"86e78e03-f2ba-4bb8-85a8-4f35837e50bc"
31+
"a25dd16d-774f-457e-967e-a38ee00e3f58"
3232
],
3333
"x-ms-gateway-service-instanceid": [
34-
"PASFE_IN_2"
34+
"PASFE_IN_0"
3535
],
3636
"X-Content-Type-Options": [
3737
"nosniff"
@@ -40,19 +40,19 @@
4040
"max-age=31536000; includeSubDomains"
4141
],
4242
"x-ms-ratelimit-remaining-subscription-reads": [
43-
"14999"
43+
"14709"
4444
],
4545
"x-ms-correlation-request-id": [
46-
"ab17e75f-8b3e-4d04-ade8-fed4591c4440"
46+
"8cc3a1ec-2204-4e59-9be6-c1d35950b4c2"
4747
],
4848
"x-ms-routing-request-id": [
49-
"CENTRALUS:20151015T013236Z:ab17e75f-8b3e-4d04-ade8-fed4591c4440"
49+
"WESTUS:20151028T002132Z:8cc3a1ec-2204-4e59-9be6-c1d35950b4c2"
5050
],
5151
"Cache-Control": [
5252
"no-cache"
5353
],
5454
"Date": [
55-
"Thu, 15 Oct 2015 01:32:36 GMT"
55+
"Wed, 28 Oct 2015 00:21:32 GMT"
5656
],
5757
"Set-Cookie": [
5858
"x-ms-gateway-slice=productionb; path=/"
@@ -94,7 +94,7 @@
9494
"no-cache"
9595
],
9696
"x-ms-request-id": [
97-
"70d9dd77-f9de-4a4f-b842-a9c418b17b84"
97+
"9e94b46a-b9ac-4fc0-8650-5679ee3fdb0f"
9898
],
9999
"x-ms-gateway-service-instanceid": [
100100
"PASFE_IN_2"
@@ -106,19 +106,19 @@
106106
"max-age=31536000; includeSubDomains"
107107
],
108108
"x-ms-ratelimit-remaining-subscription-reads": [
109-
"14998"
109+
"14708"
110110
],
111111
"x-ms-correlation-request-id": [
112-
"92594bda-9940-43c5-bb8d-c55238a504da"
112+
"ff7b0d49-beb6-4e7b-9a3f-ba09654c33d9"
113113
],
114114
"x-ms-routing-request-id": [
115-
"CENTRALUS:20151015T013236Z:92594bda-9940-43c5-bb8d-c55238a504da"
115+
"WESTUS:20151028T002133Z:ff7b0d49-beb6-4e7b-9a3f-ba09654c33d9"
116116
],
117117
"Cache-Control": [
118118
"no-cache"
119119
],
120120
"Date": [
121-
"Thu, 15 Oct 2015 01:32:36 GMT"
121+
"Wed, 28 Oct 2015 00:21:32 GMT"
122122
],
123123
"Set-Cookie": [
124124
"x-ms-gateway-slice=productionb; path=/"
@@ -160,7 +160,7 @@
160160
"no-cache"
161161
],
162162
"x-ms-request-id": [
163-
"1d0c3a9c-e40c-44ee-84ed-88c37a0a2e10"
163+
"3fbaaa67-482e-4690-8a4e-055fa68f1b81"
164164
],
165165
"x-ms-gateway-service-instanceid": [
166166
"PASFE_IN_2"
@@ -172,19 +172,19 @@
172172
"max-age=31536000; includeSubDomains"
173173
],
174174
"x-ms-ratelimit-remaining-subscription-reads": [
175-
"14997"
175+
"14707"
176176
],
177177
"x-ms-correlation-request-id": [
178-
"41eb1391-cb2b-4926-9d4e-61c083799002"
178+
"d69b4abb-595e-4897-8edb-2f23f9b395b3"
179179
],
180180
"x-ms-routing-request-id": [
181-
"CENTRALUS:20151015T013236Z:41eb1391-cb2b-4926-9d4e-61c083799002"
181+
"WESTUS:20151028T002133Z:d69b4abb-595e-4897-8edb-2f23f9b395b3"
182182
],
183183
"Cache-Control": [
184184
"no-cache"
185185
],
186186
"Date": [
187-
"Thu, 15 Oct 2015 01:32:36 GMT"
187+
"Wed, 28 Oct 2015 00:21:32 GMT"
188188
],
189189
"Set-Cookie": [
190190
"x-ms-gateway-slice=productionb; path=/"

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

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

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

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

src/ResourceManager/Resources/Commands.Resources.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Insights" version="0.7.7-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Authorization" version="1.0.2" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Authorization" version="1.1.0" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.Framework" version="1.0.5772.15967-prerelease" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5772.15967-prerelease" targetFramework="net45" />

src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.2-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
7070
</Reference>
7171
<Reference Include="Microsoft.Azure.Management.Authorization">
72-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.2\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
72+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.1.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
73+
<Private>True</Private>
7374
</Reference>
7475
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7576
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/Resources/Commands.Resources/Models.Authorization/AuthorizationClient.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,11 @@ public PSRoleDefinition GetRoleRoleDefinition(string name)
335335
public PSRoleDefinition RemoveRoleDefinition(Guid roleDefinitionId, string subscriptionId)
336336
{
337337
string id = roleDefinitionId.ToString();
338-
string roleDefinitionFullyQualifiedId = AuthorizationHelper.GetRoleDefinitionFullyQualifiedId(subscriptionId, id);
339338

340339
PSRoleDefinition roleDefinition = this.GetRoleDefinition(roleDefinitionId);
341340
if (roleDefinition != null)
342341
{
343-
return AuthorizationManagementClient.RoleDefinitions.Delete(roleDefinitionFullyQualifiedId).RoleDefinition.ToPSRoleDefinition();
342+
return AuthorizationManagementClient.RoleDefinitions.Delete(roleDefinitionId, roleDefinition.AssignableScopes.First()).RoleDefinition.ToPSRoleDefinition();
344343
}
345344
else
346345
{
@@ -356,8 +355,7 @@ public PSRoleDefinition RemoveRoleDefinition(Guid roleDefinitionId, string subsc
356355
public PSRoleDefinition RemoveRoleDefinition(string roleDefinitionName, string subscriptionId)
357356
{
358357
PSRoleDefinition roleDefinition = this.GetRoleRoleDefinition(roleDefinitionName);
359-
string roleDefinitionFullyQualifiedId = AuthorizationHelper.GetRoleDefinitionFullyQualifiedId(subscriptionId, roleDefinition.Id);
360-
return AuthorizationManagementClient.RoleDefinitions.Delete(roleDefinitionFullyQualifiedId).RoleDefinition.ToPSRoleDefinition();
358+
return AuthorizationManagementClient.RoleDefinitions.Delete(Guid.Parse(roleDefinition.Id), roleDefinition.AssignableScopes.First()).RoleDefinition.ToPSRoleDefinition();
361359
}
362360

363361
/// <summary>
@@ -392,6 +390,7 @@ public PSRoleDefinition UpdateRoleDefinition(PSRoleDefinition role, string subsc
392390
return
393391
AuthorizationManagementClient.RoleDefinitions.CreateOrUpdate(
394392
roleDefinitionId,
393+
roleDefinition.AssignableScopes.First(),
395394
new RoleDefinitionCreateOrUpdateParameters()
396395
{
397396
RoleDefinition = new RoleDefinition()
@@ -449,7 +448,7 @@ public PSRoleDefinition CreateRoleDefinition(PSRoleDefinition roleDefinition)
449448
PSRoleDefinition roleDef = null;
450449
try
451450
{
452-
roleDef = AuthorizationManagementClient.RoleDefinitions.CreateOrUpdate(newRoleDefinitionId, parameters).RoleDefinition.ToPSRoleDefinition();
451+
roleDef = AuthorizationManagementClient.RoleDefinitions.CreateOrUpdate(newRoleDefinitionId, roleDefinition.AssignableScopes.First(), parameters).RoleDefinition.ToPSRoleDefinition();
453452
}
454453
catch (CloudException ce)
455454
{
@@ -476,7 +475,7 @@ private static void ValidateRoleDefinition(PSRoleDefinition roleDefinition)
476475
throw new ArgumentException(ProjectResources.InvalidRoleDefinitionDescription);
477476
}
478477

479-
if (roleDefinition.AssignableScopes == null || !roleDefinition.AssignableScopes.Any())
478+
if (roleDefinition.AssignableScopes == null || !roleDefinition.AssignableScopes.Any() || roleDefinition.AssignableScopes.Any(s => string.IsNullOrWhiteSpace(s)))
480479
{
481480
throw new ArgumentException(ProjectResources.InvalidAssignableScopes);
482481
}

src/ResourceManager/Resources/Commands.Resources/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.2-preview" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Authorization" version="1.0.2" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Authorization" version="1.1.0" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Resources" version="2.18.11-preview" targetFramework="net45" />
1111
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
1212
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

0 commit comments

Comments
 (0)