Skip to content

Commit 1167845

Browse files
authored
Merge branch 'preview' into darshanhs90/adapplnissue
2 parents 277f57f + 69e474b commit 1167845

File tree

128 files changed

+20990
-50922
lines changed

Some content is hidden

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

128 files changed

+20990
-50922
lines changed

src/Common/Commands.Common/DataCollectionController.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,32 @@ public abstract class DataCollectionController
2626

2727
static AzurePSDataCollectionProfile Initialize(IAzureSession session)
2828
{
29-
AzurePSDataCollectionProfile result = new AzurePSDataCollectionProfile();
29+
AzurePSDataCollectionProfile result = new AzurePSDataCollectionProfile(true);
3030
try
3131
{
32-
var store = session.DataStore;
33-
string dataPath = Path.Combine(session.ProfileDirectory, AzurePSDataCollectionProfile.DefaultFileName);
34-
if (store.FileExists(dataPath))
32+
var environmentValue = Environment.GetEnvironmentVariable(AzurePSDataCollectionProfile.EnvironmentVariableName);
33+
bool enabled = true;
34+
if (!string.IsNullOrWhiteSpace(environmentValue) && bool.TryParse(environmentValue, out enabled))
3535
{
36-
string contents = store.ReadFileAsText(dataPath);
37-
var localResult = JsonConvert.DeserializeObject<AzurePSDataCollectionProfile>(contents);
38-
if (localResult != null && localResult.EnableAzureDataCollection.HasValue)
39-
{
40-
result = localResult;
41-
}
36+
result.EnableAzureDataCollection = enabled;
4237
}
4338
else
4439
{
45-
WritePSDataCollectionProfile(session, new AzurePSDataCollectionProfile(true));
40+
var store = session.DataStore;
41+
string dataPath = Path.Combine(session.ProfileDirectory, AzurePSDataCollectionProfile.DefaultFileName);
42+
if (store.FileExists(dataPath))
43+
{
44+
string contents = store.ReadFileAsText(dataPath);
45+
var localResult = JsonConvert.DeserializeObject<AzurePSDataCollectionProfile>(contents);
46+
if (localResult != null && localResult.EnableAzureDataCollection.HasValue)
47+
{
48+
result = localResult;
49+
}
50+
}
51+
else
52+
{
53+
WritePSDataCollectionProfile(session, new AzurePSDataCollectionProfile(true));
54+
}
4655
}
4756
}
4857
catch

src/ResourceManager/Common/Commands.Common.Authentication.ResourceManager/AzureRmProfile.cs

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -356,55 +356,57 @@ public bool TryFindContext(IAzureContext context, out string name)
356356
{
357357
bool result = false;
358358
name = null;
359-
var foundContext = Contexts.FirstOrDefault((c) =>
360-
c.Value != null
361-
&& (
362-
(c.Value.Account != null && context.Account != null && string.Equals(c.Value.Account.Id, context.Account.Id, StringComparison.OrdinalIgnoreCase))
363-
|| (c.Value.Account == context.Account))
364-
&& (
365-
(c.Value.Tenant != null && context.Tenant != null && c.Value.Tenant.GetId() == context.Tenant.GetId())
366-
|| (c.Value.Tenant == context.Tenant))
367-
&& (
368-
(c.Value.Subscription != null && context.Subscription != null && c.Value.Subscription.GetId() == context.Subscription.GetId())
369-
|| (c.Value.Subscription == context.Subscription)));
370-
if (!string.IsNullOrEmpty(foundContext.Key))
371-
{
372-
name = foundContext.Key;
373-
result = true;
359+
if (context != null)
360+
{
361+
var foundContext = Contexts.FirstOrDefault((c) =>
362+
c.Value != null
363+
&& (
364+
(c.Value.Account != null && context.Account != null && string.Equals(c.Value.Account.Id, context.Account.Id, StringComparison.OrdinalIgnoreCase))
365+
|| (c.Value.Account == context.Account))
366+
&& (
367+
(c.Value.Tenant != null && context.Tenant != null && c.Value.Tenant.GetId() == context.Tenant.GetId())
368+
|| (c.Value.Tenant == context.Tenant))
369+
&& (
370+
(c.Value.Subscription != null && context.Subscription != null && c.Value.Subscription.GetId() == context.Subscription.GetId())
371+
|| (c.Value.Subscription == context.Subscription)));
372+
if (!string.IsNullOrEmpty(foundContext.Key))
373+
{
374+
name = foundContext.Key;
375+
result = true;
376+
}
374377
}
375378

376379
return result;
377380
}
378381

379382
public bool TryGetContextName(IAzureContext context, out string name)
380383
{
381-
if (context == null)
382-
{
383-
throw new ArgumentNullException(nameof(context));
384-
}
385-
386384
bool result = false;
387385
name = null;
388-
if ((context.Account != null && !string.IsNullOrWhiteSpace(context.Account.Id)) || context.Subscription != null)
386+
if (context != null)
389387
{
390-
List<string> components = new List<string>();
391-
if (context.Account != null && !string.IsNullOrWhiteSpace(context.Account.Id))
388+
389+
if ((context.Account != null && !string.IsNullOrWhiteSpace(context.Account.Id)) || context.Subscription != null)
392390
{
393-
components.Add(context.Account.Id);
391+
List<string> components = new List<string>();
392+
if (context.Account != null && !string.IsNullOrWhiteSpace(context.Account.Id))
393+
{
394+
components.Add(context.Account.Id);
395+
}
396+
397+
if (context.Subscription != null)
398+
{
399+
components.Add(context.Subscription.GetId().ToString());
400+
}
401+
402+
name = string.Format("[{0}]", string.Join(", ", components));
403+
result = true;
394404
}
395-
396-
if (context.Subscription != null)
405+
else
397406
{
398-
components.Add(context.Subscription.GetId().ToString());
407+
name = "Default";
408+
result = true;
399409
}
400-
401-
name = string.Format("[{0}]", string.Join(", ", components));
402-
result = true;
403-
}
404-
else
405-
{
406-
name = "Default";
407-
result = true;
408410
}
409411

410412
return result;
@@ -478,7 +480,8 @@ public bool TrySetDefaultContext(IAzureContext context)
478480
{
479481
bool result = false;
480482
string contextName;
481-
if (TryFindContext(context, out contextName) || TryAddContext(context, out contextName))
483+
484+
if (context != null && (TryFindContext(context, out contextName) || TryAddContext(context, out contextName)))
482485
{
483486
result = TrySetDefaultContext(contextName);
484487
}
@@ -489,13 +492,16 @@ public bool TrySetDefaultContext(IAzureContext context)
489492
public bool TrySetDefaultContext(string name, IAzureContext context)
490493
{
491494
bool result = false;
492-
if (string.IsNullOrWhiteSpace(name))
495+
if (context != null)
493496
{
494-
result = TrySetDefaultContext(context);
495-
}
496-
else if (TrySetContext(name, context))
497-
{
498-
result = TrySetDefaultContext(name);
497+
if (string.IsNullOrWhiteSpace(name))
498+
{
499+
result = TrySetDefaultContext(context);
500+
}
501+
else if (TrySetContext(name, context))
502+
{
503+
result = TrySetDefaultContext(name);
504+
}
499505
}
500506

501507
return result;
@@ -562,6 +568,11 @@ public bool TryCopyProfile(AzureRmProfile other)
562568
TrySetContext(context.Key, context.Value);
563569
}
564570

571+
if (other.DefaultContext != null)
572+
{
573+
this.TrySetDefaultContext(other.DefaultContext);
574+
}
575+
565576
this.CopyPropertiesFrom(other);
566577
return true;
567578
}

src/ResourceManager/Dns/ChangeLog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21-
* Support for Private DNS Zones (Public Preview feature)
22-
- Adds ability to create DNS Zones that are visible only within associated virtual networks
21+
2322
## Version 3.3.1
2423

2524
## Version 3.3.0

src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6565
<SpecificVersion>False</SpecificVersion>
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.11.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
67-
<Private>True</Private>
68-
</Reference>
69-
<Reference Include="Microsoft.Azure.Management.Network, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.7.2-preview\lib\net45\Microsoft.Azure.Management.Dns.dll</HintPath>
7167
<Private>True</Private>
7268
</Reference>
7369
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -108,7 +104,7 @@
108104
<Private>True</Private>
109105
</Reference>
110106
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
111-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.2\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
107+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
112108
<Private>True</Private>
113109
</Reference>
114110
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -332,12 +328,6 @@
332328
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
333329
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
334330
</None>
335-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateRegistrationVnet.json">
336-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
337-
</None>
338-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudPrivateResolutionVnet.json">
339-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
340-
</None>
341331
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudTrimsDot.json">
342332
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
343333
</None>

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/Common.ps1

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ function Get-ResourceGroupName
2121
return getAssetName
2222
}
2323

24-
<#
25-
.SYNOPSIS
26-
Gets valid resource group name
27-
#>
28-
function Get-VirtualNetworkName
29-
{
30-
return getAssetName
31-
}
32-
3324
<#
3425
.SYNOPSIS
3526
Gets valid resource name
@@ -80,18 +71,6 @@ function TestSetup-CreateResourceGroup
8071
return $resourceGroup
8172
}
8273

83-
<#
84-
.SYNOPSIS
85-
Creates a resource group to use in tests
86-
#>
87-
function TestSetup-CreateVirtualNetwork ($resourceGroup)
88-
{
89-
$virtualNetworkName = Get-VirtualNetworkName
90-
$virtualNetwork = New-AzureRmVirtualNetwork -Name $virtualNetworkName -resourceGroupName $resourceGroup.ResourceGroupName -location "WestUS" -AddressPrefix "192.168.1.0/24"
91-
return $virtualNetwork
92-
}
93-
94-
9574
function Get-RandomZoneName
9675
{
9776
$prefix = getAssetName;

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/DnsTestsBase.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System.Collections.Generic;
1616
using Microsoft.Azure.Commands.Common.Authentication;
17-
using Microsoft.Azure.Management.Network;
1817
using Microsoft.Azure.Test.HttpRecorder;
1918
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2019

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

41+
4242
private readonly EnvironmentSetupHelper helper;
43-
43+
44+
4445
public ResourceManagementClient ResourceManagementClient { get; private set; }
4546

4647
public SubscriptionClient SubscriptionClient { get; private set; }
4748

49+
4850
public GalleryClient GalleryClient { get; private set; }
4951

52+
5053
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
5154

55+
5256
public DnsManagementClient DnsClient { get; private set; }
5357

54-
public NetworkManagementClient NetworkManagementClient { get; private set; }
5558

5659
public static DnsTestsBase NewInstance
5760
{
@@ -61,28 +64,28 @@ public static DnsTestsBase NewInstance
6164
}
6265
}
6366

67+
6468
protected DnsTestsBase()
6569
{
6670
this.helper = new EnvironmentSetupHelper();
6771
}
6872

73+
6974
protected void SetupManagementClients(MockContext context)
7075
{
7176
this.ResourceManagementClient = this.GetResourceManagementClient();
7277
this.SubscriptionClient = this.GetSubscriptionClient();
7378
this.GalleryClient = this.GetGalleryClient();
7479
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
75-
this.DnsClient = this.GetFeatureClient(context);
76-
this.NetworkManagementClient = this.GetNetworkManagementClient(context);
80+
this.DnsClient = this.GetFeatureClient(context);
7781

7882

7983
this.helper.SetupManagementClients(
8084
this.ResourceManagementClient,
8185
this.SubscriptionClient,
8286
this.GalleryClient,
8387
this.AuthorizationManagementClient,
84-
this.DnsClient,
85-
this.NetworkManagementClient);
88+
this.DnsClient);
8689
}
8790

