Skip to content

Commit

Permalink
Merge pull request #1 from Azure/preview
Browse files Browse the repository at this point in the history
Merging from preview pr branch
  • Loading branch information
athipp authored Sep 18, 2017
2 parents fd7ac47 + 0a0dd87 commit 4786d8f
Show file tree
Hide file tree
Showing 139 changed files with 114,152 additions and 4,496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public EffectiveNetworkSecurityGroup()
/// that is applied.</param>
/// <param name="effectiveSecurityRules">A collection of effective
/// security rules.</param>
public EffectiveNetworkSecurityGroup(SubResource networkSecurityGroup = default(SubResource), EffectiveNetworkSecurityGroupAssociation association = default(EffectiveNetworkSecurityGroupAssociation), IList<EffectiveNetworkSecurityRule> effectiveSecurityRules = default(IList<EffectiveNetworkSecurityRule>))
/// <param name="tagMap">Tag map.</param>
public EffectiveNetworkSecurityGroup(SubResource networkSecurityGroup = default(SubResource), EffectiveNetworkSecurityGroupAssociation association = default(EffectiveNetworkSecurityGroupAssociation), IList<EffectiveNetworkSecurityRule> effectiveSecurityRules = default(IList<EffectiveNetworkSecurityRule>), IDictionary<string, List<string>> tagMap = default(IDictionary<string, List<string>>))
{
NetworkSecurityGroup = networkSecurityGroup;
Association = association;
EffectiveSecurityRules = effectiveSecurityRules;
TagMap = tagMap;
CustomInit();
}

Expand All @@ -66,5 +68,10 @@ public EffectiveNetworkSecurityGroup()
[JsonProperty(PropertyName = "effectiveSecurityRules")]
public IList<EffectiveNetworkSecurityRule> EffectiveSecurityRules { get; set; }

