Skip to content

Commit 40ffae8

Browse files
committed
Merge remote-tracking branch 'Azure/preview' into preview
# Conflicts: # src/ResourceManager/Resources/Commands.Resources/ChangeLog.md
2 parents e3d0bef + 467f178 commit 40ffae8

File tree

27 files changed

+396
-334
lines changed

27 files changed

+396
-334
lines changed

TestMappings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@
198198
"src/ResourceManager/Websites/": [
199199
".\\src\\ResourceManager\\LogicApp\\Commands.LogicApp.Test\\bin\\Debug\\Microsoft.Azure.Commands.LogicApp.Test.dll",
200200
".\\src\\ResourceManager\\Websites\\Commands.Websites.Test\\bin\\Debug\\Microsoft.Azure.Commands.Websites.Test.dll"
201+
],
202+
"src/ResourceManager/ManagementPartner/": [
203+
".\\src\\ResourceManager\\ManagementPartner\\Commands.Partner.Test\\bin\\Debug\\Microsoft.Azure.Commands.ManagementPartner.Test.dll"
201204
],
202205
"src/ServiceManagement/": [
203206
".\\src\\ServiceManagement\\Common\\Commands.Common.Test\\bin\\Debug\\Microsoft.WindowsAzure.Commands.Common.Test.dll",

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@
478478
UnsignedFiles="@(DelaySignedAssembliesToSign)"
479479
DestinationPath="$(LibrarySourceFolder)"
480480
BasePath="$(LibrarySourceFolder)"
481-
Certificates="72, 401"
481+
Certificates="72, 400"
482482
SigningLogPath="$(LibraryRoot)\signing.log"
483483
ToolsPath="$(CIToolsPath)"
484484
Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''"/>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,11 @@ public string ToString(bool serializeCache)
312312
}
313313

314314
/// <summary>
315-
/// Set the contaienr to its defautl state
315+
/// Set the contaienr to its default state
316316
/// </summary>
317317
public void Clear()
318318
{
319+
this.GetTokenCache()?.Clear();
319320
Contexts.Clear();
320321
DefaultContextKey = "Default";
321322
DefaultContext = new AzureContext();
@@ -324,6 +325,8 @@ public void Clear()
324325
{
325326
EnvironmentTable.Add(environment.Key, environment.Value);
326327
}
328+
329+
AzureRmProfileProvider.Instance.SetTokenCacheForProfile(this);
327330
}
328331

329332
public bool TryAddContext(IAzureContext context, out string name)
@@ -393,9 +396,9 @@ public bool TryGetContextName(IAzureContext context, out string name)
393396
if (context != null)
394397
{
395398

396-
if (context.Subscription != null)
399+
if (context.Subscription != null && context.Account != null)
397400
{
398-
name = string.Format("{0} - {1}", context.Subscription.Name, context.Subscription.Id);
401+
name = string.Format("{0} ({1}) - {2}", context.Subscription.Name, context.Subscription.Id, context.Account.Id);
399402
result = true;
400403
}
401404
else

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public static bool HasTokenCache(this IAzureContextContainer container)
2929
&& container.DefaultContext.TokenCache.CacheData.Length > 0;
3030
}
3131

