Skip to content

Commit 403afca

Browse files
author
Hovsep Mkrtchyan
committed
Fixing failing tests and updating reference to Common.Authentication's latest nuget package.
1 parent d6c70cf commit 403afca

File tree

124 files changed

+202
-169
lines changed

Some content is hidden

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

124 files changed

+202
-169
lines changed

src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</Reference>
5959
<Reference Include="Microsoft.Azure.Common.Authentication">
6060
<SpecificVersion>False</SpecificVersion>
61-
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
61+
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
6262
</Reference>
6363
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6464
<SpecificVersion>False</SpecificVersion>

src/Common/Commands.Common.Storage/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Hyak.Common" version="1.0.1" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.0.1" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
6-
<package id="Microsoft.Azure.Common.Authentication" version="1.0.2-preview" targetFramework="net45" />
6+
<package id="Microsoft.Azure.Common.Authentication" version="1.0.4-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Resources" version="2.12.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
99
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

src/Common/Commands.Common.Test/Commands.Common.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.Common.Authentication">
5858
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
59+
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Common.NetFramework">
6262
<HintPath>..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>

src/Common/Commands.Common.Test/Common/ProfileCmdltsTests.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void ClearAzureProfileClearsDefaultProfile()
5353
{
5454
ClearAzureProfileCommand cmdlt = new ClearAzureProfileCommand();
5555
// Setup
56-
ProfileClient client = new ProfileClient();
56+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
5757
client.AddOrSetAccount(azureAccount);
5858
client.AddOrSetEnvironment(azureEnvironment);
5959
client.AddOrSetSubscription(azureSubscription1);
@@ -68,7 +68,7 @@ public void ClearAzureProfileClearsDefaultProfile()
6868
cmdlt.InvokeEndProcessing();
6969

7070
// Verify
71-
client = new ProfileClient();
71+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
7272
Assert.Equal(0, client.Profile.Subscriptions.Count);
7373
Assert.Equal(0, client.Profile.Accounts.Count);
7474
Assert.Equal(2, client.Profile.Environments.Count); //only default environments
@@ -81,7 +81,7 @@ public void ClearAzureProfileClearsCustomProfile()
8181

8282
ClearAzureProfileCommand cmdlt = new ClearAzureProfileCommand();
8383
// Setup
84-
ProfileClient client = new ProfileClient(subscriptionDataFile);
84+
ProfileClient client = new ProfileClient(new AzureProfile(subscriptionDataFile));
8585
client.AddOrSetAccount(azureAccount);
8686
client.AddOrSetEnvironment(azureEnvironment);
8787
client.AddOrSetSubscription(azureSubscription1);
@@ -97,7 +97,7 @@ public void ClearAzureProfileClearsCustomProfile()
9797
cmdlt.InvokeEndProcessing();
9898

9999
// Verify
100-
client = new ProfileClient(subscriptionDataFile);
100+
client = new ProfileClient(new AzureProfile(subscriptionDataFile));
101101
Assert.Equal(0, client.Profile.Subscriptions.Count);
102102
Assert.Equal(0, client.Profile.Accounts.Count);
103103
Assert.Equal(2, client.Profile.Environments.Count); //only default environments
@@ -177,7 +177,7 @@ public void SetAzureSubscriptionAddsSubscriptionWithCertificate()
177177
cmdlt.InvokeEndProcessing();
178178

179179
// Verify
180-
ProfileClient client = new ProfileClient();
180+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
181181
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
182182
var newAccount = client.Profile.Accounts[SampleCertificate.Thumbprint];
183183
Assert.Equal(cmdlt.SubscriptionName, newSubscription.Name);
@@ -194,7 +194,7 @@ public void SetAzureSubscriptionAddsSubscriptionWithCertificate()
194194
public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnAdd()
195195
{
196196
// Setup
197-
ProfileClient client = new ProfileClient();
197+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
198198
client.AddOrSetEnvironment(azureEnvironment);
199199
client.Profile.Save();
200200
SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand();
@@ -212,7 +212,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnAdd(
212212
cmdlt.InvokeEndProcessing();
213213

214214
// Verify
215-
client = new ProfileClient();
215+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
216216
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
217217
Assert.Equal(cmdlt.SubscriptionName, newSubscription.Name);
218218
Assert.Equal(cmdlt.Environment, newSubscription.Environment);
@@ -224,7 +224,7 @@ public void SetAzureSubscriptionThrowsExceptionWithoutCertificateOnAdd()
224224
{
225225
SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand();
226226
// Setup
227-
ProfileClient client = new ProfileClient();
227+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
228228
client.AddOrSetEnvironment(azureEnvironment);
229229
client.Profile.Save();
230230

@@ -243,7 +243,7 @@ public void SetAzureSubscriptionThrowsExceptionWithoutCertificateOnAdd()
243243
public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnSet()
244244
{
245245
// Setup
246-
ProfileClient client = new ProfileClient();
246+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
247247
client.AddOrSetAccount(azureAccount);
248248
client.AddOrSetEnvironment(azureEnvironment);
249249
client.AddOrSetSubscription(azureSubscription1);
@@ -261,7 +261,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnSet(
261261
cmdlt.InvokeEndProcessing();
262262

263263
// Verify
264-
client = new ProfileClient();
264+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
265265
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
266266
Assert.Equal(cmdlt.Environment, newSubscription.Environment);
267267
Assert.Equal(cmdlt.CurrentStorageAccountName, newSubscription.GetProperty(AzureSubscription.Property.StorageAccount));
@@ -271,7 +271,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnSet(
271271
public void SetAzureSubscriptionDerivesEnvironmentFromServiceEndpointParameterOnSet()
272272
{
273273
// Setup
274-
ProfileClient client = new ProfileClient();
274+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
275275
client.AddOrSetAccount(azureAccount);
276276
client.AddOrSetEnvironment(azureEnvironment);
277277
client.AddOrSetSubscription(azureSubscription1);
@@ -289,7 +289,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromServiceEndpointParameterOn
289289
cmdlt.InvokeEndProcessing();
290290

291291
// Verify
292-
client = new ProfileClient();
292+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
293293
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
294294
Assert.Equal(cmdlt.Environment, newSubscription.Environment);
295295
Assert.Equal(cmdlt.CurrentStorageAccountName,
@@ -300,7 +300,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromServiceEndpointParameterOn
300300
public void SetAzureSubscriptionDerivesEnvironmentFromResourcesEndpointParameterOnSet()
301301
{
302302
// Setup
303-
ProfileClient client = new ProfileClient();
303+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
304304
client.AddOrSetAccount(azureAccount);
305305
client.AddOrSetEnvironment(azureEnvironment);
306306
client.AddOrSetSubscription(azureSubscription1);
@@ -318,7 +318,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromResourcesEndpointParameter
318318
cmdlt.InvokeEndProcessing();
319319

320320
// Verify
321-
client = new ProfileClient();
321+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
322322
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
323323
Assert.Equal(cmdlt.Environment, newSubscription.Environment);
324324
Assert.Equal(cmdlt.CurrentStorageAccountName, newSubscription.GetProperty(AzureSubscription.Property.StorageAccount));
@@ -328,7 +328,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromResourcesEndpointParameter
328328
public void SetAzureSubscriptionDerivesEnvironmentFromBothEndpointParameters()
329329
{
330330
// Setup
331-
ProfileClient client = new ProfileClient();
331+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
332332
client.AddOrSetAccount(azureAccount);
333333
client.AddOrSetEnvironment(azureEnvironment);
334334
client.AddOrSetSubscription(azureSubscription1);
@@ -348,7 +348,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromBothEndpointParameters()
348348
cmdlt.InvokeEndProcessing();
349349

350350
// Verify
351-
client = new ProfileClient();
351+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
352352
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
353353
Assert.Equal(cmdlt.Environment, newSubscription.Environment);
354354
Assert.Equal(cmdlt.CurrentStorageAccountName, newSubscription.GetProperty(AzureSubscription.Property.StorageAccount));
@@ -358,7 +358,7 @@ public void SetAzureSubscriptionDerivesEnvironmentFromBothEndpointParameters()
358358
public void SetAzureSubscriptionUpdatesSubscriptionWithCertificate()
359359
{
360360
// Setup
361-
ProfileClient client = new ProfileClient();
361+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
362362
client.AddOrSetAccount(azureAccount);
363363
client.AddOrSetEnvironment(azureEnvironment);
364364
client.AddOrSetSubscription(azureSubscription1);
@@ -377,7 +377,7 @@ public void SetAzureSubscriptionUpdatesSubscriptionWithCertificate()
377377
cmdlt.InvokeEndProcessing();
378378

379379
// Verify
380-
client = new ProfileClient();
380+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
381381
var newSubscription = client.Profile.Subscriptions[new Guid(cmdlt.SubscriptionId)];
382382
var newAccount = client.Profile.Accounts[SampleCertificate.Thumbprint];
383383
var existingAccount = client.Profile.Accounts[azureAccount.Id];
@@ -402,14 +402,14 @@ public void ImportPublishSettingsFileSelectsCorrectEnvironment()
402402
// Setup
403403
AzureSession.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
404404
Properties.Resources.ValidProfileChina);
405-
ProfileClient client = new ProfileClient();
405+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
406406
var oldDataStore = FileUtilities.DataStore;
407407
FileUtilities.DataStore = AzureSession.DataStore;
408408
var expectedEnv = "AzureChinaCloud";
409409
var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", null);
410410

411411
cmdlt.CommandRuntime = commandRuntimeMock;
412-
cmdlt.ProfileClient = new ProfileClient();
412+
cmdlt.ProfileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
413413
cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
414414

415415
try
@@ -441,14 +441,14 @@ public void ImportPublishSettingsFileOverwritesEnvironment()
441441
// Setup
442442
AzureSession.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
443443
Properties.Resources.ValidProfileChina);
444-
ProfileClient client = new ProfileClient();
444+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
445445
var oldDataStore = FileUtilities.DataStore;
446446
FileUtilities.DataStore = AzureSession.DataStore;
447447
var expectedEnv = "AzureCloud";
448448
var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);
449449

450450
cmdlt.CommandRuntime = commandRuntimeMock;
451-
cmdlt.ProfileClient = new ProfileClient();
451+
cmdlt.ProfileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
452452
cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
453453
cmdlt.Environment = expectedEnv;
454454

@@ -492,7 +492,7 @@ public void SelectDefaultAzureSubscriptionByNameUpdatesProfile()
492492
cmdlt.InvokeEndProcessing();
493493

494494
// Verify
495-
client = new ProfileClient();
495+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
496496
Assert.NotNull(client.Profile.DefaultSubscription);
497497
Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);
498498
}
@@ -580,7 +580,7 @@ public void SelectDefaultAzureSubscriptionByIdAndNoDefaultUpdatesProfile()
580580
cmdlt.InvokeEndProcessing();
581581

582582
// Verify
583-
client = new ProfileClient();
583+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
584584
Assert.NotNull(client.Profile.DefaultSubscription);
585585
Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);
586586

@@ -597,7 +597,7 @@ public void SelectDefaultAzureSubscriptionByIdAndNoDefaultUpdatesProfile()
597597
cmdlt.InvokeEndProcessing();
598598

599599
// Verify
600-
client = new ProfileClient();
600+
client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
601601
Assert.Null(client.Profile.DefaultSubscription);
602602
}
603603

@@ -654,7 +654,7 @@ public void SelectAzureSubscriptionByInvalidGuidThrowsException()
654654

655655
private ProfileClient SetupDefaultProfile()
656656
{
657-
ProfileClient client = new ProfileClient();
657+
ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
658658
client.AddOrSetEnvironment(azureEnvironment);
659659
client.AddOrSetAccount(azureAccount);
660660
client.AddOrSetSubscription(azureSubscription1);

src/Common/Commands.Common.Test/Mocks/MockClientFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using Microsoft.Azure.Common.Authentication.Models;
2727
using Microsoft.Azure.Common.Authentication;
2828
using Microsoft.Azure;
29+
using System.IO;
2930

3031
namespace Microsoft.WindowsAzure.Commands.Common.Test.Mocks
3132
{
@@ -57,7 +58,7 @@ public TClient CreateClient<TClient>(AzureSubscription subscription, AzureEnviro
5758
SubscriptionCloudCredentials creds = new TokenCloudCredentials(subscription.Id.ToString(), "fake_token");
5859
if (HttpMockServer.GetCurrentMode() != HttpRecorderMode.Playback)
5960
{
60-
ProfileClient profileClient = new ProfileClient();
61+
ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
6162
AzureContext context = new AzureContext(
6263
subscription,
6364
profileClient.GetAccount(subscription.Account),
@@ -67,7 +68,7 @@ public TClient CreateClient<TClient>(AzureSubscription subscription, AzureEnviro
6768
creds = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(context);
6869
}
6970

70-
Uri endpointUri = (new ProfileClient()).Profile.Environments[subscription.Environment].GetEndpointAsUri(endpoint);
71+
Uri endpointUri = (new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)))).Profile.Environments[subscription.Environment].GetEndpointAsUri(endpoint);
7172
return CreateCustomClient<TClient>(creds, endpointUri);
7273
}
7374

src/Common/Commands.Common.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Hyak.Common" version="1.0.1" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.0.1" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
6-
<package id="Microsoft.Azure.Common.Authentication" version="1.0.2-preview" targetFramework="net45" />
6+
<package id="Microsoft.Azure.Common.Authentication" version="1.0.4-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Resources" version="2.12.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5486.28526-prerelease" targetFramework="net45" />
99
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ static AzurePSCmdlet()
3939

4040
public AzurePSCmdlet()
4141
{
42-
AzureSession.Profile = new AzureProfile(
43-
Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
42+
AzureSession.Profile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
4443

4544
DefaultProfileClient = new ProfileClient(AzureSession.Profile);
4645
}

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Common.Authentication">
6262
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
63+
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.0.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>

0 commit comments

Comments
 (0)