Skip to content

Commit 2faffac

Browse files
committed
revert DefaultContext to _profile.DefaultContext to pass test cases except ListTenants
1 parent 4b79993 commit 2faffac

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Accounts/Accounts/Models/RMProfileClient.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private IAzureContext DefaultContext
5656
public RMProfileClient(IProfileOperations profile)
5757
{
5858
_profile = profile;
59-
var context = DefaultContext;
59+
var context = _profile.DefaultContext;
6060
_cache = AzureSession.Instance.TokenCache;
6161
if (_profile != null && context != null &&
6262
context.TokenCache != null)
@@ -264,7 +264,7 @@ public AzureRmProfile Login(
264264
}
265265
}
266266

267-
shouldPopulateContextList &= DefaultContext?.Account == null;
267+
shouldPopulateContextList &= _profile.DefaultContext?.Account == null;
268268
if (newSubscription == null)
269269
{
270270
if (subscriptionId != null)
@@ -298,10 +298,10 @@ public AzureRmProfile Login(
298298
}
299299
}
300300

301-
DefaultContext.TokenCache = _cache;
301+
_profile.DefaultContext.TokenCache = _cache;
302302
if (shouldPopulateContextList)
303303
{
304-
var defaultContext = DefaultContext;
304+
var defaultContext = _profile.DefaultContext;
305305
var subscriptions = ListSubscriptions(tenantId).Take(25);
306306
foreach (var subscription in subscriptions)
307307
{
@@ -338,7 +338,7 @@ public IAzureContext SetCurrentContext(string subscriptionNameOrId, string tenan
338338
IAzureTenant tenant = null;
339339
Guid subscriptionId;
340340
IAzureContext context = new AzureContext();
341-
context.CopyFrom(DefaultContext);
341+
context.CopyFrom(_profile.DefaultContext);
342342
if (!string.IsNullOrWhiteSpace(subscriptionNameOrId))
343343
{
344344
if (Guid.TryParse(subscriptionNameOrId, out subscriptionId))
@@ -369,7 +369,7 @@ public IAzureContext SetCurrentContext(string subscriptionNameOrId, string tenan
369369

370370
context.WithTenant(tenant).WithSubscription(subscription);
371371
_profile.TrySetDefaultContext(name, context);
372-
DefaultContext.ExtendedProperties.Clear();
372+
_profile.DefaultContext.ExtendedProperties.Clear();
373373
return context;
374374
}
375375

@@ -472,8 +472,8 @@ public IAzureEnvironment RemoveEnvironment(string name)
472472
public IAccessToken AcquireAccessToken(string tenantId, Action<string> promptAction = null)
473473
{
474474
return AcquireAccessToken(
475-
DefaultContext.Account,
476-
DefaultContext.Environment,
475+
_profile.DefaultContext.Account,
476+
_profile.DefaultContext.Environment,
477477
tenantId, null,
478478
ShowDialog.Auto,
479479
promptAction);
@@ -495,7 +495,7 @@ public IEnumerable<IAzureSubscription> ListSubscriptions(string tenantIdOrDomain
495495
{
496496
WriteWarningMessage(string.Format(
497497
ProfileMessages.UnableToLogin,
498-
DefaultContext.Account,
498+
_profile.DefaultContext.Account,
499499
tenant));
500500
}
501501

@@ -723,8 +723,8 @@ private List<AzureTenant> ListAccountTenants(
723723
private IEnumerable<AzureSubscription> ListAllSubscriptionsForTenant(
724724
string tenantId)
725725
{
726-
IAzureAccount account = DefaultContext.Account;
727-
IAzureEnvironment environment = DefaultContext.Environment;
726+
IAzureAccount account = _profile.DefaultContext.Account;
727+
IAzureEnvironment environment = _profile.DefaultContext.Environment;
728728
SecureString password = null;
729729
string promptBehavior = ShowDialog.Never;
730730
IAccessToken accessToken = null;
@@ -744,7 +744,7 @@ private IEnumerable<AzureSubscription> ListAllSubscriptionsForTenant(
744744
new TokenCredentials(accessToken.AccessToken) as ServiceClientCredentials,
745745
AzureSession.Instance.ClientFactory.GetCustomHandlers());
746746

747-
AzureContext context = new AzureContext(DefaultContext.Subscription, account, environment,
747+
AzureContext context = new AzureContext(_profile.DefaultContext.Subscription, account, environment,
748748
CreateTenantFromString(tenantId, accessToken.TenantId));
749749

750750
return subscriptionClient.ListAllSubscriptions().Select(s => s.ToAzureSubscription(context));

tools/RunVersionController.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function Get-ReleaseNotes
132132
$_.FullName -notlike "*Netcore*" -and `
133133
$_.FullName -notlike "*dll-Help.psd1*" -and `
134134
$_.FullName -notlike "*Stack*" } }
135+
135136
Import-LocalizedData -BindingVariable ModuleMetadata -BaseDirectory $ModuleManifestFile.DirectoryName -FileName $ModuleManifestFile.Name
136137
return $ModuleMetadata.PrivateData.PSData.ReleaseNotes
137138
}

0 commit comments

Comments
 (0)