Skip to content

. #162

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 8 commits into from
Oct 18, 2015
Merged

. #162

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 @@ -71,11 +71,11 @@
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.1\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.11-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework">
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Name": "Another tests role",
"Id": "/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/providers/Microsoft.Authorization/roleDefinitions/85E460B3-89E9-48BA-9DCD-A8A99D64A674",
"Id": "85E460B3-89E9-48BA-9DCD-A8A99D64A674",
"Description": "Test role",
"Actions": [
"Microsoft.Authorization/*/read",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,56 @@ public void RaAuthorizationChangeLog()
ResourcesController.NewInstance.RunPsTest("Test-RaAuthorizationChangeLog");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaClassicAdmins()
{
ResourcesController.NewInstance.RunPsTest("Test-RaClassicAdmins");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaNegativeScenarios()
{
ResourcesController.NewInstance.RunPsTest("Test-RaNegativeScenarios");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByScope()
{
ResourcesController.NewInstance.RunPsTest("Test-RaByScope");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByResourceGroup()
{
ResourcesController.NewInstance.RunPsTest("Test-RaByResourceGroup");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByResource()
{
ResourcesController.NewInstance.RunPsTest("Test-RaByResource");
}

[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByServicePrincipal()
{
ResourcesController.NewInstance.RunPsTest("Test-RaByServicePrincipal");
}

[Fact(Skip = "Need to re-record test")]
[Fact(Skip = "tenantID NullException")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaByUpn()
{
ResourcesController.NewInstance.RunPsTest("Test-RaByUpn");
}

[Fact(Skip="Need to re-record test")]
[Fact(Skip = "Need to re-record test")]
public void RaUserPermissions()
{
User newUser = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ function Test-RaClassicAdmins
{
# Setup
Add-Type -Path ".\\Microsoft.Azure.Commands.Resources.dll"
$subscription = Get-AzureRmSubscription -Current
$subscription = Get-AzureRmSubscription

# Test
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("8D7DD69E-9AE2-44A1-94D8-F7BC8E12645E")
$classic = Get-AzureRmRoleAssignment -IncludeClassicAdministrators | Where-Object { $_.Scope -ieq ('/subscriptions/' + $subscription.SubscriptionId) -and $_.RoleDefinitionName.ToLower().Contains('administrator')}

# Assert
Expand All @@ -40,22 +39,20 @@ function Test-RaNegativeScenarios
# Setup
Add-Type -Path ".\\Microsoft.Azure.Commands.Resources.dll"

$subscription = Get-AzureRmSubscription -Current
$subscription = Get-AzureRmSubscription

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

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

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

# Bad Scope
$badScope = '/subscriptions/'+ $subscription.SubscriptionId +'/providers/nonexistent'
Expand All @@ -74,7 +71,7 @@ function Test-RaByScope

$definitionName = 'Reader'
$users = Get-AzureRmADUser | Select-Object -First 1 -Wait
$subscription = Get-AzureRmSubscription -Current
$subscription = Get-AzureRmSubscription
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
Assert-AreEqual 1 $users.Count "There should be at least one user to run the test."
Expand Down Expand Up @@ -145,7 +142,7 @@ function Test-RaByResource
Assert-AreEqual 1 $groups.Count "There should be at least one group to run the test."
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
Assert-AreEqual 1 $resourceGroups.Count "No resource group found. Unable to run the test."
$resource = Get-AzureRmResource -ResourceGroupName $resourceGroups[0].ResourceGroupName
$resource = Get-AzureRmResource -ResourceGroupName $resourceGroups[0].ResourceGroupName | Select-Object -Last 1 -Wait
Assert-NotNull $resource "Cannot find any resource to continue test execution."

# Test
Expand Down Expand Up @@ -179,7 +176,7 @@ function Test-RaByServicePrincipal

$definitionName = 'Reader'
$servicePrincipals = Get-AzureRmADServicePrincipal | Select-Object -Last 1 -Wait
$subscription = Get-AzureRmSubscription -Current
$subscription = Get-AzureRmSubscription
$resourceGroups = Get-AzureRmResourceGroup | Select-Object -Last 1 -Wait
$scope = '/subscriptions/'+ $subscription.SubscriptionId +'/resourceGroups/' + $resourceGroups[0].ResourceGroupName
Assert-AreEqual 1 $servicePrincipals.Count "No service principals found. Unable to run the test."
Expand Down Expand Up @@ -222,7 +219,7 @@ function Test-RaByUpn
# Test
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("8d7dd69e-9ae2-44a1-94d8-f7bc8e12645e")
$newAssignment = New-AzureRmRoleAssignment `
-UPN $users[0].Mail `
-SignInName $users[0].Mail `
-RoleDefinitionName $definitionName `
-ResourceGroupName $resourceGroups[0].ResourceGroupName

Expand Down Expand Up @@ -310,6 +307,6 @@ function VerifyRoleAssignmentDeleted

$deletedRoleAssignment = Get-AzureRmRoleAssignment -ObjectId $roleAssignment.ObjectId.Guid `
-Scope $roleAssignment.Scope `
-RoleDefinitionName $roleAssignment.RoleDefinitionName
-RoleDefinitionName $roleAssignment.RoleDefinitionName | where {$_.roleAssignmentId -eq $roleAssignment.roleAssignmentId}
Assert-Null $deletedRoleAssignment
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function Test-RdNegativeScenarios

# Throws on trying to delete a role that does not exist
$missingSubscription = "MissingSubscription: The request did not have a provided subscription. All requests must have an associated subscription Id."
Assert-Throws { Remove-AzureRmRoleDefinition -Id $rdId -Force} $missingSubscription
Assert-Throws { Remove-AzureRmRoleDefinition -Id $rdId -Force} $badIdException
}

<#
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.

Loading