Skip to content

Commit d5aaa37

Browse files
committed
role name filter and bug fixes
1 parent 6926479 commit d5aaa37

File tree

12 files changed

+2181
-1914
lines changed

12 files changed

+2181
-1914
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,56 +37,56 @@ public void RaAuthorizationChangeLog()
3737
ResourcesController.NewInstance.RunPsTest("Test-RaAuthorizationChangeLog");
3838
}
3939

40-
[Fact(Skip = "Need to re-record test")]
40+
[Fact]
4141
[Trait(Category.AcceptanceType, Category.CheckIn)]
4242
public void RaClassicAdmins()
4343
{
4444
ResourcesController.NewInstance.RunPsTest("Test-RaClassicAdmins");
4545
}
4646

47-
[Fact(Skip = "Need to re-record test")]
47+
[Fact]
4848
[Trait(Category.AcceptanceType, Category.CheckIn)]
4949
public void RaNegativeScenarios()
5050
{
5151
ResourcesController.NewInstance.RunPsTest("Test-RaNegativeScenarios");
5252
}
5353

54-
[Fact(Skip = "Need to re-record test")]
54+
[Fact]
5555
[Trait(Category.AcceptanceType, Category.CheckIn)]
5656
public void RaByScope()
5757
{
5858
ResourcesController.NewInstance.RunPsTest("Test-RaByScope");
5959
}
6060

61-
[Fact(Skip = "Need to re-record test")]
61+
[Fact]
6262
[Trait(Category.AcceptanceType, Category.CheckIn)]
6363
public void RaByResourceGroup()
6464
{
6565
ResourcesController.NewInstance.RunPsTest("Test-RaByResourceGroup");
6666
}
6767

68-
[Fact(Skip = "Need to re-record test")]
68+
[Fact]
6969
[Trait(Category.AcceptanceType, Category.CheckIn)]
7070
public void RaByResource()
7171
{
7272
ResourcesController.NewInstance.RunPsTest("Test-RaByResource");
7373
}
7474

75-
[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
75+
[Fact]
7676
[Trait(Category.AcceptanceType, Category.CheckIn)]
7777
public void RaByServicePrincipal()
7878
{
7979
ResourcesController.NewInstance.RunPsTest("Test-RaByServicePrincipal");
8080
}
8181

82-
[Fact(Skip = "Need to re-record test")]
82+
[Fact]
8383
[Trait(Category.AcceptanceType, Category.CheckIn)]
8484
public void RaByUpn()
8585
{
8686
ResourcesController.NewInstance.RunPsTest("Test-RaByUpn");
8787
}
8888

89-
[Fact(Skip="Need to re-record test")]
89+
[Fact(Skip = "Need to re-record test")]
9090
public void RaUserPermissions()
9191
{
9292
User newUser = null;

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Test-RaClassicAdmins
2020
{
2121
# Setup
2222
Add-Type -Path ".\\Microsoft.Azure.Commands.Resources.dll"
23-
$subscription = Get-AzureRmSubscription -Current
23+
$subscription = Get-AzureRmSubscription
2424

2525
# Test
2626
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("8D7DD69E-9AE2-44A1-94D8-F7BC8E12645E")
@@ -40,22 +40,20 @@ function Test-RaNegativeScenarios
4040
# Setup
4141
Add-Type -Path ".\\Microsoft.Azure.Commands.Resources.dll"
4242

43-
$subscription = Get-AzureRmSubscription -Current
43+
$subscription = Get-AzureRmSubscription
4444

4545
# Bad OID does not throw when getting a non-existing role assignment
4646
$badOid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
47-
$badOidResult = Get-AzureRmRoleAssignment -ObjectId $badOid
48-
Assert-Null $badOidResult
47+
$badObjectResult = "Cannot find principal using the specified options"
48+
Assert-Throws { Get-AzureRmRoleAssignment -ObjectId $badOid} $badObjectResult
4949

5050
# Bad UPN
5151
$badUpn = '[email protected]'
52-
$badUpnException = "The provided information does not map to an AD object id."
53-
Assert-Throws { Get-AzureRmRoleAssignment -UserPrincipalName $badUpn } $badUpnException
52+
Assert-Throws { Get-AzureRmRoleAssignment -UserPrincipalName $badUpn } $badObjectResult
5453

5554
# Bad SPN
5655
$badSpn = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
57-
$badSpnException = "The provided information does not map to an AD object id."
58-
Assert-Throws { Get-AzureRmRoleAssignment -ServicePrincipalName $badSpn } $badSpnException
56+
Assert-Throws { Get-AzureRmRoleAssignment -ServicePrincipalName $badSpn } $badObjectResult
5957

6058
# Bad Scope
6159
$badScope = '/subscriptions/'+ $subscription.SubscriptionId +'/providers/nonexistent'
@@ -74,7 +72,7 @@ function Test-RaByScope
7472

7573
$definitionName = 'Reader'
7674
$users = Get-AzureRmADUser | Select-Object -First 1 -Wait
77-
$subscription = Get-AzureRmSubscription -Current
75+
$subscription = Get-AzureRmSubscription
7876
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
7977
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
8078
Assert-AreEqual 1 $users.Count "There should be at least one user to run the test."
@@ -145,7 +143,7 @@ function Test-RaByResource
145143
Assert-AreEqual 1 $groups.Count "There should be at least one group to run the test."
146144
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
147145
Assert-AreEqual 1 $resourceGroups.Count "No resource group found. Unable to run the test."
148-
$resource = Get-AzureRmResource -ResourceGroupName $resourceGroups[0].ResourceGroupName
146+
$resource = Get-AzureRmResource -ResourceGroupName $resourceGroups[0].ResourceGroupName | Select-Object -Last 1 -Wait
149147
Assert-NotNull $resource "Cannot find any resource to continue test execution."
150148

151149
# Test
@@ -179,7 +177,7 @@ function Test-RaByServicePrincipal
179177

180178
$definitionName = 'Reader'
181179
$servicePrincipals = Get-AzureRmADServicePrincipal | Select-Object -Last 1 -Wait
182-
$subscription = Get-AzureRmSubscription -Current
180+
$subscription = Get-AzureRmSubscription
183181
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
184182
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
185183
Assert-AreEqual 1 $servicePrincipals.Count "No service principals found. Unable to run the test."
@@ -310,6 +308,6 @@ function VerifyRoleAssignmentDeleted
310308

311309
$deletedRoleAssignment = Get-AzureRmRoleAssignment -ObjectId $roleAssignment.ObjectId.Guid `
312310
-Scope $roleAssignment.Scope `
313-
-RoleDefinitionName $roleAssignment.RoleDefinitionName
311+
-RoleDefinitionName $roleAssignment.RoleDefinitionName | where {$_.roleAssignmentId -eq $roleAssignment.roleAssignmentId}
314312
Assert-Null $deletedRoleAssignment
315313
}

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByResource.json

Lines changed: 338 additions & 205 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByResourceGroup.json

Lines changed: 419 additions & 164 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByScope.json

Lines changed: 289 additions & 134 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByServicePrincipal.json

Lines changed: 318 additions & 154 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaByUpn.json

Lines changed: 433 additions & 175 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.RoleAssignmentTests/RaClassicAdmins.json

Lines changed: 87 additions & 1001 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)