Skip to content

Commit 6eab10f

Browse files
authored
Merge pull request Azure#4803 from AshishGargMicrosoft/ashigarg/PowerShellChanges
Fix comparison of Scope field in PAS - RoleAssignment Resource
2 parents 5439f89 + d15af67 commit 6eab10f

File tree

15 files changed

+11557
-2296
lines changed

15 files changed

+11557
-2296
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@
682682
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaClassicAdmins.json">
683683
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
684684
</None>
685+
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaDeletionByScopeAtRootScope.json">
686+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
687+
</None>
685688
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaNegativeScenarios.json">
686689
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
687690
</None>

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ public void RaDeletionByScope()
103103
ResourcesController.NewInstance.RunPsTest("Test-RaDeletionByScope");
104104
}
105105

106+
[Fact]
107+
[Trait(Category.AcceptanceType, Category.CheckIn)]
108+
public void RaDeletionByScopeAtRootScope()
109+
{
110+
ResourcesController.NewInstance.RunPsTest("Test-RaDeletionByScopeAtRootScope");
111+
}
112+
106113
[Fact]
107114
[Trait(Category.AcceptanceType, Category.CheckIn)]
108115
public void RaByUpn()

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,41 @@ function Test-RaDeletionByScope
345345
VerifyRoleAssignmentDeleted $newAssignment
346346
}
347347

348+
<#
349+
.SYNOPSIS
350+
Tests verifies creation and deletion of a RoleAssignments by Scope irrespective of the case
351+
#>
352+
function Test-RaDeletionByScopeAtRootScope
353+
{
354+
# Setup
355+
$definitionName = 'Reader'
356+
$users = Get-AzureRmADUser | Select-Object -First 1 -Wait
357+
$subscription = Get-AzureRmSubscription
358+
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
359+
$scope = '/'
360+
Assert-AreEqual 1 $users.Count "There should be at least one user to run the test."
361+
362+
# Test
363+
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("fa1a4d3b-2cca-406b-8956-6b6b32377641")
364+
$newAssignment = New-AzureRmRoleAssignment `
365+
-ObjectId $users[0].Id.Guid `
366+
-RoleDefinitionName $definitionName `
367+
-Scope $scope
368+
$newAssignment.Scope = $scope.toUpper()
369+
370+
# cleanup
371+
DeleteRoleAssignment $newAssignment
372+
373+
# Assert
374+
Assert-NotNull $newAssignment
375+
Assert-AreEqual $definitionName $newAssignment.RoleDefinitionName
376+
Assert-AreEqual $scope $newAssignment.Scope
377+
Assert-AreEqual $users[0].DisplayName $newAssignment.DisplayName
378+
379+
VerifyRoleAssignmentDeleted $newAssignment
380+
}
381+
382+
348383
<#
349384
.SYNOPSIS
350385
Creates role assignment

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByResource.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByResourceGroup.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByScope.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByServicePrincipal.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByUpn.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaClassicAdmins.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaDeleteByPSRoleAssignment.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaDeletionByScope.json

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

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaDeletionByScopeAtRootScope.json

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

0 commit comments

Comments
 (0)