diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs index 0a5585090fd6..08c4a256a761 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/EnvironmentSetupHelper.cs @@ -58,8 +58,10 @@ public EnvironmentSetupHelper() rmprofile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); rmprofile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.Environments["foo"], new AzureTenant()); rmprofile.Context.Subscription.Environment = "foo"; - AzureRMCmdlet.DefaultProfile = rmprofile; - AzureSession.DataStore = datastore; + if (AzureRMCmdlet.DefaultProfile == null) + { + AzureRMCmdlet.DefaultProfile = rmprofile; + } ProfileClient = new ProfileClient(profile); // Ignore SSL errors @@ -162,12 +164,18 @@ private void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode) environment.Endpoints[AzureEnvironment.Endpoint.ActiveDirectory] = currentEnvironment.Endpoints.AADAuthUri.AbsoluteUri; environment.Endpoints[AzureEnvironment.Endpoint.Gallery] = currentEnvironment.Endpoints.GalleryUri.AbsoluteUri; environment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = currentEnvironment.BaseUri.AbsoluteUri; + environment.Endpoints[AzureEnvironment.Endpoint.ResourceManager] = currentEnvironment.Endpoints.ResourceManagementUri.AbsoluteUri; if (!ProfileClient.Profile.Environments.ContainsKey(testEnvironmentName)) { ProfileClient.AddOrSetEnvironment(environment); } + if (!AzureRMCmdlet.DefaultProfile.Environments.ContainsKey(testEnvironmentName)) + { + AzureRMCmdlet.DefaultProfile.Environments[testEnvironmentName] = environment; + } + if (currentEnvironment.SubscriptionId != null) { testSubscription = new AzureSubscription() @@ -199,6 +207,17 @@ private void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode) ProfileClient.Profile.Subscriptions[testSubscription.Id] = testSubscription; ProfileClient.Profile.Accounts[testAccount.Id] = testAccount; ProfileClient.SetSubscriptionAsDefault(testSubscription.Name, testSubscription.Account); + + var testTenant = new AzureTenant() { Id = Guid.NewGuid() }; + if (!string.IsNullOrEmpty(currentEnvironment.Tenant)) + { + Guid tenant; + if (Guid.TryParse(currentEnvironment.Tenant, out tenant)) + { + testTenant.Id = tenant; + } + } + AzureRMCmdlet.DefaultProfile.Context = new AzureContext(testSubscription, testAccount, environment, testTenant); } } diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/PermissiveRecordMatcherWithApiExclusion.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/PermissiveRecordMatcherWithApiExclusion.cs index e0de3fd00b5c..fb1b9d38ddfb 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/PermissiveRecordMatcherWithApiExclusion.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/PermissiveRecordMatcherWithApiExclusion.cs @@ -53,21 +53,24 @@ public string GetMatchingKey(System.Net.Http.HttpRequestMessage request) public string GetMatchingKey(RecordEntry recordEntry) { - var encodedPath = recordEntry.EncodedRequestUri; - if (recordEntry.RequestUri.Contains("?&")) + string path = recordEntry.RequestUri; + if(!string.IsNullOrEmpty(recordEntry.EncodedRequestUri)) { - var updatedPath = recordEntry.RequestUri.Replace("?&", "?"); - - - string version; - if (ContainsIgnoredProvider(updatedPath, out version)) - { - updatedPath = RemoveOrReplaceApiVersion(updatedPath, version); - } + path = Encoding.UTF8.GetString(Convert.FromBase64String(recordEntry.EncodedRequestUri)); + } - encodedPath = Convert.ToBase64String(Encoding.UTF8.GetBytes(updatedPath)); + if (path.Contains("?&")) + { + path = path.Replace("?&", "?"); } + string version; + if (ContainsIgnoredProvider(path, out version)) + { + path = RemoveOrReplaceApiVersion(path, version); + } + + var encodedPath = Convert.ToBase64String(Encoding.UTF8.GetBytes(path)); return string.Format("{0} {1}", recordEntry.RequestMethod, encodedPath); } diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs b/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs index 572482b43ce2..f91eb0302613 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs +++ b/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs @@ -97,7 +97,7 @@ public void RunPsTestWorkflow( string mockName) { Dictionary d = new Dictionary(); - d.Add("Microsoft.Authorization", "2014-07-01-preview"); + d.Add("Microsoft.Authorization", null); HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d); using (UndoContext context = UndoContext.Current) diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/DscExtensionTests.cs b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/DscExtensionTests.cs index 5851018f5812..290de79df578 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/DscExtensionTests.cs +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/DscExtensionTests.cs @@ -5,7 +5,7 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests { public class DscExtensionTests { - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestGetAzureRmVMDscExtension() { diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs index 66d901739cbc..5249c6808a38 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs @@ -19,14 +19,14 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests { public class VirtualMachineProfileTests { - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVirtualMachineProfile() { ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineProfile"); } - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVirtualMachineProfileWithoutAUC() { diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 index 86ce7d2aa07c..2d73acdc9c6f 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 @@ -116,7 +116,7 @@ function Test-VirtualMachineProfile $imgRef = Get-DefaultCRPWindowsImageOffline -loc $loc; $p = ($imgRef | Set-AzureRmVMSourceImage -VM $p); - $subid = (Get-AzureRmSubscription -Current).SubscriptionId; + $subid = (Get-AzureRmContext).Subscription.SubscriptionId; $referenceUri = "/subscriptions/" + $subid + "/resourceGroups/RgTest1/providers/Microsoft.KeyVault/vaults/TestVault123"; $certStore = "My"; @@ -283,7 +283,7 @@ function Test-VirtualMachineProfileWithoutAUC $imgRef = Get-DefaultCRPWindowsImageOffline -loc $loc; $p = ($imgRef | Set-AzureRmVMSourceImage -VM $p); - $subid = (Get-AzureRmSubscription -Current).SubscriptionId; + $subid = (Get-AzureRmContext).Subscription.SubscriptionId; $referenceUri = "/subscriptions/" + $subid + "/resourceGroups/RgTest1/providers/Microsoft.KeyVault/vaults/TestVault123"; $certStore = "My"; diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.cs b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.cs index 700cab5f3a43..7343e9362214 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.cs +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.cs @@ -19,7 +19,7 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests { public partial class VirtualMachineTests { - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVirtualMachine() { diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1 b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1 index dbb828cec90f..08fb95444028 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1 +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineTests.ps1 @@ -179,7 +179,7 @@ function Test-VirtualMachine Assert-NotNull $aset; Assert-AreEqual $asetName $aset.Name; - $asetId = ('/subscriptions/' + (Get-AzureRmSubscription -Current).SubscriptionId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/availabilitySets/' + $asetName); + $asetId = ('/subscriptions/' + (Get-AzureRmContext).Subscription.SubscriptionId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/availabilitySets/' + $asetName); $vmname2 = $vmname + '2'; $p2 = New-AzureRmVMConfig -VMName $vmname2 -VMSize $vmsize -AvailabilitySetId $asetId; $p2.HardwareProfile = $p.HardwareProfile; diff --git a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/Common.ps1 b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/Common.ps1 index 28e3faa7d8d4..17f3de540dba 100644 --- a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/Common.ps1 +++ b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/Common.ps1 @@ -36,7 +36,7 @@ Gets a valid storage account resource id #> function Get-StorageResourceId($rgname, $resourcename) { - $subscription = (Get-AzureRmSubscription -Default).SubscriptionId + $subscription = (Get-AzureRmContext).Subscription.SubscriptionId return "/subscriptions/$subscription/resourcegroups/$rgname/providers/microsoft.storage/storageaccounts/$resourcename" } diff --git a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/OperationalInsightsScenarioTestBase.cs b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/OperationalInsightsScenarioTestBase.cs index 7eb73b3e4349..01c8c250909a 100644 --- a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/OperationalInsightsScenarioTestBase.cs +++ b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/OperationalInsightsScenarioTestBase.cs @@ -19,8 +19,10 @@ using Microsoft.Azure.Management.Resources; using Microsoft.Azure.Subscriptions; using Microsoft.Azure.Test; +using Microsoft.Azure.Test.HttpRecorder; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; +using System.Collections.Generic; namespace Microsoft.Azure.Commands.OperationalInsights.Test { @@ -51,6 +53,10 @@ protected void SetupManagementClients() protected void RunPowerShellTest(params string[] scripts) { + Dictionary d = new Dictionary(); + d.Add("Microsoft.Authorization", null); + HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d); + using (UndoContext context = UndoContext.Current) { context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2)); diff --git a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/StorageInsightTests.cs b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/StorageInsightTests.cs index e71cd984a2e8..6d2c81b2fdb4 100644 --- a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/StorageInsightTests.cs +++ b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/StorageInsightTests.cs @@ -19,14 +19,14 @@ namespace Microsoft.Azure.Commands.OperationalInsights.Test { public class StorageInsightTests : OperationalInsightsScenarioTestBase { - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestStorageInsightCreateUpdateDelete() { RunPowerShellTest("Test-StorageInsightCreateUpdateDelete"); } - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestStorageInsightCreateFailsWithoutWorkspace() { diff --git a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.cs b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.cs index f00e0377d006..87207409e023 100644 --- a/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.cs +++ b/src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleAssignmentTests.cs @@ -37,21 +37,21 @@ public void RaAuthorizationChangeLog() ResourcesController.NewInstance.RunPsTest("Test-RaAuthorizationChangeLog"); } - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact(Skip = "Need to re-record test")] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RaClassicAdmins() { ResourcesController.NewInstance.RunPsTest("Test-RaClassicAdmins"); } - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact(Skip = "Need to re-record test")] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RaNegativeScenarios() { ResourcesController.NewInstance.RunPsTest("Test-RaNegativeScenarios"); } - [Fact(Skip = "PSGet Migration: TODO: Get-AzureRmSubscription")] + [Fact(Skip = "Need to re-record test")] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RaByScope() { diff --git a/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs b/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs index 092b9453f827..3011c4324af7 100644 --- a/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs +++ b/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs @@ -57,7 +57,7 @@ protected void RunPowerShellTest(params string[] scripts) { //HttpMockServer.Matcher = new PermissiveRecordMatcher(); Dictionary d = new Dictionary(); - d.Add("Microsoft.Authorization", "2014-07-01-preview"); + d.Add("Microsoft.Authorization", null); HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d); // Enable undo functionality as well as mock recording using (UndoContext context = UndoContext.Current) diff --git a/src/ServiceManagement/Services/Commands.Test/Profile/NewAzureProfileTests.cs b/src/ServiceManagement/Services/Commands.Test/Profile/NewAzureProfileTests.cs index a5f2f131cb88..d064a4493ab7 100644 --- a/src/ServiceManagement/Services/Commands.Test/Profile/NewAzureProfileTests.cs +++ b/src/ServiceManagement/Services/Commands.Test/Profile/NewAzureProfileTests.cs @@ -56,7 +56,7 @@ public void TestMakeRdfeCallWithCreatedProfile() ProfileTestController.NewRdfeInstance.RunPSTestWithToken((context, token) => string.Format("Test-NewAzureProfileInRDFEMode {0} {1} {2}", token, context.Account.Id, context.Subscription.Id)); } - [Fact(Skip = "Hovsep: Move to ARM")] + [Fact(Skip = "PSGet Migration: TODO Move to ARM")] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestMakeArmCallWithCreatedProfile() {