Skip to content

Commit 70cc576

Browse files
author
Hovsep Mkrtchyan
committed
Fixed Compute and SQL tests
1 parent 3eb1938 commit 70cc576

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,24 @@ public string GetMatchingKey(System.Net.Http.HttpRequestMessage request)
5353

5454
public string GetMatchingKey(RecordEntry recordEntry)
5555
{
56-
var encodedPath = recordEntry.EncodedRequestUri;
57-
if (recordEntry.RequestUri.Contains("?&"))
56+
string path = recordEntry.RequestUri;
57+
if(!string.IsNullOrEmpty(recordEntry.EncodedRequestUri))
5858
{
59-
var updatedPath = recordEntry.RequestUri.Replace("?&", "?");
60-
61-
62-
string version;
63-
if (ContainsIgnoredProvider(updatedPath, out version))
64-
{
65-
updatedPath = RemoveOrReplaceApiVersion(updatedPath, version);
66-
}
59+
path = Encoding.UTF8.GetString(Convert.FromBase64String(recordEntry.EncodedRequestUri));
60+
}
6761

68-
encodedPath = Convert.ToBase64String(Encoding.UTF8.GetBytes(updatedPath));
62+
if (path.Contains("?&"))
63+
{
64+
path = path.Replace("?&", "?");
6965
}
7066

67+
string version;
68+
if (ContainsIgnoredProvider(path, out version))
69+
{
70+
path = RemoveOrReplaceApiVersion(path, version);
71+
}
72+
73+
var encodedPath = Convert.ToBase64String(Encoding.UTF8.GetBytes(path));
7174
return string.Format("{0} {1}", recordEntry.RequestMethod, encodedPath);
7275
}
7376

src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void RunPsTestWorkflow(
9797
string mockName)
9898
{
9999
Dictionary<string, string> d = new Dictionary<string, string>();
100-
d.Add("Microsoft.Authorization", "2014-07-01-preview");
100+
d.Add("Microsoft.Authorization", null);
101101
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d);
102102

103103
using (UndoContext context = UndoContext.Current)

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/DscExtensionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
55
{
66
public class DscExtensionTests
77
{
8-
[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
8+
[Fact]
99
[Trait(Category.AcceptanceType, Category.CheckIn)]
1010
public void TestGetAzureRmVMDscExtension()
1111
{

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
1919
{
2020
public class VirtualMachineProfileTests
2121
{
22-
[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
22+
[Fact]
2323
[Trait(Category.AcceptanceType, Category.CheckIn)]
2424
public void TestVirtualMachineProfile()
2525
{
2626
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineProfile");
2727
}
2828

29-
[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
29+
[Fact]
3030
[Trait(Category.AcceptanceType, Category.CheckIn)]
3131
public void TestVirtualMachineProfileWithoutAUC()
3232
{

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function Test-VirtualMachineProfile
116116
$imgRef = Get-DefaultCRPWindowsImageOffline -loc $loc;
117117
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
118118

119-
$subid = (Get-AzureRmSubscription -Current).SubscriptionId;
119+
$subid = (Get-AzureRmContext).Subscription.SubscriptionId;
120120

121121
$referenceUri = "/subscriptions/" + $subid + "/resourceGroups/RgTest1/providers/Microsoft.KeyVault/vaults/TestVault123";
122122
$certStore = "My";
@@ -283,7 +283,7 @@ function Test-VirtualMachineProfileWithoutAUC
283283
$imgRef = Get-DefaultCRPWindowsImageOffline -loc $loc;
284284
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
285285

286-
$subid = (Get-AzureRmSubscription -Current).SubscriptionId;
286+
$subid = (Get-AzureRmContext).Subscription.SubscriptionId;
287287

288288
$referenceUri = "/subscriptions/" + $subid + "/resourceGroups/RgTest1/providers/Microsoft.KeyVault/vaults/TestVault123";
289289
$certStore = "My";

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
1919
{
2020
public partial class VirtualMachineTests
2121
{
22-
[Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")]
22+
[Fact]
2323
[Trait(Category.AcceptanceType, Category.CheckIn)]
2424
public void TestVirtualMachine()
2525
{

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function Test-VirtualMachine
179179
Assert-NotNull $aset;
180180
Assert-AreEqual $asetName $aset.Name;
181181

182-
$asetId = ('/subscriptions/' + (Get-AzureRmSubscription -Current).SubscriptionId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/availabilitySets/' + $asetName);
182+
$asetId = ('/subscriptions/' + (Get-AzureRmContext).Subscription.SubscriptionId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/availabilitySets/' + $asetName);
183183
$vmname2 = $vmname + '2';
184184
$p2 = New-AzureRmVMConfig -VMName $vmname2 -VMSize $vmsize -AvailabilitySetId $asetId;
185185
$p2.HardwareProfile = $p.HardwareProfile;

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected void RunPowerShellTest(params string[] scripts)
5757
{
5858
//HttpMockServer.Matcher = new PermissiveRecordMatcher();
5959
Dictionary<string, string> d = new Dictionary<string, string>();
60-
d.Add("Microsoft.Authorization", "2014-07-01-preview");
60+
d.Add("Microsoft.Authorization", null);
6161
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d);
6262
// Enable undo functionality as well as mock recording
6363
using (UndoContext context = UndoContext.Current)

0 commit comments

Comments
 (0)