Ejemplo n.º 1
0
        public async Task RegisterResourceProviderTest()
        {
            // SET PARAMETERS
            var location               = Environment.GetEnvironmentVariable("AZURE_LOCATION");
            var baseUriString          = Environment.GetEnvironmentVariable("AZURE_BASE_URL");
            var resourceGroupName      = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP");
            var servicePrincipalId     = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
            var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
            var azureResourceId        = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID");
            var tenantId               = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
            var subscriptionId         = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
            var resourceProvidersName  = Environment.GetEnvironmentVariable("AZURE_RESOURCEPROVIDERS");
            var credentials            = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId);

            // SET CONTROLLER
            var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId);

            // REGISTER RESOURCE PROVIDER
            var providers = resourceProvidersName.Split(';');

            foreach (var resourceProviderName in providers)
            {
                var resourceProvider = await resourceController.RegisterResourceProvider(resourceProviderName);

                // VALIDATION
                Assert.Equal("OK", resourceProvider.Response.ReasonPhrase, ignoreCase: true);
                Assert.NotNull(resourceProvider.Body);
                Assert.Equal("registered", resourceProvider.Body.RegistrationState, ignoreCase: true);
            }
        }