Skip to content

Commit 16eae94

Browse files
committed
Merge pull request #1401 from shuagarw/customRoleScopeAndFilters
Custom role updates to add scoped role Assignments and additional filters
2 parents eaa63d3 + b90d426 commit 16eae94

File tree

46 files changed

+7912
-5544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+7912
-5544
lines changed

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Authorization">
6262
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/ApiManagement/Commands.SMAPI.Test/Commands.ApiManagement.ServiceManagement.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Authorization">
6262
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6262
</Reference>
6363
<Reference Include="Microsoft.Azure.Management.Authorization">
64-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
64+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Batch">
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.5.0\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Authorization">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.Compute, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7070
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<Private>True</Private>
7878
</Reference>
7979
<Reference Include="Microsoft.Azure.Management.Authorization">
80-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
80+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
8181
<Private>True</Private>
8282
</Reference>
8383
<Reference Include="Microsoft.Azure.Management.Compute, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

src/ResourceManager/DataFactories/Commands.DataFactories.Test/Commands.DataFactories.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Authorization">
6767
<SpecificVersion>False</SpecificVersion>
68-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.Management.DataFactories, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7171
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6161
</Reference>
6262
<Reference Include="Microsoft.Azure.Management.Authorization">
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/Dns/Commands.Dns/Commands.Dns.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<Private>True</Private>
101101
</Reference>
102102
<Reference Include="Microsoft.Azure.Management.Authorization">
103-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
103+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
104104
<Private>True</Private>
105105
</Reference>
106106
<Reference Include="Microsoft.Azure.Management.Dns">

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Commands.KeyVault.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.1.0.0\lib\net45\Microsoft.Azure.KeyVault.dll</HintPath>
7373
</Reference>
7474
<Reference Include="Microsoft.Azure.Management.Authorization">
75-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
75+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7676
</Reference>
7777
<Reference Include="Microsoft.Azure.Common.NetFramework">
7878
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>

src/ResourceManager/KeyVault/Commands.KeyVault/Commands.KeyVault.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
</Reference>
133133
<Reference Include="Microsoft.Azure.Management.Authorization">
134134
<SpecificVersion>False</SpecificVersion>
135-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
135+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
136136
</Reference>
137137
<Reference Include="Microsoft.Azure.Management.KeyVault, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
138138
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.1.0.1\lib\net40\Microsoft.Azure.Management.KeyVault.dll</HintPath>

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Authorization">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7070
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.15-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</Reference>
7575
<Reference Include="Microsoft.Azure.Management.Authorization">
7676
<SpecificVersion>False</SpecificVersion>
77-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
77+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7878
</Reference>
7979
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8080
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.15-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>

src/ResourceManager/NotificationHubs/Commands.NotificationHubs.Test/Commands.NotificationHubs.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<Private>True</Private>
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.Management.Authorization">
65-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.1.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
65+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6666
</Reference>
6767
<Reference Include="Microsoft.Azure.Management.NotificationHubs, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6868
<HintPath>..\..\..\packages\Microsoft.Azure.Management.NotificationHubs.0.1.0-preview\lib\portable-net45+wp8+wpa81+win\Microsoft.Azure.Management.NotificationHubs.dll</HintPath>

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/Commands.OperationalInsights.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.Management.Authorization">
58-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
58+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5959
</Reference>
6060
<Reference Include="Microsoft.Azure.Gallery">
6161
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.Management.Authorization">
74-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.1.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7575
</Reference>
7676
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7777
<SpecificVersion>False</SpecificVersion>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Test-RaClassicAdmins
2323
$subscription = Get-AzureRmSubscription
2424

2525
# Test
26-
$classic = Get-AzureRmRoleAssignment -IncludeClassicAdministrators | Where-Object { $_.Scope -ieq ('/subscriptions/' + $subscription.SubscriptionId) -and $_.RoleDefinitionName.ToLower().Contains('administrator')}
26+
$classic = Get-AzureRmRoleAssignment -IncludeClassicAdministrators | Where-Object { $_.Scope -ieq ('/subscriptions/' + $subscription[0].SubscriptionId) -and $_.RoleDefinitionName.ToLower().Contains('administrator')}
2727