/// <summary>
/// Gets or sets the tag map.
/// </summary>
[JsonProperty(PropertyName = "tagMap")]
public IDictionary<string, List<string>> TagMap { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Common/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ protected void LogQosEvent()

try
{
_metricHelper.SetPSHost(this.Host);
_metricHelper.LogQoSEvent(_qosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
_metricHelper.FlushMetric();
WriteDebug("Finish sending metric.");
Expand Down
33 changes: 32 additions & 1 deletion src/Common/Commands.Common/MetricHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Management.Automation.Host;
using System.Security.Cryptography;
using System.Text;

Expand All @@ -31,6 +32,8 @@ public class MetricHelper
{
protected INetworkHelper _networkHelper;
private const int FlushTimeoutInMilli = 5000;
private const string DefaultPSVersion = "3.0.0.0";
private const string EventName = "cmdletInvocation";

/// <summary>
/// The collection of telemetry clients.
Expand Down Expand Up @@ -58,6 +61,26 @@ public class MetricHelper

private AzurePSDataCollectionProfile _profile;

private static PSHost _host;

private static string _psVersion;

protected string PSVersion
{
get
{
if (_host != null)
{
_psVersion = _host.Version.ToString();
}
else
{
_psVersion = DefaultPSVersion;
}
return _psVersion;
}
}

public string HashMacAddress
{
get
Expand Down Expand Up @@ -171,7 +194,7 @@ private void LogUsageEvent(AzurePSQoSEvent qos)
{
var pageViewTelemetry = new PageViewTelemetry
{
Name = qos.CommandName ?? "empty",
Name = EventName,
Duration = qos.Duration,
Timestamp = qos.StartTime
};
Expand Down Expand Up @@ -217,13 +240,19 @@ private void LoadTelemetryClientContext(AzurePSQoSEvent qos, TelemetryContext cl
}
}

public void SetPSHost(PSHost host)
{
_host = host;
}

private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string, string> eventProperties)
{
if (qos == null)
{
return;
}

eventProperties.Add("Command", qos.CommandName);
eventProperties.Add("IsSuccess", qos.IsSuccess.ToString());
eventProperties.Add("ModuleName", qos.ModuleName);
eventProperties.Add("ModuleVersion", qos.ModuleVersion);
Expand All @@ -234,6 +263,8 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string,
eventProperties.Add("x-ms-client-request-id", qos.ClientRequestId);
eventProperties.Add("UserAgent", AzurePowerShell.UserAgentValue.ToString());
eventProperties.Add("HashMacAddress", HashMacAddress);
eventProperties.Add("PowerShellVersion", PSVersion);
eventProperties.Add("Version", AzurePowerShell.AssemblyVersion);
if (qos.InputFromPipeline != null)
{
eventProperties.Add("InputFromPipeline", qos.InputFromPipeline.Value.ToString());
Expand Down
22 changes: 22 additions & 0 deletions src/Common/Commands.Common/Utilities/GeneralUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,28 @@ public static void EnsureDefaultProfileDirectoryExists()
}
}

/// <summary>
/// Checks if collection has more than one element
/// </summary>
/// <typeparam name="T">Type of the collection.</typeparam>
/// <param name="collection">Collection.</param>
/// <returns></returns>
public static bool HasMoreThanOneElement<T>(ICollection<T> collection)
{
return collection != null && collection.Count > 1;
}

/// <summary>
/// Checks if collection has only one element
/// </summary>
/// <typeparam name="T">Type of the collection.</typeparam>
/// <param name="collection">Collection.</param>
/// <returns></returns>
public static bool HasSingleElement<T>(ICollection<T> collection)
{
return collection != null && collection.Count == 1;
}

/// <summary>
/// Clear the current storage account from the context - guarantees that only one storage account will be active
/// at a time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public EnvironmentSetupHelper()
TestExecutionHelpers.SetUpSessionAndProfile();
var datastore = new MemoryDataStore();
AzureSession.Instance.DataStore = datastore;
var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ARMProfileDirectory, AzureSession.Instance.ARMProfileFile));
var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ProfileDirectory, AzureSession.Instance.ProfileFile));
rmprofile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));
rmprofile.DefaultContext = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.EnvironmentTable["foo"], new AzureTenant());
rmprofile.DefaultContext.Subscription.SetEnvironment("foo");
Expand Down Expand Up @@ -135,6 +135,15 @@ public string RMStorageDataPlaneModule
}
}

public string RMNetworkModule
{
get
{
return Path.Combine(this.PackageDirectory,
@"ResourceManager\AzureResourceManager\AzureRM.Network\AzureRM.Network.psd1");
}
}

public string GetRMModulePath(string psd1FileName)
{
string basename = Path.GetFileNameWithoutExtension(psd1FileName);
Expand Down Expand Up @@ -256,12 +265,12 @@ private void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode)
private void SetAuthenticationFactory(AzureModule mode, TestEnvironment environment)
{
#if !NETSTANDARD
if(environment.AuthorizationContext.Certificate != null)
if (environment.AuthorizationContext.Certificate != null)
{
AzureSession.Instance.AuthenticationFactory = new MockCertificateAuthenticationFactory(environment.UserName,
environment.AuthorizationContext.Certificate);
}
else if(environment.AuthorizationContext.TokenCredentials.ContainsKey(TokenAudience.Management))
else if (environment.AuthorizationContext.TokenCredentials.ContainsKey(TokenAudience.Management))
{
var httpMessage = new HttpRequestMessage();
environment.AuthorizationContext.TokenCredentials[TokenAudience.Management]
Expand Down Expand Up @@ -430,4 +439,4 @@ private void SetupPowerShellModules(System.Management.Automation.PowerShell powe
}

}
}
}
3 changes: 2 additions & 1 deletion src/ResourceManager/Dns/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
- Additional information about change #1
-->
## Current Release

* Support for Private DNS Zones (Public Preview feature)
- Adds ability to create DNS Zones that are visible only within associated virtual networks
## Version 3.3.1