32+
public static void SetTokenCache(this IAzureContextContainer container, IAzureTokenCache cache)
33+
{
34+
if (container != null && container.DefaultContext != null)
35+
{
36+
container.DefaultContext.TokenCache = cache;
37+
}
38+
}
39+
3240
public static IAzureTokenCache GetTokenCache(this IAzureContextContainer container)
3341
{
3442
IAzureTokenCache result = null;

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.Azure.Commands.Common.Authentication.Models;
1818
using Microsoft.Azure.Commands.Common.Authentication.ResourceManager;
19+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1920
using System.IO;
2021

2122
namespace Microsoft.Azure.Commands.ResourceManager.Common
@@ -49,7 +50,16 @@ public override T GetProfile<T>()
4950

5051
public override void SetTokenCacheForProfile(IAzureContextContainer profile)
5152
{
52-
// do not update the token cache in this case
53+
base.SetTokenCacheForProfile(profile);
54+
var session = AzureSession.Instance;
55+
var cache = new ProtectedFileTokenCache(Path.Combine(session.TokenCacheDirectory, session.TokenCacheFile), session.DataStore);
56+
session.TokenCache = cache;
57+
if (profile.HasTokenCache())
58+
{
59+
cache.Deserialize(profile.GetTokenCache().CacheData);
60+
}
61+
62+
profile.SetTokenCache(cache);
5363
}
5464

5565
public override IAzureContextContainer Profile
@@ -68,7 +78,7 @@ public override IAzureContextContainer Profile
6878
/// <summary>
6979
/// Initialize the resource manager profile
7080
/// </summary>
71-
public static void InitializeResourceManagerProfile(bool overwrite=false)
81+
public static void InitializeResourceManagerProfile(bool overwrite = false)
7282
{
7383
SetInstance(() => new ProtectedProfileProvider(), overwrite);
7484
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ public override void ResetDefaultProfile()
3636
public override void SetTokenCacheForProfile(IAzureContextContainer profile)
3737
{
3838
base.SetTokenCacheForProfile(profile);
39+
var cache = new AuthenticationStoreTokenCache(TokenCache.DefaultShared);
3940
if (profile.HasTokenCache())
4041
{
41-
var cache = TokenCache.DefaultShared;
4242
cache.Deserialize(profile.GetTokenCache().CacheData);
43-
AzureSession.Instance.TokenCache = new AuthenticationStoreTokenCache(cache);
4443
}
44+
45+
AzureSession.Instance.TokenCache = cache;
46+
profile.SetTokenCache(cache);
4547
}
4648

4749
public override T GetProfile<T>()

src/ResourceManager/ManagementPartner/Commands.Partner.Test/Commands.Partner.Test.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.Management.ManagementPartner, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
55-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ManagementPartner.1.0.0-preview\lib\net452\Microsoft.Azure.Management.ManagementPartner.dll</HintPath>
55+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ManagementPartner.1.1.0-preview\lib\net452\Microsoft.Azure.Management.ManagementPartner.dll</HintPath>
5656
<Private>True</Private>
5757
</Reference>
5858
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -63,7 +63,7 @@
6363
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.8.1\lib\net452\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
6767
<Private>True</Private>
6868
</Reference>
6969
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -74,9 +74,10 @@
7474
</Reference>
7575
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7676
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.3.0\lib\net452\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
77+
<Private>True</Private>
7778
</Reference>
78-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
79-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
79+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
80+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.7.2\lib\net452\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
8081
<Private>True</Private>
8182
</Reference>
8283
<Reference Include="Microsoft.Threading.Tasks">
@@ -176,4 +177,4 @@
176177
<PostBuildEvent>rem xcopy "$(SolutionDir)Package\$(ConfigurationName)\*.*" $(TargetDir) /Y /E
177178
</PostBuildEvent>
178179
</PropertyGroup>
179-
</Project>
180+
</Project>

src/ResourceManager/ManagementPartner/Commands.Partner.Test/ScenarioTests/ManagementPartnerTests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Tests get management partner
2121
function Test-GetPartner
2222
{
2323
# Setup
24-
$partnerId="123457"
24+
$partnerId="5127255"
2525
$partner = New-AzureRmManagementPartner -PartnerId $partnerId
2626

2727
# Test
@@ -45,7 +45,7 @@ Tests get management partner without parnter id
4545
function Test-GetPartnerNoPartnerId
4646
{
4747
# Setup
48-
$partnerId="123457"
48+
$partnerId="5127255"
4949
$partner = New-AzureRmManagementPartner -PartnerId $partnerId
5050

5151
# Test
@@ -68,7 +68,7 @@ Tests add management partner
6868
#>
6969
function Test-NewPartner
7070
{
71-
$partnerId="123457"
71+
$partnerId="5127255"
7272
$partner = New-AzureRmManagementPartner -PartnerId $partnerId
7373

7474
# Assert
@@ -89,11 +89,11 @@ Tests update management partner
8989
function Test-UpdatePartner
9090
{
9191
# Setup
92-
$partnerId="123457"
92+
$partnerId="5127255"
9393
$partner = New-AzureRmManagementPartner -PartnerId $partnerId
9494

9595
# Test
96-
$newPartnerId="123456"
96+
$newPartnerId="5127254"
9797
$partner = Update-AzureRmManagementPartner -PartnerId $newPartnerId
9898

9999
# Assert
@@ -113,7 +113,7 @@ Tests remove management partner
113113
function Test-RemovePartner
114114
{
115115
# Setup
116-
$partnerId="123457"
116+
$partnerId="5127255"
117117
$partner = New-AzureRmManagementPartner -PartnerId $partnerId
118118

119119
# Test

0 commit comments

Comments
 (0)