Skip to content

Commit 60ce7fa

Browse files
authored
Merge pull request #5985 from darshanhs90/preview1
Include deleted users/groups/serviceprincipals for Get-AzureRmRoleAssignment calls
2 parents a312d30 + 1dbfd77 commit 60ce7fa

23 files changed

+5244
-4845
lines changed

src/ResourceManager/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
## Current Release
2121
* Set minimum dependency of module to PowerShell 5.0
2222
* Remove obsolete parameter -AtScopeAndBelow from Get-AzureRmRoledefinition call
23+
* Include assignments to deleted USers/Groups/ServicePrincipals in Get-AzureRmRoleAssignment result
2324

2425
## Version 5.5.2
2526
* Updated to the latest version of the Azure ClientRuntime

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@
683683
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaById.json">
684684
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
685685
</None>
686+
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaDeletedPrincipals.json">
687+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
688+
</None>
686689
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests\RdNegativeScenarios.json">
687690
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
688691
</None>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public void RaClassicAdmins()
4444
ResourcesController.NewInstance.RunPsTest("Test-RaClassicAdmins");
4545
}
4646

47+
[Fact]
48+
[Trait(Category.AcceptanceType, Category.CheckIn)]
49+
public void RaDeletedPrincipals()
50+
{
51+
ResourcesController.NewInstance.RunPsTest("Test-RaDeletedPrincipals");
52+
}
53+
4754
[Fact]
4855
[Trait(Category.AcceptanceType, Category.Flaky)]
4956
public void RaPropertiesValidation() {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ function Test-RaClassicAdmins
2929
Assert-True { $classic.Length -ge 1 }
3030
}
3131

32+
<#
33+
.SYNOPSIS
34+
Tests retrieval of assignments to deleted principals/Users/Groups
35+
This test will fail if the objectId is changed or the role assignment deleted
36+
#>
37+
function Test-RaDeletedPrincipals
38+
{
39+
$objectId = "d49bc32d-d030-4ab6-8c98-e90a5b88f602"
40+
$assignment = Get-AzureRmRoleAssignment -ObjectId $objectId
41+
Assert-NotNull $assignment
42+
Assert-NotNull $assignment.ObjectType
43+
Assert-AreEqual $assignment.ObjectType "Unknown"
44+
Assert-NotNull $assignment.ObjectId
45+
Assert-AreEqual $assignment.ObjectId $objectId
46+
}
47+
3248
<#
3349
.SYNOPSIS
3450
Tests verifies negative scenarios for RoleAssignments

0 commit comments

Comments
 (0)