@@ -386,21 +386,25 @@ Tests verifies creation and validation of RoleAssignment properties for not null
386
386
function Test-RaPropertiesValidation
387
387
{
388
388
# Setup
389
- $definitionName = ' CustomRole Tests Role'
390
- [Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient ]::RoleDefinitionNames.Enqueue(" 8D7DD69E-9AE2-44A1-94D8-F7BC8E12645E" )
391
- New-AzureRmRoleDefinition - InputFile .\Resources\NewRoleDefinition.json
392
389
$users = Get-AzureRmADUser | Select-Object - First 1 - Wait
393
390
$subscription = Get-AzureRmSubscription
394
- $resourceGroups = Get-AzureRmResourceGroup | Select-Object - Last 1 - Wait
395
391
$scope = ' /subscriptions/' + $subscription [0 ].Id
396
- Assert-AreEqual 1 $users.Count " There should be at least one user to run the test."
397
- $rd = Get-AzureRmRoleDefinition - Name $definitionName
392
+ $roleDef = Get-AzureRmRoleDefinition - Name " Reader"
393
+ $roleDef.Id = $null
394
+ $roleDef.Name = " Custom Reader Test"
395
+ $roleDef.Actions.Add (" Microsoft.ClassicCompute/virtualMachines/restart/action" )
396
+ $roleDef.Description = " Read, monitor and restart virtual machines"
397
+ $roleDef.AssignableScopes [0 ] = " /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f"
398
+
399
+ [Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient ]::RoleDefinitionNames.Enqueue(" 032F61D2-ED09-40C9-8657-26A273DA7BAE" )
400
+ New-AzureRmRoleDefinition - Role $roleDef
401
+ $rd = Get-AzureRmRoleDefinition - Name " Custom Reader Test"
398
402
399
403
# Test
400
404
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient ]::RoleAssignmentNames.Enqueue(" fa1a4d3b-2cca-406b-8956-6b6b32377641" )
401
405
$newAssignment = New-AzureRmRoleAssignment `
402
406
- ObjectId $users [0 ].Id.Guid `
403
- - RoleDefinitionName $definitionName `
407
+ - RoleDefinitionName $roleDef .Name `
404
408
- Scope $scope
405
409
$newAssignment.Scope = $scope.toUpper ()
406
410
@@ -418,7 +422,7 @@ function Test-RaPropertiesValidation
418
422
419
423
# Assert
420
424
Assert-NotNull $newAssignment
421
- Assert-AreEqual $definitionName $newAssignment.RoleDefinitionName
425
+ Assert-AreEqual $roleDef .Name $newAssignment.RoleDefinitionName
422
426
Assert-AreEqual $scope $newAssignment.Scope
423
427
Assert-AreEqual $users [0 ].DisplayName $newAssignment.DisplayName
424
428
0 commit comments