Skip to content

Fix comparison of Scope field in PAS - RoleAssignment Resource #4803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaClassicAdmins.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaDeletionByScopeAtRootScope.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests\RaNegativeScenarios.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ public void RaDeletionByScope()
ResourcesController.NewInstance.RunPsTest("Test-RaDeletionByScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaDeletionByScopeAtRootScope()
{
ResourcesController.NewInstance.RunPsTest("Test-RaDeletionByScopeAtRootScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByUpn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,41 @@ function Test-RaDeletionByScope
VerifyRoleAssignmentDeleted $newAssignment
}

<#
.SYNOPSIS
Tests verifies creation and deletion of a RoleAssignments by Scope irrespective of the case
#>
function Test-RaDeletionByScopeAtRootScope
{
# Setup
$definitionName = 'Reader'
$users = Get-AzureRmADUser | Select-Object -First 1 -Wait
$subscription = Get-AzureRmSubscription
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
$scope = '/'
Assert-AreEqual 1 $users.Count "There should be at least one user to run the test."

# Test
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("fa1a4d3b-2cca-406b-8956-6b6b32377641")
$newAssignment = New-AzureRmRoleAssignment `
-ObjectId $users[0].Id.Guid `
-RoleDefinitionName $definitionName `
-Scope $scope
$newAssignment.Scope = $scope.toUpper()

# cleanup
DeleteRoleAssignment $newAssignment

# Assert
Assert-NotNull $newAssignment
Assert-AreEqual $definitionName $newAssignment.RoleDefinitionName
Assert-AreEqual $scope $newAssignment.Scope
Assert-AreEqual $users[0].DisplayName $newAssignment.DisplayName

VerifyRoleAssignmentDeleted $newAssignment
}


<#
.SYNOPSIS
Creates role assignment
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading