Skip to content

Upstream #48

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 21 commits into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
13d9dda
Use V2 Storage accounts for RM based Diagnostics Extenstion
rahulpandit85 Oct 13, 2015
577ab59
Adding ruleState to dynamic data masking
yoavrubin Oct 14, 2015
7877f08
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
yoavrubin Oct 14, 2015
08ede14
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
yoavrubin Oct 14, 2015
3ac4aee
custom role fixes and bug fix
shuagarw Oct 15, 2015
2b38257
Merge branch 'dev' of github.com:Azure/azure-powershell into release-…
shuagarw Oct 15, 2015
6926479
Re-recorded some tests
shuagarw Oct 15, 2015
d5aaa37
role name filter and bug fixes
shuagarw Oct 15, 2015
cdba402
Audit cmdlets to read storage endoints from env
yoavrubin Oct 15, 2015
d0db0d9
Test fixes and re-recording
shuagarw Oct 15, 2015
de53b36
Re-record test
shuagarw Oct 16, 2015
6887eaa
Revert "Audit cmdlets to read storage endoints from env"
yoavrubin Oct 16, 2015
5baf503
Addressed review comments
shuagarw Oct 16, 2015
69044ea
Merge pull request #1119 from shuagarw/release-1.0.0-preview
amarzavery Oct 16, 2015
8f084e8
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
yoavrubin Oct 19, 2015
362f3da
Running tests after checkin
yoavrubin Oct 19, 2015
dc7ee26
Testing rule lifecycle after CI
yoavrubin Oct 19, 2015
4d2f8d7
Merge pull request #1116 from yoavrubin/dev
stankovski Oct 19, 2015
5c679fd
Use StorageUtilities to fetch Storage Account keys
rahulpandit85 Oct 19, 2015
93edfa5
Update Get-AllCommands.ps1
devigned Oct 19, 2015
8d44f81
Merge pull request #1112 from rahulpandit85/dev
ogail Oct 20, 2015
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 @@ -21,7 +21,8 @@
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.WindowsAzure.Commands.Common.Storage;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.WindowsAzure.Management.Storage;
using Microsoft.Azure.Commands.Management.Storage;
using Microsoft.Azure.Management.Storage;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.Compute
Expand All @@ -37,7 +38,7 @@ public class SetAzureVMDiagnosticsExtensionCommand : VirtualMachineExtensionBase
private const string VirtualMachineExtension = "Microsoft.Compute/virtualMachines/extensions";
private const string IaaSDiagnosticsExtension = "IaaSDiagnostics";
private const string ExtensionPublisher = "Microsoft.Azure.Diagnostics";
private StorageManagementClient storageClient;
private IStorageManagementClient storageClient;

[Parameter(
Mandatory = true,
Expand Down Expand Up @@ -154,14 +155,14 @@ public string PrivateConfiguration
}
}

public StorageManagementClient StorageClient
public IStorageManagementClient StorageClient
{
get
{
if (this.storageClient == null)
{
this.storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
DefaultProfile.Context, AzureEnvironment.Endpoint.ServiceManagement);
DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);
}

return this.storageClient;
Expand Down Expand Up @@ -201,15 +202,8 @@ protected string GetStorageKey()

if (!string.IsNullOrEmpty(StorageAccountName))
{
var storageAccount = this.StorageClient.StorageAccounts.Get(StorageAccountName);
if (storageAccount != null)
{
var keys = this.StorageClient.StorageAccounts.GetKeys(StorageAccountName);
if (keys != null)
{
storageKey = !string.IsNullOrEmpty(keys.PrimaryKey) ? keys.PrimaryKey : keys.SecondaryKey;
}
}
var storageCredentials = StorageUtilities.GenerateStorageCredentials(this.StorageClient, this.ResourceGroupName, this.StorageAccountName);
storageKey = storageCredentials.ExportBase64EncodedKey();
}

return storageKey;
Expand Down
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.

Loading