Skip to content

Commit af88352

Browse files
committed
Fix test setup
1 parent d6a6d67 commit af88352

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ public static void SetTestSettings()
181181
CredentialHelper.GetTestSettings(Resource.TestSettings);
182182

183183
vmPowershellCmdlets.RemoveAzureSubscriptions();
184+
var ussouthEnv = vmPowershellCmdlets.GetAzureEnvironment("ussouth");
185+
if (ussouthEnv != null && ussouthEnv.Count > 0)
186+
{
187+
Console.WriteLine("Removing ussouth environment...");
188+
vmPowershellCmdlets.RunPSScript("Remove-AzureEnvironment -Name ussouth -Force");
189+
}
184190

185191
List<PSAzureEnvironment> environments = vmPowershellCmdlets.GetAzureEnvironment();
186192

@@ -221,58 +227,50 @@ public static void SetTestSettings()
221227

222228
foreach (var env in environments)
223229
{
224-
var envServiceManagementUrl = (string) env.Endpoints[AzureEnvironment.Endpoint.ServiceManagement];
225-
226-
if (!string.IsNullOrEmpty(envServiceManagementUrl))
230+
if ((!string.IsNullOrEmpty(env.ServiceManagementUrl)))
227231
{
228232
Console.WriteLine("The service management URL for evironment {0} is : {1}", env, serviceManagementUrl);
229-
if (envServiceManagementUrl.Equals(serviceManagementUrl))
233+
if (env.ServiceManagementUrl.Equals(serviceManagementUrl))
230234
{
231235
currentEnvName = env.Name;
232236
var curEnv = vmPowershellCmdlets.GetAzureEnvironment(currentEnvName)[0];
233237
Console.WriteLine("Using the existing environment: {0}", currentEnvName);
234-
Console.WriteLine("PublichSettingsFileUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl));
235-
Console.WriteLine("ServiceManagement: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ServiceManagement));
236-
Console.WriteLine("ManagementPortalUrl: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl));
237-
Console.WriteLine("ActiveDirectory: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory));
238-
Console.WriteLine("ActiveDirectoryServiceEndpointResourceId: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId));
239-
Console.WriteLine("ResourceManager: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager));
240-
Console.WriteLine("Gallery: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery));
241-
Console.WriteLine("Graph: {0}", curEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph));
238+
Console.WriteLine("PublichSettingsFileUrl: {0}", curEnv.PublishSettingsFileUrl);
239+
Console.WriteLine("ServiceManagement: {0}", curEnv.ServiceManagementUrl);
240+
Console.WriteLine("ManagementPortalUrl: {0}", curEnv.ManagementPortalUrl);
241+
Console.WriteLine("ActiveDirectory: {0}", curEnv.ActiveDirectoryAuthority);
242+
Console.WriteLine("ActiveDirectoryServiceEndpointResourceId: {0}", curEnv.ActiveDirectoryServiceEndpointResourceId);
243+
Console.WriteLine("ResourceManager: {0}", curEnv.ResourceManagerUrl);
244+
Console.WriteLine("Gallery: {0}", curEnv.GalleryUrl);
245+
Console.WriteLine("Graph: {0}", curEnv.GalleryUrl);
242246
break;
243247
}
244248
}
245249
}
246250

247251
if (string.IsNullOrEmpty(currentEnvName))
248-
{
249-
if (vmPowershellCmdlets.GetAzureEnvironment("ussouth").Count > 0)
250-
{
251-
Console.WriteLine("Removing ussouth environment...");
252-
vmPowershellCmdlets.RunPSScript("Remove-AzureEnvironment -Name ussouth -Force");
253-
}
254-
252+
{
255253
Console.WriteLine("Creating new environment... : {0}", TempEnvName);
256254
var prodEnv = vmPowershellCmdlets.GetAzureEnvironment("AzureCloud")[0];
257255
vmPowershellCmdlets.RunPSScript(string.Format(
258256
@"Add-AzureEnvironment -Name {0} `
259-
-PublishSettingsFileUrl {1} `
260-
-ServiceEndpoint {2} `
261-
-ManagementPortalUrl {3} `
262-
-ActiveDirectoryEndpoint {4} `
263-
-ActiveDirectoryServiceEndpointResourceId {5} `
264-
-ResourceManagerEndpoint {6} `
265-
-GalleryEndpoint {7} `
266-
-GraphEndpoint {8}",
257+
-PublishSettingsFileUrl {1} `
258+
-ServiceEndpoint {2} `
259+
-ManagementPortalUrl {3} `
260+
-ActiveDirectoryEndpoint {4} `
261+
-ActiveDirectoryServiceEndpointResourceId {5} `
262+
-ResourceManagerEndpoint {6} `
263+
-GalleryEndpoint {7} `
264+
-GraphEndpoint {8}",
267265
TempEnvName,
268-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.PublishSettingsFileUrl),
266+
prodEnv.PublishSettingsFileUrl,
269267
serviceManagementUrl,
270-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ManagementPortalUrl),
271-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectory),
272-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId),
273-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager),
274-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Gallery),
275-
prodEnv.GetEndpoint(AzureEnvironment.Endpoint.Graph)));
268+
prodEnv.ManagementPortalUrl,
269+
prodEnv.ActiveDirectoryAuthority,
270+
prodEnv.ActiveDirectoryServiceEndpointResourceId,
271+
prodEnv.ResourceManagerUrl,
272+
prodEnv.GalleryUrl,
273+
prodEnv.GalleryUrl));
276274

277275
vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile, TempEnvName);
278276
}

0 commit comments

Comments
 (0)