Skip to content
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

update roledefinition get custom roles to use filter #5664

Merged
merged 9 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions src/ResourceManager/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## Current Release
* Fixed issue with importing aliases
* Add Support for DataActions and NotDataActions to be passed in roledefinition create calls
* Fix Roledefinitions calls to use the type filter

## Version 5.4.0
* Register-AzureRmProviderFeature: Added missing example in the docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.3.4.0-preview\lib\net452\Microsoft.Azure.Graph.RBAC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.7.0-preview\lib\net452\Microsoft.Azure.Management.Authorization.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.8.0-preview\lib\net452\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Insights">
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.10.0-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
Expand Down Expand Up @@ -713,6 +713,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests\RDUpdate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests\RDFilter.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleDefinitionTests\RoleDefinitionDataActionsCreateTests.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,9 @@ function Test-RaPropertiesValidation
$roleDef.Description = "Read, monitor and restart virtual machines"
$roleDef.AssignableScopes[0] = "/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f"

[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleDefinitionNames.Enqueue("032F61D2-ED09-40C9-8657-26A273DA7BAE")
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleDefinitionNames.Enqueue("171d2453-29dc-42b4-84fc-3fd259eeaec3")
New-AzureRmRoleDefinition -Role $roleDef
$rd = Get-AzureRmRoleDefinition -Name "Custom Reader Test"

# Test
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("2fec1202-19ad-4c8b-b461-6031a1b5dce6")
$newAssignment = New-AzureRmRoleAssignment `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darshanhs90 why is this command being removed from this test?

Copy link
Contributor Author

@darshanhs90 darshanhs90 Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne it was a redundant thing added in the test,as you can see earlier in the same test,we are creating a roleassignment, so that would be sufficient to validate the scenario for this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad,thought the earlier create was also for a roleassignment, will revert it

-ObjectId $users[0].Id.Guid `
-RoleDefinitionName $roleDef.Name `
-Scope $scope
$newAssignment.Scope = $scope.toUpper()

$assignments = Get-AzureRmRoleAssignment
Assert-NotNull $assignments
Expand All @@ -503,16 +495,7 @@ function Test-RaPropertiesValidation
}

# cleanup
DeleteRoleAssignment $newAssignment
Remove-AzureRmRoleDefinition -Id $rd.Id -Force

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

VerifyRoleAssignmentDeleted $newAssignment
}

<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ public void RDCreateFromFile()
ResourcesController.NewInstance.RunPsTest("Test-RDCreateFromFile");
}

[Fact(Skip = "Unskip after service side change")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RDFilter()
{
ResourcesController.NewInstance.RunPsTest("Test-RDFilter");
}

[Fact(Skip = "Unskip after service side change")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RDRemoveScenario()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,16 @@ function Test-RDGetAtScopeFilterRoles
{
# Setup
# Basic positive case - read from file
$rdName = 'CustomRole Tests Role New'
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleDefinitionNames.Enqueue("17643b76-fff5-4c48-b1a7-f4da3297a8cb")
New-AzureRmRoleDefinition -InputFile .\Resources\DataActionsRoleDefinition.json
$rdName = 'Another tests role'
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleDefinitionNames.Enqueue("3d95b97a-5745-4c39-950c-0b608dea635f")
$rd = New-AzureRmRoleDefinition -InputFile .\Resources\RoleDefinition.json

$rd = Get-AzureRmRoleDefinition -Name $rdName -AtScopeAndBelow
Assert-AreEqual "Test role" $rd.Description
Assert-AreEqual $true $rd.IsCustom
Assert-NotNull $rd.DataActions
Assert-AreEqual "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/*" $rd.DataActions[0]
Assert-NotNull $rd.NotDataActions
Assert-AreEqual "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write" $rd.NotDataActions[0]
Assert-NotNull $rd.AssignableScopes
Assert-Null $rd.Actions
Assert-Null $rd.NotActions
Assert-NotNull $rd.Actions
Assert-NotNull $rd.NotActions

# Basic positive case - read from object
Remove-AzureRmRoleDefinition -Id $rd.Id -Force
Expand Down Expand Up @@ -440,6 +436,26 @@ function Test-RdValidateInputParameters2 ($cmdName)
Assert-Throws { &$cmdName -Role $roleDef } $invalidScope
}

<#
.SYNOPSIS
Verify positive and negative scenarios for RoleDefinition Get with filters.
#>
function Test-RDFilter
{
# Setup
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleDefinitionNames.Enqueue("5282481f-37e6-40d3-bec0-b797e0496d3c")
$readerRole = Get-AzureRmRoleDefinition -Name "Reader"
Assert-NotNull $readerRole
Assert-AreEqual $readerRole.Name "Reader"

$customRoles = Get-AzureRmRoleDefinition -Custom
Assert-NotNull $customRoles
foreach($role in $customRoles){
Assert-NotNull $role
Assert-AreEqual $role.IsCustom $true
}
}

<#
.SYNOPSIS
Tests verify scenarios for RoleDefinitions creation.
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.

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