Skip to content

Commit c06cd8f

Browse files
author
Hovsep
committed
Merge pull request #1841 from hovsepm/dev
Fixing profile tests in ASM.
2 parents f088168 + 9045a4c commit c06cd8f

File tree

9 files changed

+43
-33
lines changed

9 files changed

+43
-33
lines changed

src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AssemblyName>Commands.Common.Authentication</AssemblyName>
1212
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
14+
<TargetFrameworkProfile />
1515
<RestorePackages>true</RestorePackages>
1616
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
1717
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
@@ -51,7 +51,8 @@
5151
</PropertyGroup>
5252
<ItemGroup>
5353
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
54-
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\net45\Hyak.Common.dll</HintPath>
54+
<SpecificVersion>False</SpecificVersion>
55+
<HintPath>..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
5556
<Private>True</Private>
5657
</Reference>
5758
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -178,5 +179,4 @@
178179
<None Include="packages.config" />
179180
</ItemGroup>
180181
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
181-
<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')" />
182182
</Project>

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/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
<Compile Include="Mocks\MockClientFactory.cs" />
141141
<Compile Include="Mocks\MockCommandRuntime.cs" />
142142
<Compile Include="PermissiveRecordMatcherWithApiExclusion.cs" />
143+
<Compile Include="ProfileClient.cs" />
143144
<Compile Include="PSCmdletExtensions.cs" />
144145
<Compile Include="Constants.cs" />
145146
<Compile Include="Mocks\MockAccessToken.cs" />
@@ -171,10 +172,6 @@
171172
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
172173
<Name>Commands.Common</Name>
173174
</ProjectReference>
174-
<ProjectReference Include="..\..\..\ServiceManagement\Common\Commands.ServiceManagement.Common\Commands.ServiceManagement.Common.csproj">
175-
<Project>{cff09e81-1e31-444e-b4d4-a21e946c29e2}</Project>
176-
<Name>Commands.ServiceManagement.Common</Name>
177-
</ProjectReference>
178175
<ProjectReference Include="..\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
179176
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
180177
<Name>Commands.ResourceManager.Common</Name>

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ public EnvironmentSetupHelper()
6161
rmprofile.Context.Subscription.Environment = "foo";
6262
if (AzureRmProfileProvider.Instance.Profile == null)
6363
{
64-
AzureRmProfileProvider.Instance.Profile = rmprofile; }
64+
AzureRmProfileProvider.Instance.Profile = rmprofile;
65+
}
6566

66-
AzureSession.DataStore = datastore; ProfileClient = new ProfileClient(profile);
67+
AzureSession.DataStore = datastore;
68+
ProfileClient = new ProfileClient(profile);
6769

6870
// Ignore SSL errors
6971
System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Mocks/MockClientFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Microsoft.Azure.Commands.Common.Authentication.Factories;
3030
using Microsoft.Azure.Commands.Common.Authentication.Models;
3131
using Microsoft.Azure.ServiceManagemenet.Common;
32+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
3233

3334
namespace Microsoft.WindowsAzure.Commands.Common.Test.Mocks
3435
{

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/ProfileClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ public AzureSubscription SetSubscriptionAsDefault(Guid id, string accountName)
656656
{
657657
if (subscription.IsPropertySet(AzureSubscription.Property.StorageAccount))
658658
{
659-
subscription.SetProperty(AzureSubscription.Property.StorageAccount, null);
659+
GeneralUtilities.ClearCurrentStorageAccount();
660660
}
661661

662662
Profile.DefaultSubscription = subscription;

src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@
238238
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
239239
<Name>Commands.Common</Name>
240240
</ProjectReference>
241-
<ProjectReference Include="..\..\..\ServiceManagement\Common\Commands.ServiceManagement.Common\Commands.ServiceManagement.Common.csproj">
242-
<Project>{cff09e81-1e31-444e-b4d4-a21e946c29e2}</Project>
243-
<Name>Commands.ServiceManagement.Common</Name>
244-
</ProjectReference>
245241
<ProjectReference Include="..\..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
246242
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
247243
<Name>Commands.ResourceManager.Common</Name>

src/ResourceManager/Profile/Commands.Profile.Test/CommonDataCmdletTests.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,22 @@ public static AzureRMProfile CreateAzureRMProfile(string storageAccount)
3939
AccountType = "User"
4040
},
4141
Environment = (PSAzureEnvironment)AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
42-
Subscription =
43-
new PSAzureSubscription {
42+
Subscription =
43+
new PSAzureSubscription
44+
{
4445
CurrentStorageAccount = storageAccount,
45-
CurrentStorageAccountName= PSAzureSubscription.GetAccountName(storageAccount),
46+
CurrentStorageAccountName = PSAzureSubscription.GetAccountName(storageAccount),
4647
SubscriptionId = subscriptionId.ToString(),
4748
SubscriptionName = "Test Subscription 1",
4849
TenantId = tenantId.ToString()
4950
},
5051
Tenant = new PSAzureTenant
5152
{
52-
Domain=domain,
53+
Domain = domain,
5354
TenantId = tenantId.ToString()
5455
}
5556
};
56-
return new AzureRMProfile() { Context = context};
57+
return new AzureRMProfile() { Context = context };
5758
}
5859

