public void TestFallbackWhenArmCloudMetadataInitFails()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, @"TestData\BadArmResponse.json");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(TestOperationsFactory.Create().GetHttpOperations());

            var unequalItemsDict = armEnvironments
                                   .Where(keyValuePair => !hardCodedEnvironments[keyValuePair.Key].Equals(keyValuePair.Value))
                                   .ToDictionary(entry => entry.Key, entry => entry.Value);

            if (unequalItemsDict.Any())
            {
                Assert.True(false, "Hard coded and ARM based cloud metadata initializations have different values.");
            }
        }
Пример #2
0
        public void TestDisableArmCloudMetadataInit()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, "disabled");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(null, httpOperations: TestOperationsFactory.Create().GetHttpOperations());

            // Check all built-in environments are loaded because discover is disabled
            Assert.Equal(4, armEnvironments.Count);
            foreach (var env in armEnvironments.Values)
            {
                Assert.Equal(AzureEnvironment.TypeBuiltIn, env.Type);
            }
        }
Пример #3
0
        public void TestArmResponseOneEntry()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, @"TestData\ArmResponseOneEntry.json");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(null, httpOperations: TestOperationsFactory.Create().GetHttpOperations());

            Assert.Equal(5, armEnvironments.Count);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureCloud].Type);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureChinaCloud].Type);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureGermanCloud].Type);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureUSGovernment].Type);
        }
Пример #4
0
        public void TestArmResponseNoAzureCloud()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, @"TestData\ArmResponseNoAzureCloud.json");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(null, httpOperations: TestOperationsFactory.Create().GetHttpOperations());

            // Check AzureCloud is added to public environment list even discovery endpoint doesn't return AzureCloud.
            Assert.Equal(4, armEnvironments.Count);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureCloud].Type);
            Assert.Equal(AzureEnvironment.TypeBuiltIn, armEnvironments[EnvironmentName.AzureChinaCloud].Type);
            Assert.Equal(AzureEnvironment.TypeDiscovered, armEnvironments[EnvironmentName.AzureGermanCloud].Type);
            Assert.Equal(AzureEnvironment.TypeDiscovered, armEnvironments[EnvironmentName.AzureUSGovernment].Type);
        }
Пример #5
0
        public void TestArmCloudMetadata20190501Init()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, @"TestData\ArmResponse2019-05-01.json");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(null, httpOperations: TestOperationsFactory.Create().GetHttpOperations());

            // Check all discovered environments are loaded.
            Assert.Equal(4, armEnvironments.Count);
            foreach (var env in armEnvironments.Values)
            {
                Assert.Equal(AzureEnvironment.TypeDiscovered, env.Type);
                Assert.EndsWith("/", env.ServiceManagementUrl);
                Assert.StartsWith(".", env.SqlDatabaseDnsSuffix);
            }
        }
Пример #6
0
        public void TestArmAndNonArmBasedCloudMetadataInit()
        {
            Environment.SetEnvironmentVariable(ArmMetadataEnvVariable, @"TestData\GoodArmResponse.json");
            var armEnvironments = AzureEnvironment.InitializeBuiltInEnvironments(null, httpOperations: TestOperationsFactory.Create().GetHttpOperations());

            // Check all discovered environments are loaded.
            Assert.Equal(4, armEnvironments.Count);
            foreach (var env in armEnvironments.Values)
            {
                Assert.Equal(AzureEnvironment.TypeDiscovered, env.Type);
            }
        }