Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>Commands.Common.Authentication</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<TargetFrameworkProfile />
<RestorePackages>true</RestorePackages>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
Expand Down Expand Up @@ -51,7 +51,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\net45\Hyak.Common.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -178,5 +179,4 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public bool Deserialize(string contents, AzureSMProfile profile)
DeserializeErrors = new List<string>();

DataContractSerializer serializer = new DataContractSerializer(typeof(ProfileData));

// For backward compatibility since namespace of ProfileData has been changed
// we need to replace previous namespace with the current one
if (!string.IsNullOrWhiteSpace(contents))
{
contents = contents.Replace(
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Common.Authentication",
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Commands.Common.Authentication");
}

using (MemoryStream s = new MemoryStream(Encoding.UTF8.GetBytes(contents ?? "")))
{
data = (ProfileData)serializer.ReadObject(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<Compile Include="Mocks\MockClientFactory.cs" />
<Compile Include="Mocks\MockCommandRuntime.cs" />
<Compile Include="PermissiveRecordMatcherWithApiExclusion.cs" />
<Compile Include="ProfileClient.cs" />
<Compile Include="PSCmdletExtensions.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Mocks\MockAccessToken.cs" />
Expand Down Expand Up @@ -171,10 +172,6 @@
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\ServiceManagement\Common\Commands.ServiceManagement.Common\Commands.ServiceManagement.Common.csproj">
<Project>{cff09e81-1e31-444e-b4d4-a21e946c29e2}</Project>
<Name>Commands.ServiceManagement.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
<Name>Commands.ResourceManager.Common</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ public EnvironmentSetupHelper()
rmprofile.Context.Subscription.Environment = "foo";
if (AzureRmProfileProvider.Instance.Profile == null)
{
AzureRmProfileProvider.Instance.Profile = rmprofile; }
AzureRmProfileProvider.Instance.Profile = rmprofile;
}

AzureSession.DataStore = datastore; ProfileClient = new ProfileClient(profile);
AzureSession.DataStore = datastore;
ProfileClient = new ProfileClient(profile);

// Ignore SSL errors
System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Factories;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.ServiceManagemenet.Common;
using Microsoft.WindowsAzure.Commands.ScenarioTest;

namespace Microsoft.WindowsAzure.Commands.Common.Test.Mocks
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public AzureSubscription SetSubscriptionAsDefault(Guid id, string accountName)
{
if (subscription.IsPropertySet(AzureSubscription.Property.StorageAccount))
{
subscription.SetProperty(AzureSubscription.Property.StorageAccount, null);
GeneralUtilities.ClearCurrentStorageAccount();
}

Profile.DefaultSubscription = subscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\ServiceManagement\Common\Commands.ServiceManagement.Common\Commands.ServiceManagement.Common.csproj">
<Project>{cff09e81-1e31-444e-b4d4-a21e946c29e2}</Project>
<Name>Commands.ServiceManagement.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
<Name>Commands.ResourceManager.Common</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ public static AzureRMProfile CreateAzureRMProfile(string storageAccount)
AccountType = "User"
},
Environment = (PSAzureEnvironment)AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
Subscription =
new PSAzureSubscription {
Subscription =
new PSAzureSubscription
{
CurrentStorageAccount = storageAccount,
CurrentStorageAccountName= PSAzureSubscription.GetAccountName(storageAccount),
CurrentStorageAccountName = PSAzureSubscription.GetAccountName(storageAccount),
SubscriptionId = subscriptionId.ToString(),
SubscriptionName = "Test Subscription 1",
TenantId = tenantId.ToString()
},
Tenant = new PSAzureTenant
{
Domain=domain,
Domain = domain,
TenantId = tenantId.ToString()
}
};
return new AzureRMProfile() { Context = context};
return new AzureRMProfile() { Context = context };
}

public static AzureSMProfile CreateAzureSMProfile(string storageAccount)
Expand Down Expand Up @@ -99,13 +100,14 @@ public static void RunDataProfileTest(AzureRMProfile rmProfile, AzureSMProfile s
AzureRmProfileProvider.Instance.Profile = savedRmProfile;
AzureSMProfileProvider.Instance.Profile = savedSmProfile;
}
}
}

[Theory,
InlineData(null, null),
InlineData("", null),
InlineData("AccountName=myAccount", "AccountName=myAccount")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanClearStorageAccountForSMProfile(string connectionString, string expected)
public void CanClearStorageAccountForSMProfile(string connectionString, string expected)
{
RunDataProfileTest(
CreateAzureRMProfile(null),
Expand All @@ -121,9 +123,9 @@ public void CanClearStorageAccountForSMProfile(string connectionString, string e
[Theory,
InlineData(null, null),
InlineData("", null),
InlineData("AccountName=myAccount","AccountName=myAccount")]
InlineData("AccountName=myAccount", "AccountName=myAccount")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanClearStorageAccountForRMProfile(string connectionString, string expected)
public void CanClearStorageAccountForRMProfile(string connectionString, string expected)
{
RunDataProfileTest(
CreateAzureRMProfile(connectionString),
Expand All @@ -138,18 +140,18 @@ public void CanClearStorageAccountForRMProfile(string connectionString, string e

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanClearStorageAccountForEmptyProfile()
public void CanClearStorageAccountForEmptyProfile()
{
var rmProfile = new AzureRMProfile();
rmProfile.Context = new AzureContext(null, null, null, null);
RunDataProfileTest(
rmProfile,
new AzureSMProfile(),
() =>
{
GeneralUtilities.ClearCurrentStorageAccount(true);
Assert.True(string.IsNullOrEmpty(AzureSMProfileProvider.Instance.Profile.Context.GetCurrentStorageAccountName()));
});
RunDataProfileTest(
rmProfile,
new AzureSMProfile(),
() =>
{
GeneralUtilities.ClearCurrentStorageAccount(true);
Assert.True(string.IsNullOrEmpty(AzureSMProfileProvider.Instance.Profile.Context.GetCurrentStorageAccountName()));
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Xunit;
using CSMSubscription = Microsoft.Azure.Subscriptions.Models.Subscription;
using RDFESubscription = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionListOperationResponse.Subscription;
using Microsoft.WindowsAzure.Commands.ScenarioTest;

namespace Common.Authentication.Test
{
Expand Down Expand Up @@ -193,6 +194,7 @@ public void ProfileMigratesOldDataOnce()
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ProfileMigratesAccountsAndDefaultSubscriptions()
{
MemoryDataStore dataStore = new MemoryDataStore();
Expand Down