Skip to content

Commit 0a61209

Browse files
Andrea TomassilliAndrea Tomassilli
authored andcommitted
change
1 parent 7d37d0d commit 0a61209

File tree

4 files changed

+1344
-4
lines changed

4 files changed

+1344
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,12 @@ public void CreateRAWithObjectType()
245245
{
246246
TestRunner.RunTestScript("Test-CreateRAWithObjectType");
247247
}
248+
249+
[Fact]
250+
[Trait(Category.AcceptanceType, Category.CheckIn)]
251+
public void RAGuidFormatHandling()
252+
{
253+
TestRunner.RunTestScript("Test-RAGuidFormatHandling");
254+
}
248255
}
249256
}

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,3 +925,30 @@ function Test-CreateRAWhenIdNotExist
925925

926926
Assert-Throws $function $ExpectedError
927927
}
928+
929+
<#
930+
.SYNOPSIS
931+
Validates that Get-AzRoleAssignment can filter client-side the role assignments by ObjectId in different GUID formats.
932+
#>
933+
function Test-RAGuidFormatHandling
934+
{
935+
$subscription = $(Get-AzContext).Subscription
936+
$scope = '/subscriptions/'+ $subscription[0].Id
937+
$principalId = "35e5fdfa-e80b-49b9-abf3-4c9a54f6b7a3"
938+
939+
$expected = @(Get-AzRoleAssignment -ObjectId $principalId -Scope $scope -AtScope)
940+
$expectedIds = $expected | Select-Object -ExpandProperty RoleAssignmentId | Sort-Object
941+
942+
$guid = [guid]::Parse($principalId)
943+
$formats = @('N', 'D', 'B', 'P', 'X')
944+
foreach ($format in $formats) {
945+
$principalIdFormat = $guid.ToString($format)
946+
$actual = @(Get-AzRoleAssignment -ObjectId $principalIdFormat -Scope $scope -AtScope)
947+
Assert-AreEqual $expected.Count $actual.Count
948+
949+
if ($actual) {
950+
$actualIds = $actual | Select-Object -ExpandProperty RoleAssignmentId | Sort-Object
951+
Assert-AreEqual (@($expectedIds) -join ',') (@($actualIds) -join ',')
952+
}
953+
}
954+
}

0 commit comments

Comments
 (0)