5960
public static AzureSMProfile CreateAzureSMProfile(string storageAccount)
@@ -99,13 +100,14 @@ public static void RunDataProfileTest(AzureRMProfile rmProfile, AzureSMProfile s
99100
AzureRmProfileProvider.Instance.Profile = savedRmProfile;
100101
AzureSMProfileProvider.Instance.Profile = savedSmProfile;
101102
}
102-
}
103+
}
104+
103105
[Theory,
104106
InlineData(null, null),
105107
InlineData("", null),
106108
InlineData("AccountName=myAccount", "AccountName=myAccount")]
107109
[Trait(Category.AcceptanceType, Category.CheckIn)]
108-
public void CanClearStorageAccountForSMProfile(string connectionString, string expected)
110+
public void CanClearStorageAccountForSMProfile(string connectionString, string expected)
109111
{
110112
RunDataProfileTest(
111113
CreateAzureRMProfile(null),
@@ -121,9 +123,9 @@ public void CanClearStorageAccountForSMProfile(string connectionString, string e
121123
[Theory,
122124
InlineData(null, null),
123125
InlineData("", null),
124-
InlineData("AccountName=myAccount","AccountName=myAccount")]
126+
InlineData("AccountName=myAccount", "AccountName=myAccount")]
125127
[Trait(Category.AcceptanceType, Category.CheckIn)]
126-
public void CanClearStorageAccountForRMProfile(string connectionString, string expected)
128+
public void CanClearStorageAccountForRMProfile(string connectionString, string expected)
127129
{
128130
RunDataProfileTest(
129131
CreateAzureRMProfile(connectionString),
@@ -138,18 +140,18 @@ public void CanClearStorageAccountForRMProfile(string connectionString, string e
138140

139141
[Fact]
140142
[Trait(Category.AcceptanceType, Category.CheckIn)]
141-
public void CanClearStorageAccountForEmptyProfile()
143+
public void CanClearStorageAccountForEmptyProfile()
142144
{
143145
var rmProfile = new AzureRMProfile();
144146
rmProfile.Context = new AzureContext(null, null, null, null);
145-
RunDataProfileTest(
146-
rmProfile,
147-
new AzureSMProfile(),
148-
() =>
149-
{
150-
GeneralUtilities.ClearCurrentStorageAccount(true);
151-
Assert.True(string.IsNullOrEmpty(AzureSMProfileProvider.Instance.Profile.Context.GetCurrentStorageAccountName()));
152-
});
147+
RunDataProfileTest(
148+
rmProfile,
149+
new AzureSMProfile(),
150+
() =>
151+
{
152+
GeneralUtilities.ClearCurrentStorageAccount(true);
153+
Assert.True(string.IsNullOrEmpty(AzureSMProfileProvider.Instance.Profile.Context.GetCurrentStorageAccountName()));
154+
});
153155
}
154-
}
156+
}
155157
}

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

Lines changed: 2 additions & 0 deletions
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
{
@@ -193,6 +194,7 @@ public void ProfileMigratesOldDataOnce()
193194
}
194195

195196
[Fact]
197+
[Trait(Category.AcceptanceType, Category.CheckIn)]
196198
public void ProfileMigratesAccountsAndDefaultSubscriptions()
197199
{
198200
MemoryDataStore dataStore = new MemoryDataStore();

0 commit comments

Comments
 (0)