File tree Expand file tree Collapse file tree 5 files changed +2453
-1
lines changed
src/ResourceManager/Resources
Commands.Resources/Models.Authorization
SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests Expand file tree Collapse file tree 5 files changed +2453
-1
lines changed Original file line number Diff line number Diff line change 678
678
<None Include =" SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaValidateInputParameters.json" >
679
679
<CopyToOutputDirectory >Always</CopyToOutputDirectory >
680
680
</None >
681
+ <None Include =" SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaDeletionByScope.json" >
682
+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
683
+ </None >
681
684
<None Include =" SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests\RdNegativeScenarios.json" >
682
685
<CopyToOutputDirectory >PreserveNewest</CopyToOutputDirectory >
683
686
</None >
Original file line number Diff line number Diff line change @@ -96,6 +96,13 @@ public void RaByServicePrincipal()
96
96
ResourcesController . NewInstance . RunPsTest ( "Test-RaByServicePrincipal" ) ;
97
97
}
98
98
99
+ [ Fact ]
100
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
101
+ public void RaDeletionByScope ( )
102
+ {
103
+ ResourcesController . NewInstance . RunPsTest ( "Test-RaDeletionByScope" ) ;
104
+ }
105
+
99
106
[ Fact ]
100
107
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
101
108
public void RaByUpn ( )
Original file line number Diff line number Diff line change @@ -314,7 +314,41 @@ function Test-RaAuthorizationChangeLog
314
314
Assert-True { $log1.Count -ge 1 } " At least one record should be returned for the user"
315
315
}
316
316
317
+ <#
318
+ . SYNOPSIS
319
+ Tests verifies creation and deletion of a RoleAssignments by Scope irrespective of the case
320
+ #>
321
+ function Test-RaDeletionByScope
322
+ {
323
+ # Setup
324
+ Add-Type - Path " .\\Microsoft.Azure.Commands.Resources.dll"
317
325
326
+ $definitionName = ' Reader'
327
+ $users = Get-AzureRmADUser | Select-Object - First 1 - Wait
328
+ $subscription = Get-AzureRmSubscription
329
+ $resourceGroups = Get-AzureRmResourceGroup | Select-Object - Last 1 - Wait
330
+ $scope = ' /subscriptions/' + $subscription [0 ].Id + ' /resourceGroups/' + $resourceGroups [0 ].ResourceGroupName
331
+ Assert-AreEqual 1 $users.Count " There should be at least one user to run the test."
332
+
333
+ # Test
334
+ [Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient ]::RoleAssignmentNames.Enqueue(" fa1a4d3b-2cca-406b-8956-6b6b32377641" )
335
+ $newAssignment = New-AzureRmRoleAssignment `
336
+ - ObjectId $users [0 ].Id.Guid `
337
+ - RoleDefinitionName $definitionName `
338
+ - Scope $scope
339
+ $newAssignment.Scope = $scope.toUpper ()
340
+
341
+ # cleanup
342
+ DeleteRoleAssignment $newAssignment
343
+
344
+ # Assert
345
+ Assert-NotNull $newAssignment
346
+ Assert-AreEqual $definitionName $newAssignment.RoleDefinitionName
347
+ Assert-AreEqual $scope $newAssignment.Scope
348
+ Assert-AreEqual $users [0 ].DisplayName $newAssignment.DisplayName
349
+
350
+ VerifyRoleAssignmentDeleted $newAssignment
351
+ }
318
352
319
353
<#
320
354
. SYNOPSIS
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -317,7 +317,7 @@ public IEnumerable<PSRoleAssignment> RemoveRoleAssignment(FilterRoleAssignmentsO
317
317
// but an edge case can have multiple role assignments to the same role or multiple role assignments to different roles, with same name.
318
318
// The FilterRoleAssignments takes care of paging internally
319
319
IEnumerable < PSRoleAssignment > roleAssignments = FilterRoleAssignments ( options , currentSubscription : subscriptionId )
320
- . Where ( ra => ra . Scope == options . Scope . TrimEnd ( '/' ) ) ;
320
+ . Where ( ra => ra . Scope . Equals ( options . Scope . TrimEnd ( '/' ) , StringComparison . OrdinalIgnoreCase ) ) ;
321
321
322
322
if ( roleAssignments == null || ! roleAssignments . Any ( ) )
323
323
{
You can’t perform that action at this time.
0 commit comments