AzureEnvironment -> Environment
This commit is contained in:
Родитель
0d30ad575d
Коммит
116202b7c9
|
@ -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",
|
||||
|
|
|
@ -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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче