Skip to content

Commit a53e29c

Browse files
authored
Merge pull request #3 from Azure/master
Sync
2 parents 922c592 + e2f6357 commit a53e29c

File tree

58 files changed

+8360
-1105
lines changed

Some content is hidden

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

58 files changed

+8360
-1105
lines changed

src/Accounts/Authentication.ResourceManager/Common/PSObjectExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static bool HasProperty(this PSObject source, string name)
4848
/// </summary>
4949
/// <typeparam name="T">The type of the property to look for</typeparam>
5050
/// <param name="source">The PSObject to check</param>
51-
/// <param name="name">The name of the proeprty to look for</param>
51+
/// <param name="name">The name of the property to look for</param>
5252
/// <returns>true if the PSObject has a property with the given name, otherwise false</returns>
5353
public static bool HasProperty<T>(this PSObject source, string name)
5454
{
@@ -211,7 +211,7 @@ public static void Populate(this IDictionary<string, string> dictionary, string
211211
/// Populate a list from a proprty of the given PSObject
212212
/// </summary>
213213
/// <param name="list">The list to populate</param>
214-
/// <param name="name">The name of the proeprty contiaing the list</param>
214+
/// <param name="name">The name of the property contiaing the list</param>
215215
/// <param name="other">The PSObject to populate the list from</param>
216216
public static void Populate(this IList<string> list, string name, PSObject other)
217217
{

src/Accounts/Authentication.ResourceManager/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Authentication.Test/PSSerializationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ IAzureContext GetDefaultContext()
251251
VersionProfile = "2017_09_25"
252252
};
253253

254-
context.SetProperty("ContextProeprty1", "ContextProperty1Value1", "ContextProperty1Value2");
255-
context.SetProperty("ContextProeprty2", "ContextProperty2Value1", "ContextProperty2Value2");
254+
context.SetProperty("ContextProperty1", "ContextProperty1Value1", "ContextProperty1Value2");
255+
context.SetProperty("ContextProperty2", "ContextProperty2Value1", "ContextProperty2Value2");
256256

257257
return context;
258258
}

src/Accounts/Authentication/Properties/Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compute/Compute.Test/ScenarioTests/VirtualMachinePatchTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,14 @@ public void TestInvokeAzVmPatchAssessment()
1717
{
1818
TestRunner.RunTestScript("Test-InvokeAzVmPatchAssessment");
1919
}
20+
21+
[Fact]
22+
[Trait(Category.AcceptanceType, Category.CheckIn)]
23+
public void TestPatchStatusGetAzVMinstanceview()
24+
{
25+
TestRunner.RunTestScript("Test-PatchStatusGetAzVMinstanceview");
26+
}
27+
28+
2029
}
2130
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachinePatchTests.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,47 @@ function Test-InvokeAzVmPatchAssessment
7373
# Cleanup
7474
Clean-ResourceGroup $rgname
7575
}
76+
}
77+
78+
79+
<#
80+
.SYNOPSIS
81+
Test PatchStatus in Get-Azvm instance view
82+
#>
83+
function Test-PatchStatusGetAzVMinstanceview
84+
{
85+
# Setup
86+
$rgname = Get-ComputeTestResourceName
87+
88+
try
89+
{
90+
# Common
91+
$loc = Get-ComputeVMLocation;
92+
$loc = $loc.Replace(' ', '');
93+
94+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
95+
96+
# VM Profile & Hardware
97+
$vmsize = Get-AvailableSku $loc "virtualMachine"
98+
$vmname = 'vm' + $rgname;
99+
100+
$username = "admin01"
101+
$password = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force
102+
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
103+
[string]$domainNameLabel = "$vmname-$vmname".tolower();
104+
105+
$x = New-AzVM -ResourceGroupName $rgname -Name $vmname -Location $loc -Credential $cred -DomainNameLabel $domainNameLabel
106+
$patchResult = invoke-azvmpatchAssessment -resourcegroupname $rgname -vmname $vmname
107+
108+
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname -Status;
109+
110+
Assert-NotNull $vm.PatchStatus;
111+
Assert-NotNull $vm.PatchStatus.availablePatchSummary;
112+
Assert-AreEqual "Succeeded" $vm.PatchStatus.availablePatchSummary.status;
113+
}
114+
finally
115+
{
116+
# Cleanup
117+
Clean-ResourceGroup $rgname
118+
}
76119
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachinePatchTests/TestPatchStatusGetAzVMinstanceview.json

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

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Additional information about change #1
2020
-->
2121
## Upcoming Release
22+
* Added 'PatchStatus'Property to VirtualMachine Instance View
2223
* Added ``VMHealth`` property to the virtual machine's instance view, which is the returned object when ``Get-AzVm`` is invoked with ``-Status``
2324
* Added 'AssignedHost' field to Get-AzVM and Get-AzVmss's instance views. The field shows the resource id of the virtual machine instance
2425
* Added `SupportAutomaticPlacement` to New-AzHostGroup

src/Compute/Compute/Generated/Models/PSVirtualMachineInstanceView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public partial class PSVirtualMachineInstanceView
4141
public IList<VirtualMachineExtensionInstanceView> Extensions { get; set; }
4242
public BootDiagnosticsInstanceView BootDiagnostics { get; set; }
4343
public IList<InstanceViewStatus> Statuses { get; set; }
44+
public VirtualMachinePatchStatus PatchStatus { get; set; }
4445
public VirtualMachineHealthStatus VmHealth { get; set; }
4546

4647
}

