Skip to content

Commit 3e1ab7e

Browse files
committed
Updating test to include environment name in environment record
1 parent e0c02ce commit 3e1ab7e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/ResourceManager/Profile/Commands.Profile.Test/ProfileCmdletTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public ProfileCmdletTests(ITestOutputHelper output)
5252
public void SelectAzureProfileInMemory()
5353
{
5454
var profile = new AzureRmProfile { DefaultContext = new AzureContext() };
55-
profile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));
55+
var env = new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
56+
env.Name = "foo";
57+
profile.EnvironmentTable.Add("foo", env);
5658
ImportAzureRMContextCommand cmdlt = new ImportAzureRMContextCommand();
5759
// Setup
5860
cmdlt.AzureContext = profile;

src/ResourceManager/Profile/Commands.Profile/Context/ImportAzureRMContext.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
17-
using Microsoft.Azure.Commands.Common.Authentication.Core;
1817
using Microsoft.Azure.Commands.Common.Authentication.Models;
1918
using Microsoft.Azure.Commands.Common.Authentication.ResourceManager;
2019
using Microsoft.Azure.Commands.Profile.Common;
2120
using Microsoft.Azure.Commands.Profile.Models;
2221
// TODO: Remove IfDef
2322
#if NETSTANDARD
23+
using Microsoft.Azure.Commands.Common.Authentication.Core;
2424
using Microsoft.Azure.Commands.Profile.Models.Core;
25+
#else
26+
using Microsoft.Azure.Commands.Common.Authentication;
2527
#endif
2628
using Microsoft.Azure.Commands.Profile.Properties;
2729
using System;
@@ -82,6 +84,11 @@ void CopyProfile(AzureRmProfile source, IProfileOperations target)
8284

8385
void EnsureProtectedCache(IProfileOperations profile, byte[] cacheData)
8486
{
87+
if (profile == null || cacheData == null)
88+
{
89+
return;
90+
}
91+
8592
AzureRmAutosaveProfile autosave = profile as AzureRmAutosaveProfile;
8693
var protectedcache = AzureSession.Instance.TokenCache as ProtectedFileTokenCache;
8794
if (autosave != null && protectedcache == null && cacheData.Any())

0 commit comments

Comments
 (0)