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 @@ -12,40 +12,38 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Management.Automation;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure.Commands.Common.Storage;
using Microsoft.WindowsAzure.Commands.Profile.Models;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions;
using Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Network.Gateway.Model;
using Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.Model;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.DiskRepository;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extensions.BGInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extensions.Common;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extesnions.CustomScript;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extesnions.VMAccess;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extensions.SqlServer;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.Extesnions.VMAccess;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo.ILB;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PaasCmdletInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PIRCmdletInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.SubscriptionCmdletInfo;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Network.Gateway.Model;
using Microsoft.WindowsAzure.Management.Network.Models;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Management.Automation;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
{
Expand Down Expand Up @@ -1857,26 +1855,11 @@ public void RemoveAzureSubscription(string Name, bool force, bool debug = false)
removeAzureSubscriptionCmdlet.Run(debug);
}

public List<AzureEnvironment> GetAzureEnvironment(string name = null, string subscriptionDataFile = null, bool debug = false)
public List<PSAzureEnvironment> GetAzureEnvironment(string name = null, string subscriptionDataFile = null, bool debug = false)
{
Collection<PSObject> result = (new WindowsAzurePowershellCmdlet(new GetAzureEnvironmentCmdletInfo(name, subscriptionDataFile))).Run(debug);
List<AzureEnvironment> envList = new List<AzureEnvironment>();

foreach (var element in result)
{
var newEnv = new AzureEnvironment();
newEnv.Name = element.Properties.Match("Name")[0].Value.ToString();
var endpoints = new Dictionary<AzureEnvironment.Endpoint,string>();
var endpointKeys = Enum.GetValues(typeof(AzureEnvironment.Endpoint));
foreach(var key in endpointKeys)
{
endpoints.Add((AzureEnvironment.Endpoint) key, (string) element.Properties.Match(key.ToString())[0].Value);
}

newEnv.Endpoints = endpoints;
envList.Add(newEnv);
}

var envList = new List<PSAzureEnvironment>();
RunPSCmdletAndReturnAll<PSAzureEnvironment>(new GetAzureEnvironmentCmdletInfo(name, subscriptionDataFile))
.ForEach(a => envList.Add(a));
return envList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,33 +180,33 @@ public static void SetTestSettings()
CredentialHelper.GetTestSettings(Resource.TestSettings);

vmPowershellCmdlets.RemoveAzureSubscriptions();
if (vmPowershellCmdlets.GetAzureEnvironment("ussouth").Count > 0)
var ussouthEnv = vmPowershellCmdlets.GetAzureEnvironment("ussouth");
if (ussouthEnv != null && ussouthEnv.Count > 0)
{
Console.WriteLine("Removing ussouth environment...");
vmPowershellCmdlets.RunPSScript("Remove-AzureEnvironment -Name ussouth -Force");
}

List<AzureEnvironment> environments = vmPowershellCmdlets.GetAzureEnvironment();
List<PSAzureEnvironment> environments = vmPowershellCmdlets.GetAzureEnvironment();
var serviceManagementUrl = GetServiceManagementUrl(CredentialHelper.PublishSettingsFile);

foreach (var env in environments)
{
var envServiceManagementUrl = (string) env.Endpoints[AzureEnvironment.Endpoint.ServiceManagement];
if (!string.IsNullOrEmpty(envServiceManagementUrl))
if (!string.IsNullOrEmpty(env.ServiceManagementUrl))
{
if (envServiceManagementUrl.Equals(serviceManagementUrl))
if (env.ServiceManagementUrl.Equals(serviceManagementUrl))
{
currentEnvName = env.Name;
var curEnv = vmPowershellCmdlets.GetAzureEnvironment(currentEnvName)[0];
Console.WriteLine("Using the existing environment: {0}", currentEnvName);
Console.WriteLine("PublichSettingsFileUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl));
Console.WriteLine("ServiceManagement: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ServiceManagement));
Console.WriteLine("ManagementPortalUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl));
Console.WriteLine("ActiveDirectory: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory));
Console.WriteLine("ActiveDirectoryServiceEndpointResourceId: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId));
Console.WriteLine("ResourceManager: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager));
Console.WriteLine("Gallery: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery));
Console.WriteLine("Graph: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph));
Console.WriteLine("PublichSettingsFileUrl: {0}", curEnv.PublishSettingsFileUrl);
Console.WriteLine("ServiceManagement: {0}", curEnv.ServiceManagementUrl);
Console.WriteLine("ManagementPortalUrl: {0}", curEnv.ManagementPortalUrl);
Console.WriteLine("ActiveDirectory: {0}", curEnv.ActiveDirectoryAuthority);
Console.WriteLine("ActiveDirectoryServiceEndpointResourceId: {0}", curEnv.ActiveDirectoryServiceEndpointResourceId);
Console.WriteLine("ResourceManager: {0}", curEnv.ResourceManagerUrl);
Console.WriteLine("Gallery: {0}", curEnv.GalleryUrl);
Console.WriteLine("Graph: {0}", curEnv.GalleryUrl);
break;
}
}
Expand All @@ -227,14 +227,14 @@ public static void SetTestSettings()
-GalleryEndpoint {7} `
-GraphEndpoint {8}",
TempEnvName,
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl),
prodEnv.PublishSettingsFileUrl,
serviceManagementUrl,
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl),
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory),
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId),
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager),
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery),
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph)));
prodEnv.ManagementPortalUrl,
prodEnv.ActiveDirectoryAuthority,
prodEnv.ActiveDirectoryServiceEndpointResourceId,
prodEnv.ResourceManagerUrl,
prodEnv.GalleryUrl,
prodEnv.GalleryUrl));

vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile, TempEnvName);
}
Expand Down