src/Compute/Compute/Models/PSVirtualMachineInstanceView.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class PSVirtualMachineInstanceView
4545
public IList<InstanceViewStatus> Statuses { get; set; }
4646

4747
public MaintenanceRedeployStatus MaintenanceRedeployStatus { get; set; }
48+
public VirtualMachinePatchStatus PatchStatus { get; set; }
4849
public VirtualMachineHealthStatus VMHealth { get; set; }
4950
}
5051

@@ -72,6 +73,7 @@ public static PSVirtualMachineInstanceView ToPSVirtualMachineInstanceView(
7273
OsName = virtualMachineInstanceView.OsName,
7374
OsVersion = virtualMachineInstanceView.OsVersion,
7475
HyperVGeneration = virtualMachineInstanceView.HyperVGeneration,
76+
PatchStatus = virtualMachineInstanceView.PatchStatus,
7577
VMHealth = virtualMachineInstanceView.VmHealth,
7678
AssignedHost = virtualMachineInstanceView.AssignedHost
7779
};

src/KeyVault/KeyVault.Test/ScenarioTests/KeyVaultManagementTests.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public void TestDeleteVault()
147147
public void TestSetRemoveAccessPolicyByObjectId()
148148
{
149149
string upn = "";
150-
_data.ResetPreCreatedVault();
151150

152151
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
153152
controller.RunPsTestWorkflow(
@@ -168,7 +167,6 @@ public void TestSetRemoveAccessPolicyByObjectId()
168167
public void TestSetRemoveAccessPolicyByUPN()
169168
{
170169
string upn = "";
171-
_data.ResetPreCreatedVault();
172170
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
173171
_logger,
174172
() =>
@@ -187,7 +185,6 @@ public void TestSetRemoveAccessPolicyByCompoundId()
187185
{
188186
string upn = "";
189187
Guid? appId = null;
190-
_data.ResetPreCreatedVault();
191188

192189
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
193190
controller.RunPsTestWorkflow(
@@ -211,7 +208,6 @@ public void TestRemoveAccessPolicyWithCompoundIdPolicies()
211208

212209
Guid? appId1 = null;
213210
Guid? appId2 = null;
214-
_data.ResetPreCreatedVault();
215211

216212
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
217213
controller.RunPsTestWorkflow(
@@ -233,7 +229,6 @@ public void TestSetCompoundIdAccessPolicy()
233229
{
234230
string upn = "";
235231
Guid? appId = null;
236-
_data.ResetPreCreatedVault();
237232

238233
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
239234
controller.RunPsTestWorkflow(
@@ -257,7 +252,6 @@ public void TestSetRemoveAccessPolicyBySPN()
257252
ServicePrincipal principal = null;
258253

259254
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
260-
_data.ResetPreCreatedVault();
261255
controller.RunPsTestWorkflow(
262256
_logger,
263257
//script builder
@@ -288,7 +282,6 @@ public void TestModifyAccessPolicy()
288282
string upn = "";
289283

290284
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
291-
_data.ResetPreCreatedVault();
292285

293286
controller.RunPsTestWorkflow(
294287
_logger,
@@ -310,7 +303,6 @@ public void TestModifyAccessPolicyEnabledForDeployment()
310303
{
311304
string upn = "";
312305

313-
_data.ResetPreCreatedVault();
314306
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
315307
_logger,
316308
() =>
@@ -330,7 +322,6 @@ public void TestModifyAccessPolicyEnabledForTemplateDeployment()
330322
{
331323
string upn = "";
332324

333-
_data.ResetPreCreatedVault();
334325
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
335326
_logger,
336327
() =>
@@ -349,7 +340,6 @@ public void TestModifyAccessPolicyEnabledForDiskEncryption()
349340
{
350341
string upn = "";
351342

352-
_data.ResetPreCreatedVault();
353343
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
354344
_logger,
355345
() =>
@@ -367,14 +357,11 @@ public void TestModifyAccessPolicyEnabledForDiskEncryption()
367357
[Trait(Category.AcceptanceType, Category.CheckIn)]
368358
public void TestModifyAccessPolicyNegativeCases()
369359
{
370-
string upn = "";
371-
372-
_data.ResetPreCreatedVault();
373360
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
374361
_logger,
375362
() =>
376363
{
377-
return new[] { string.Format("{0} {1} {2} {3}", "Test-ModifyAccessPolicyNegativeCases", _data.PreCreatedVault, _data.ResourceGroupName, upn) };
364+
return new[] { "Test-ModifyAccessPolicyNegativeCases" };
378365
},
379366
null,
380367
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
@@ -387,7 +374,6 @@ public void TestModifyAccessPolicyNegativeCases()
387374
public void TestRemoveNonExistentAccessPolicyDoesNotThrow()
388375
{
389376
string upn = "";
390-
_data.ResetPreCreatedVault();
391377

392378
KeyVaultManagementController controller = KeyVaultManagementController.NewInstance;
393379
controller.RunPsTestWorkflow(

src/KeyVault/KeyVault.Test/ScenarioTests/KeyVaultTestFixture.cs

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -12,144 +12,32 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.KeyVault;
16-
using Microsoft.Azure.Management.KeyVault.Models;
17-
using Microsoft.Azure.Test.HttpRecorder;
18-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
1915
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
2016
using System;
21-
using System.Collections.Generic;
22-
using System.Diagnostics;
23-
using System.Linq;
24-
using Microsoft.Azure.Management.Internal.Resources;
25-
using Microsoft.Azure.Management.Internal.Resources.Models;
26-
using Sku = Microsoft.Azure.Management.KeyVault.Models.Sku;
2717

2818
namespace Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests
2919
{
3020
public class KeyVaultTestFixture : RMTestBase, IDisposable
3121
{
32-
private readonly HttpRecorderMode _mode;
33-
3422
public string TagName { get; set; } = "testtag";
3523
public string TagValue { get; set; } = "testvalue";
3624

3725
public string ResourceGroupName { get; set; }
3826
public string Location { get; set; }
3927
public string PreCreatedVault { get; set; }
4028

41-
private bool _initialized;
4229
public KeyVaultTestFixture()
4330
{
44-
// Initialize has bug which causes null reference exception
45-
HttpMockServer.FileSystemUtilsObject = new FileSystemUtils();
46-
_mode = HttpMockServer.GetCurrentMode();
4731
}
4832

4933
public void Initialize(string className)
5034
{
51-
if (_initialized)
52-
return;
53-
54-
if (_mode == HttpRecorderMode.Record)
55-
{
56-
using (MockContext context = MockContext.Start(new StackTrace().GetFrame(1).GetMethod().ReflectedType?.ToString(), new StackTrace().GetFrame(1).GetMethod().Name))
57-
{
58-
var resourcesClient = context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
59-
var mgmtClient = context.GetServiceClient<KeyVaultManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
60-
var tenantId = TestEnvironmentFactory.GetTestEnvironment().Tenant;
61-
62-
//Figure out which locations are available for Key Vault
63-
Location = GetKeyVaultLocation(resourcesClient);
64-
65-
//Create a resource group in that location
66-
PreCreatedVault = TestUtilities.GenerateName("pshtestvault");
67-
ResourceGroupName = TestUtilities.GenerateName("pshtestrg");
68-
69-
resourcesClient.ResourceGroups.CreateOrUpdate(ResourceGroupName, new ResourceGroup { Location = Location });
70-
CreateVault(mgmtClient, Location, tenantId);
71-
}
72-
}
73-
74-
_initialized = true;
75-
}
76-
77-
private static string GetKeyVaultLocation(ResourceManagementClient resourcesClient)
78-
{
79-
var provider = resourcesClient.Providers.Get("Microsoft.KeyVault");
80-
var location = provider.ResourceTypes.First(resType => resType.ResourceType.Contains("vaults")).Locations.FirstOrDefault();
81-
return location?.ToLowerInvariant().Replace(" ", "");
35+
// no op
8236
}
8337

84-
private void CreateVault(KeyVaultManagementClient mgmtClient, string location, string tenantId)
85-
{
86-
mgmtClient.Vaults.CreateOrUpdate(
87-
ResourceGroupName,
88-
PreCreatedVault,
89-
new VaultCreateOrUpdateParameters
90-
{
91-
Location = location,
92-
Tags = new Dictionary<string, string> { { TagName, TagValue } },
93-
Properties = new VaultProperties
94-
{
95-
EnabledForDeployment = false,
96-
Sku = new Sku { Name = SkuName.Premium },
97-
TenantId = Guid.Parse(tenantId),
98-
VaultUri = "",
99-
AccessPolicies = new AccessPolicyEntry[]{ }
100-
}
101-
});
102-
}
103-
104-
public void ResetPreCreatedVault()
105-
{
106-
if (_mode == HttpRecorderMode.Record)
107-
{
108-
using (MockContext context = MockContext.Start(new StackTrace().GetFrame(1).GetMethod().ReflectedType?.ToString(), new StackTrace().GetFrame(1).GetMethod().Name))
109-
{
110-
var mgmtClient = context.GetServiceClient<KeyVaultManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
111-
var tenantId = Guid.Parse(TestEnvironmentFactory.GetTestEnvironment().Tenant);
112-
113-
var policies = new AccessPolicyEntry[] { };
114-
115-
mgmtClient.Vaults.CreateOrUpdate(
116-
ResourceGroupName,
117-
PreCreatedVault,
118-
new VaultCreateOrUpdateParameters
119-
{
120-
Location = Location,
121-
Tags = new Dictionary<string, string> { { TagName, TagValue } },
122-
Properties = new VaultProperties
123-
{
124-
EnabledForDeployment = false,
125-
Sku = new Sku { Name = SkuName.Premium },
126-
TenantId = tenantId,
127-
VaultUri = "",
128-
AccessPolicies = policies
129-
}
130-
});
131-
}
132-
}
133-
}
13438
public void Dispose()
13539
{
136-
Dispose(false);
13740
GC.SuppressFinalize(this);
13841
}
139-
140-
protected virtual void Dispose(bool disposing)
141-
{
142-
if (disposing)
143-
{
144-
if (_mode == HttpRecorderMode.Record && _initialized)
145-
{
146-
using (MockContext context = MockContext.Start(new StackTrace().GetFrame(1).GetMethod().ReflectedType?.ToString(), new StackTrace().GetFrame(1).GetMethod().Name))
147-
{
148-
var resourcesClient = context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
149-
resourcesClient.ResourceGroups.Delete(ResourceGroupName);
150-
}
151-
}
152-
}
153-
}
15442
}
15543
}

0 commit comments

Comments
 (0)