8891

@@ -130,13 +133,10 @@ public void RunPsTestWorkflow(
130133
}
131134

132135

133-
this.SetupManagementClients(context);
134-
135-
this.helper.SetupEnvironment(AzureModule.AzureResourceManager);
136-
137-
136+
this.SetupManagementClients(context);
138137

139138

139+
this.helper.SetupEnvironment(AzureModule.AzureResourceManager);
140140

141141

142142
string callingClassName = callingClassType
@@ -148,7 +148,6 @@ public void RunPsTestWorkflow(
148148
helper.RMProfileModule,
149149
helper.RMResourceModule,
150150
helper.GetRMModulePath("AzureRM.Dns.psd1"),
151-
helper.GetRMModulePath("AzureRM.Network.psd1"),
152151
"AzureRM.Resources.ps1");
153152

154153
try
@@ -179,12 +178,6 @@ protected ResourceManagementClient GetResourceManagementClient()
179178
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
180179
}
181180

182-
protected NetworkManagementClient GetNetworkManagementClient(MockContext context)
183-
{
184-
return context.GetServiceClient<NetworkManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
185-
}
186-
187-
188181
private AuthorizationManagementClient GetAuthorizationManagementClient()
189182
{
190183
return LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ public void TestZoneCrud()
3131
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrud");
3232
}
3333

34-
[Fact]
35-
[Trait(Category.AcceptanceType, Category.CheckIn)]
36-
public void TestZoneCrudPrivateResolutionVnet()
37-
{
38-
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateResolutionVnet");
39-
}
40-
41-
[Fact]
42-
[Trait(Category.AcceptanceType, Category.CheckIn)]
43-
public void TestZoneCrudPrivateRegistrationVnet()
44-
{
45-
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneCrudPrivateRegistrationVnet");
46-
}
47-
4834
[Fact]
4935
[Trait(Category.AcceptanceType, Category.CheckIn)]
5036
public void TestZoneCrudTrimsDot()

0 commit comments

Comments
 (0)