Skip to content

Commit 73ebe3a

Browse files
committed
Merge pull request #48 from Azure/dev
Upstream
2 parents 4ed2091 + 8d44f81 commit 73ebe3a

File tree

50 files changed

+15114
-7719
lines changed

Some content is hidden

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

50 files changed

+15114
-7719
lines changed

src/ResourceManager/Compute/Commands.Compute/Extension/Diagnostics/SetAzureVMDiagnosticsExtension.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
using Microsoft.Azure.Management.Compute.Models;
2222
using Microsoft.WindowsAzure.Commands.Common.Storage;
2323
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24-
using Microsoft.WindowsAzure.Management.Storage;
24+
using Microsoft.Azure.Commands.Management.Storage;
25+
using Microsoft.Azure.Management.Storage;
2526
using Newtonsoft.Json;
2627

2728
namespace Microsoft.Azure.Commands.Compute
@@ -37,7 +38,7 @@ public class SetAzureVMDiagnosticsExtensionCommand : VirtualMachineExtensionBase
3738
private const string VirtualMachineExtension = "Microsoft.Compute/virtualMachines/extensions";
3839
private const string IaaSDiagnosticsExtension = "IaaSDiagnostics";
3940
private const string ExtensionPublisher = "Microsoft.Azure.Diagnostics";
40-
private StorageManagementClient storageClient;
41+
private IStorageManagementClient storageClient;
4142

4243
[Parameter(
4344
Mandatory = true,
@@ -154,14 +155,14 @@ public string PrivateConfiguration
154155
}
155156
}
156157

157-
public StorageManagementClient StorageClient
158+
public IStorageManagementClient StorageClient
158159
{
159160
get
160161
{
161162
if (this.storageClient == null)
162163
{
163164
this.storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
164-
DefaultProfile.Context, AzureEnvironment.Endpoint.ServiceManagement);
165+
DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);
165166
}
166167

167168
return this.storageClient;
@@ -201,15 +202,8 @@ protected string GetStorageKey()
201202

202203
if (!string.IsNullOrEmpty(StorageAccountName))
203204
{
204-
var storageAccount = this.StorageClient.StorageAccounts.Get(StorageAccountName);
205-
if (storageAccount != null)
206-
{
207-
var keys = this.StorageClient.StorageAccounts.GetKeys(StorageAccountName);
208-
if (keys != null)
209-
{
210-
storageKey = !string.IsNullOrEmpty(keys.PrimaryKey) ? keys.PrimaryKey : keys.SecondaryKey;
211-
}
212-
}
205+
var storageCredentials = StorageUtilities.GenerateStorageCredentials(this.StorageClient, this.ResourceGroupName, this.StorageAccountName);
206+
storageKey = storageCredentials.ExportBase64EncodedKey();
213207
}
214208

215209
return storageKey;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
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.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
74+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.1\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>
78-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
78+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.11-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
7979
</Reference>
8080
<Reference Include="Microsoft.Azure.Test.Framework">
8181
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5715.36130-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>

src/ResourceManager/Resources/Commands.Resources.Test/Resources/RoleDefinition.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Name": "Another tests role",
3-
"Id": "/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/providers/Microsoft.Authorization/roleDefinitions/85E460B3-89E9-48BA-9DCD-A8A99D64A674",
3+
"Id": "85E460B3-89E9-48BA-9DCD-A8A99D64A674",
44
"Description": "Test role",
55
"Actions": [
66
"Microsoft.Authorization/*/read",

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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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(Skip = "tenantID NullException")]
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: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ 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
26-
[Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient]::RoleAssignmentNames.Enqueue("8D7DD69E-9AE2-44A1-94D8-F7BC8E12645E")
2726
$classic = Get-AzureRmRoleAssignment -IncludeClassicAdministrators | Where-Object { $_.Scope -ieq ('/subscriptions/' + $subscription.SubscriptionId) -and $_.RoleDefinitionName.ToLower().Contains('administrator')}
2827

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

43-
$subscription = Get-AzureRmSubscription -Current
42+
$subscription = Get-AzureRmSubscription
4443

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

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

5553
# Bad SPN
5654
$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
55+
Assert-Throws { Get-AzureRmRoleAssignment -ServicePrincipalName $badSpn } $badObjectResult
5956

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

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

151148
# Test
@@ -179,7 +176,7 @@ function Test-RaByServicePrincipal
179176

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

@@ -310,6 +307,6 @@ function VerifyRoleAssignmentDeleted
310307

311308
$deletedRoleAssignment = Get-AzureRmRoleAssignment -ObjectId $roleAssignment.ObjectId.Guid `
312309
-Scope $roleAssignment.Scope `
313-
-RoleDefinitionName $roleAssignment.RoleDefinitionName
310+
-RoleDefinitionName $roleAssignment.RoleDefinitionName | where {$_.roleAssignmentId -eq $roleAssignment.roleAssignmentId}
314311
Assert-Null $deletedRoleAssignment
315312
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function Test-RdNegativeScenarios
9494

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

100100
<#

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ProviderTests/TestAzureProvider.json

Lines changed: 292 additions & 89 deletions
Large diffs are not rendered by default.

src/ResourceManager/Resources/Commands.Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ProviderTests/TestAzureProviderOperation.json

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

0 commit comments

Comments
 (0)