2828
# Assert
2929
Assert-NotNull $classic
@@ -55,7 +55,7 @@ function Test-RaNegativeScenarios
5555
Assert-Throws { Get-AzureRmRoleAssignment -ServicePrincipalName $badSpn } $badObjectResult
5656

5757
# Bad Scope
58-
$badScope = '/subscriptions/'+ $subscription.SubscriptionId +'/providers/nonexistent'
58+
$badScope = '/subscriptions/'+ $subscription[0].SubscriptionId +'/providers/nonexistent'
5959
$badScopeException = "InvalidResourceNamespace: The resource namespace 'nonexistent' is invalid."
6060
Assert-Throws { Get-AzureRmRoleAssignment -Scope $badScope } $badScopeException
6161
}
@@ -73,7 +73,7 @@ function Test-RaByScope
7373
$users = Get-AzureRmADUser | Select-Object -First 1 -Wait
7474
$subscription = Get-AzureRmSubscription
7575
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
76-
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
76+
$scope = '/subscriptions/'+ $subscription[0].SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
7777
Assert-AreEqual 1 $users.Count "There should be at least one user to run the test."
7878

7979
# Test
@@ -140,17 +140,17 @@ function Test-RaByResource
140140
$definitionName = 'Owner'
141141
$groups = Get-AzureRmADGroup | Select-Object -Last 1 -Wait
142142
Assert-AreEqual 1 $groups.Count "There should be at least one group to run the test."
143-
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
144-
Assert-AreEqual 1 $resourceGroups.Count "No resource group found. Unable to run the test."
145-
$resource = Get-AzureRmResource -ResourceGroupName $resourceGroups[0].ResourceGroupName | Select-Object -Last 1 -Wait
143+
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
144+
Assert-AreEqual 1 $resourceGroups.Count "No resource group found. Unable to run the test."
145+
$resource = Get-AzureRmResource | Select-Object -Last 1 -Wait
146146
Assert-NotNull $resource "Cannot find any resource to continue test execution."
147147

148148
# Test
149149
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("78D6502F-74FC-4800-BB0A-0E1A7BEBECA4")
150150
$newAssignment = New-AzureRmRoleAssignment `
151151
-ObjectId $groups[0].Id.Guid `
152152
-RoleDefinitionName $definitionName `
153-
-ResourceGroupName $resourceGroups[0].ResourceGroupName `
153+
-ResourceGroupName $resource.ResourceGroupName `
154154
-ResourceType $resource.ResourceType `
155155
-ResourceName $resource.Name
156156

@@ -178,7 +178,7 @@ function Test-RaByServicePrincipal
178178
$servicePrincipals = Get-AzureRmADServicePrincipal | Select-Object -Last 1 -Wait
179179
$subscription = Get-AzureRmSubscription
180180
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
181-
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
181+
$scope = '/subscriptions/'+ $subscription[0].SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
182182
Assert-AreEqual 1 $servicePrincipals.Count "No service principals found. Unable to run the test."
183183

184184
# Test

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,19 @@ public void RdPositiveScenarios()
4141
{
4242
ResourcesController.NewInstance.RunPsTest("Test-RDPositiveScenarios");
4343
}
44+
45+
[Fact(Skip = "Unskip after service side change")]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void RDRemoveScenario()
48+
{
49+
ResourcesController.NewInstance.RunPsTest("Test-RDRemove");
50+
}
51+
52+
[Fact(Skip = "Unskip after service side change")]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void RDGetScenario()
55+
{
56+
ResourcesController.NewInstance.RunPsTest("Test-RDGet");
57+
}
4458
}
4559
}

0 commit comments

Comments
 (0)