Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should get the environment by the name', function () {
var envName = 'AzureCloud';
var env = Common.getEnvironment(envName);
env.should.be.exactly(AzureEnvironment.Azure);
envName = 'AzureChinaCloud';
var env = Common.getEnvironment(envName);
env.should.be.exactly(AzureEnvironment.AzureChina);
});
});
module.exports.getEnvironment = function(environmentName) {
var azureEnv;
switch(environmentName) {
   case 'AzureCloud':
       azureEnv = AzureEnvironment.Azure;
       break;
   case 'AzureChinaCloud':
azureEnv = AzureEnvironment.AzureChina;
       break;
   case 'AzureGermanCloud':
       azureEnv = AzureEnvironment.AzureGermanCloud;
       break;
case 'AzureUSGovernment':
azureEnv = AzureEnvironment.AzureUSGovernment;
break;
   default:
throw new Error(util.format('Environment %s is not supported', environmentName));
}
var len = azureEnv.resourceManagerEndpointUrl.length;
if (azureEnv.resourceManagerEndpointUrl[len - 1] != '/') {
azureEnv.resourceManagerEndpointUrl = azureEnv.resourceManagerEndpointUrl + '/' ;
}
return azureEnv;