## Version 3.3.0
Expand Down
14 changes: 12 additions & 2 deletions src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.7.2-preview\lib\net45\Microsoft.Azure.Management.Dns.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.11.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -104,7 +108,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -328,6 +332,12 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateRegistrationVnet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateResolutionVnet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudTrimsDot.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
21 changes: 21 additions & 0 deletions src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ function Get-ResourceGroupName
return getAssetName
}

<#
.SYNOPSIS
Gets valid resource group name
#>
function Get-VirtualNetworkName
{
return getAssetName
}

<#
.SYNOPSIS
Gets valid resource name
Expand Down Expand Up @@ -71,6 +80,18 @@ function TestSetup-CreateResourceGroup
return $resourceGroup
}

<#
.SYNOPSIS
Creates a resource group to use in tests
#>
function TestSetup-CreateVirtualNetwork ($resourceGroup)
{
$virtualNetworkName = Get-VirtualNetworkName
$virtualNetwork = New-AzureRmVirtualNetwork -Name $virtualNetworkName -resourceGroupName $resourceGroup.ResourceGroupName -location "WestUS" -AddressPrefix "192.168.1.0/24"
return $virtualNetwork
}


function Get-RandomZoneName
{
$prefix = getAssetName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System.Collections.Generic;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Test.HttpRecorder;
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;

Expand All @@ -38,23 +39,19 @@ public class DnsTestsBase : RMTestBase
{
private LegacyTest.CSMTestEnvironmentFactory csmTestFactory;


private readonly EnvironmentSetupHelper helper;



public ResourceManagementClient ResourceManagementClient { get; private set; }

public SubscriptionClient SubscriptionClient { get; private set; }


public GalleryClient GalleryClient { get; private set; }


public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }


public DnsManagementClient DnsClient { get; private set; }

public NetworkManagementClient NetworkManagementClient { get; private set; }

public static DnsTestsBase NewInstance
{
Expand All @@ -64,28 +61,28 @@ public static DnsTestsBase NewInstance
}
}


protected DnsTestsBase()
{
this.helper = new EnvironmentSetupHelper();
}


protected void SetupManagementClients(MockContext context)
{
this.ResourceManagementClient = this.GetResourceManagementClient();
this.SubscriptionClient = this.GetSubscriptionClient();
this.GalleryClient = this.GetGalleryClient();
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
this.DnsClient = this.GetFeatureClient(context);
this.DnsClient = this.GetFeatureClient(context);
this.NetworkManagementClient = this.GetNetworkManagementClient(context);


this.helper.SetupManagementClients(
this.ResourceManagementClient,
this.SubscriptionClient,
this.GalleryClient,
this.AuthorizationManagementClient,
this.DnsClient);
this.DnsClient,
this.NetworkManagementClient);
}


Expand Down Expand Up @@ -133,12 +130,15 @@ public void RunPsTestWorkflow(
}


this.SetupManagementClients(context);

this.SetupManagementClients(context);

this.helper.SetupEnvironment(AzureModule.AzureResourceManager);






string callingClassName = callingClassType
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
.Last();
Expand All @@ -148,6 +148,7 @@ public void RunPsTestWorkflow(
helper.RMProfileModule,
helper.RMResourceModule,
helper.GetRMModulePath("AzureRM.Dns.psd1"),
helper.GetRMModulePath("AzureRM.Network.psd1"),
"AzureRM.Resources.ps1");

try
Expand Down Expand Up @@ -178,6 +179,12 @@ protected ResourceManagementClient GetResourceManagementClient()
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
}

protected NetworkManagementClient GetNetworkManagementClient(MockContext context)
{
return context.GetServiceClient<NetworkManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}


private AuthorizationManagementClient GetAuthorizationManagementClient()
{
return LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public void TestZoneCrud()
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestZoneCrudPrivateResolutionVnet()
{
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateResolutionVnet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestZoneCrudPrivateRegistrationVnet()
{
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateRegistrationVnet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestZoneCrudTrimsDot()
Expand Down
Loading

0 comments on commit 4786d8f

Please sign in to comment.