From 116202b7c9e25c75f6657eb9e90d6409b5f16436 Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Thu, 4 Oct 2018 15:28:19 -0700 Subject: [PATCH] AzureEnvironment -> Environment --- lib/azureEnvironment.ts | 30 +++++++++++++++--------------- test/azureEnvironmentTests.ts | 26 +++++++++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/azureEnvironment.ts b/lib/azureEnvironment.ts index b7718b0..75a08c6 100644 --- a/lib/azureEnvironment.ts +++ b/lib/azureEnvironment.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -export interface AzureEnvironmentParameters { +export interface EnvironmentParameters { /** * The Environment name. */ @@ -93,7 +93,7 @@ export interface AzureEnvironmentParameters { readonly validateAuthority?: boolean; } -export class AzureEnvironment { +export class Environment { /** * The Environment name. */ @@ -184,7 +184,7 @@ export class AzureEnvironment { */ readonly validateAuthority: boolean = true; - constructor(parameters: AzureEnvironmentParameters) { + constructor(parameters: EnvironmentParameters) { if (!parameters || typeof parameters !== "object") { throw new Error("'parameters' is a required parameter and must be of type 'object'."); @@ -248,23 +248,23 @@ export class AzureEnvironment { } } - static add(parameters: AzureEnvironmentParameters): void { - const envContainer: { [name: string]: AzureEnvironment } = {}; - const envObj = new AzureEnvironment(parameters); + static add(parameters: EnvironmentParameters): void { + const envContainer: { [name: string]: Environment } = {}; + const envObj = new Environment(parameters); envContainer[parameters.name] = envObj; - Object.assign(AzureEnvironment, envContainer); + Object.assign(Environment, envContainer); return; } - static get(name: string): AzureEnvironment { + static get(name: string): Environment { if (!name) { throw new TypeError("name cannot be null or undefined and must be of type string."); } - return (AzureEnvironment as any)[name]; + return (Environment as any)[name]; } - static readonly Azure = { - name: "Azure", + static readonly AzureCloud = { + name: "AzureCloud", portalUrl: "https://portal.azure.com", publishingProfileUrl: "https://go.microsoft.com/fwlink/?LinkId=254432", managementEndpointUrl: "https://management.core.windows.net", @@ -283,8 +283,8 @@ export class AzureEnvironment { azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "azuredatalakeanalytics.net", validateAuthority: true }; - static readonly AzureChina = { - name: "AzureChina", + static readonly ChinaCloud = { + name: "AzureChinaCloud", portalUrl: "https://portal.azure.cn", publishingProfileUrl: "https://go.microsoft.com/fwlink/?LinkID=301774", managementEndpointUrl: "https://management.core.chinacloudapi.cn", @@ -304,7 +304,7 @@ export class AzureEnvironment { azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "N/A", validateAuthority: true }; - static readonly AzureUSGovernment = { + static readonly USGovernment = { name: "AzureUSGovernment", portalUrl: "https://portal.azure.us", publishingProfileUrl: "https://manage.windowsazure.us/publishsettings/index", @@ -324,7 +324,7 @@ export class AzureEnvironment { azureDataLakeAnalyticsCatalogAndJobEndpointSuffix: "N/A", validateAuthority: true }; - static readonly AzureGermanCloud = { + static readonly GermanCloud = { name: "AzureGermanCloud", portalUrl: "https://portal.microsoftazure.de/", publishingProfileUrl: "https://manage.microsoftazure.de/publishsettings/index", diff --git a/test/azureEnvironmentTests.ts b/test/azureEnvironmentTests.ts index 5951079..1559feb 100644 --- a/test/azureEnvironmentTests.ts +++ b/test/azureEnvironmentTests.ts @@ -2,13 +2,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. import * as should from "should"; -import { AzureEnvironment, AzureEnvironmentParameters } from "../lib/azureEnvironment"; +import { Environment, EnvironmentParameters } from "../lib/azureEnvironment"; describe("AzureEnvironment", function () { it("should show the details of Azure Production environment correctly", function (done) { - const tempEnv = AzureEnvironment.Azure; - tempEnv.name.should.equal("Azure"); + const tempEnv = Environment.AzureCloud; + tempEnv.name.should.equal("AzureCloud"); tempEnv.batchResourceId.should.equal("https://batch.core.windows.net/"); tempEnv.activeDirectoryEndpointUrl.should.equal("https://login.microsoftonline.com/"); tempEnv.activeDirectoryResourceId.should.equal("https://management.core.windows.net/"); @@ -19,9 +19,9 @@ describe("AzureEnvironment", function () { done(); }); - it("should show the details of Azure China environment correctly", function (done) { - const tempEnv = AzureEnvironment.AzureChina; - tempEnv.name.should.equal("AzureChina"); + it("should show Environment.ChinaCloud environment correctly", function (done) { + const tempEnv = Environment.ChinaCloud; + tempEnv.name.should.equal("AzureChinaCloud"); tempEnv.batchResourceId.should.equal("https://batch.chinacloudapi.cn/"); tempEnv.activeDirectoryEndpointUrl.should.equal("https://login.chinacloudapi.cn/"); tempEnv.activeDirectoryResourceId.should.equal("https://management.core.chinacloudapi.cn/"); @@ -31,9 +31,9 @@ describe("AzureEnvironment", function () { tempEnv.validateAuthority.should.equal(true); done(); }); - + Environment it("should show the details of Azure USGovernment environment correctly", function (done) { - const tempEnv = AzureEnvironment.AzureUSGovernment; + const tempEnv = Environment.USGovernment; tempEnv.name.should.equal("AzureUSGovernment"); tempEnv.batchResourceId.should.equal("https://batch.core.usgovcloudapi.net/"); tempEnv.activeDirectoryEndpointUrl.should.equal("https://login.microsoftonline.us/"); @@ -43,10 +43,10 @@ describe("AzureEnvironment", function () { tempEnv.portalUrl.should.equal("https://portal.azure.us"); tempEnv.validateAuthority.should.equal(true); done(); - }); + }); Environment it("should show the details of Azure GermanCloud environment correctly", function (done) { - const tempEnv = AzureEnvironment.AzureGermanCloud; + const tempEnv = Environment.GermanCloud; tempEnv.name.should.equal("AzureGermanCloud"); tempEnv.batchResourceId.should.equal("https://batch.microsoftazure.de/"); tempEnv.activeDirectoryEndpointUrl.should.equal("https://login.microsoftonline.de/"); @@ -55,11 +55,11 @@ describe("AzureEnvironment", function () { tempEnv.resourceManagerEndpointUrl.should.equal("https://management.microsoftazure.de"); tempEnv.portalUrl.should.equal("https://portal.microsoftazure.de/"); tempEnv.validateAuthority.should.equal(true); - done(); + done(); Environment }); it("should be able to add a new environment", function (done) { - const df: AzureEnvironmentParameters = { + const df: EnvironmentParameters = { name: "Dogfood", portalUrl: "http://go.microsoft.com/fwlink/?LinkId=254433", managementEndpointUrl: "https://management.core.windows.net", @@ -67,7 +67,7 @@ describe("AzureEnvironment", function () { activeDirectoryEndpointUrl: "https://login.microsoftonline.com/", activeDirectoryResourceId: "https://management.core.windows.net/" }; - const tempEnv = AzureEnvironment; + const tempEnv = Environment; tempEnv.add(df); const dfood = tempEnv.get(df.name); dfood.name.should.equal("Dogfood");