diff --git a/src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj b/src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj index 0e7ed8e59545..2681cd664d3e 100644 --- a/src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj +++ b/src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj @@ -11,7 +11,7 @@ Commands.Common.Authentication v4.5 512 - ..\..\ + true /assemblyCompareMode:StrongNameIgnoringVersion 06e19c11 @@ -51,7 +51,8 @@ - ..\..\packages\Hyak.Common.1.0.3\lib\net45\Hyak.Common.dll + False + ..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll True @@ -178,5 +179,4 @@ - \ No newline at end of file diff --git a/src/Common/Commands.Common.Authentication/Models/XmlProfileSerializer.cs b/src/Common/Commands.Common.Authentication/Models/XmlProfileSerializer.cs index c1eda20aefef..1c1ee2a38d4f 100644 --- a/src/Common/Commands.Common.Authentication/Models/XmlProfileSerializer.cs +++ b/src/Common/Commands.Common.Authentication/Models/XmlProfileSerializer.cs @@ -38,6 +38,16 @@ public bool Deserialize(string contents, AzureSMProfile profile) DeserializeErrors = new List(); 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); diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj index bd0ca39315b6..2e57ab65bb77 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj @@ -140,6 +140,7 @@ + @@ -171,10 +172,6 @@ {5ee72c53-1720-4309-b54b-5fb79703195f} Commands.Common - - {cff09e81-1e31-444e-b4d4-a21e946c29e2} - Commands.ServiceManagement.Common - {3819d8a7-c62c-4c47-8ddd-0332d9ce1252} Commands.ResourceManager.Common diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs index 9ffaf56104bd..486a52f56cea 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs @@ -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; diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Mocks/MockClientFactory.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Mocks/MockClientFactory.cs index 7541d4ba702f..0595d8bc7c7d 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Mocks/MockClientFactory.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Mocks/MockClientFactory.cs @@ -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 { diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/ProfileClient.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/ProfileClient.cs index 2c93654794db..9eedd3034ec3 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/ProfileClient.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/ProfileClient.cs @@ -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; diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj index cc0056bc0f9c..d531bbddfdd0 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -238,10 +238,6 @@ {5ee72c53-1720-4309-b54b-5fb79703195f} Commands.Common - - {cff09e81-1e31-444e-b4d4-a21e946c29e2} - Commands.ServiceManagement.Common - {3819d8a7-c62c-4c47-8ddd-0332d9ce1252} Commands.ResourceManager.Common diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/CommonDataCmdletTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/CommonDataCmdletTests.cs index 0058e0b8c93a..43c03919a733 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/CommonDataCmdletTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/CommonDataCmdletTests.cs @@ -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) @@ -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), @@ -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), @@ -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())); + }); } -} + } } diff --git a/src/ServiceManagement/Common/Commands.Common.Test/Common/ProfileClientTests.cs b/src/ServiceManagement/Common/Commands.Common.Test/Common/ProfileClientTests.cs index d17327bd538f..d7607989ad77 100644 --- a/src/ServiceManagement/Common/Commands.Common.Test/Common/ProfileClientTests.cs +++ b/src/ServiceManagement/Common/Commands.Common.Test/Common/ProfileClientTests.cs @@ -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 { @@ -193,6 +194,7 @@ public void ProfileMigratesOldDataOnce() } [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void ProfileMigratesAccountsAndDefaultSubscriptions() { MemoryDataStore dataStore = new MemoryDataStore();