Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void RunPsTestWorkflow(
string mockName)
{
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("Microsoft.Authorization", "2014-07-01-preview");
d.Add("Microsoft.Authorization", null);
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d);

using (UndoContext context = UndoContext.Current)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -51,6 +53,10 @@ protected void SetupManagementClients()

protected void RunPowerShellTest(params string[] scripts)
{
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("Microsoft.Authorization", null);
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(false, d);

using (UndoContext context = UndoContext.Current)
{
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void RunPowerShellTest(params string[] scripts)
{
//HttpMockServer.Matcher = new PermissiveRecordMatcher();
Dictionary<string, string> d = new Dictionary<string, string>();
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down