Skip to content

Commit 32debb4

Browse files
author
Hovsep Mkrtchyan
committed
Fixed XmlProfileSerializer bug related to ProfileData namespace change during Common.Authorization migration to PowerShell repo
1 parent 95eef6b commit 32debb4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Common/Commands.Common.Authentication/Models/XmlProfileSerializer.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public bool Deserialize(string contents, AzureSMProfile profile)
3838
DeserializeErrors = new List<string>();
3939

4040
DataContractSerializer serializer = new DataContractSerializer(typeof(ProfileData));
41+
42+
// For backward compatibility since namespace of ProfileData has been changed
43+
// we need to replace previous namespace with the current one
44+
if (!string.IsNullOrWhiteSpace(contents))
45+
{
46+
contents = contents.Replace(
47+
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Common.Authentication",
48+
"http://schemas.datacontract.org/2004/07/Microsoft.Azure.Commands.Common.Authentication");
49+
}
50+
4151
using (MemoryStream s = new MemoryStream(Encoding.UTF8.GetBytes(contents ?? "")))
4252
{
4353
data = (ProfileData)serializer.ReadObject(s);

src/ServiceManagement/Common/Commands.Common.Test/Common/ProfileClientTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Xunit;
2626
using CSMSubscription = Microsoft.Azure.Subscriptions.Models.Subscription;
2727
using RDFESubscription = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionListOperationResponse.Subscription;
28+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2829

2930
namespace Common.Authentication.Test
3031
{
@@ -56,7 +57,6 @@ public class ProfileClientTests
5657

5758
public ProfileClientTests()
5859
{
59-
AzureSession.ProfileDirectory = AppDomain.CurrentDomain.BaseDirectory;
6060
SetMockData();
6161
currentProfile = new AzureSMProfile();
6262
}
@@ -194,6 +194,7 @@ public void ProfileMigratesOldDataOnce()
194194
}
195195

196196
[Fact]
197+
[Trait(Category.AcceptanceType, Category.CheckIn)]
197198
public void ProfileMigratesAccountsAndDefaultSubscriptions()
198199
{
199200
MemoryDataStore dataStore = new MemoryDataStore();

0 commit comments

Comments
 (0)