Пример #1
0
        public void DeleteResourceGroupRemovesGroupResources()
        {
            TestUtilities.StartTest();
            var handler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.Created
            };

            var    client            = GetResourceManagementClient(handler);
            string location          = ResourcesManagementTestUtilities.GetResourceLocation(client, "Microsoft.Web/sites");
            var    resourceGroupName = TestUtilities.GenerateName("csmrg");
            var    resourceName      = TestUtilities.GenerateName("csmr");
            var    createResult      = client.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup {
                Location = location
            });
            var createResourceResult = client.Resources.CreateOrUpdate(resourceGroupName, new ResourceIdentity
            {
                ResourceName = resourceName,
                ResourceProviderNamespace = "Microsoft.Web",
                ResourceType = "sites",
                ResourceProviderApiVersion = "2014-04-01"
            },
                                                                       new GenericResource
            {
                Location   = location,
                Properties = "{'name':'" + resourceName + "','siteMode': 'Standard','computeMode':'Shared'}"
            });
            var deleteResult     = client.ResourceGroups.Delete(resourceGroupName);
            var listGroupsResult = client.ResourceGroups.List(null);

            Assert.Throws <CloudException>(() => client.Resources.List(new ResourceListParameters
            {
                ResourceGroupName = resourceGroupName
            }));

            Assert.Equal(HttpStatusCode.OK, deleteResult.StatusCode);
            Assert.False(listGroupsResult.ResourceGroups.Any(rg => rg.Name == resourceGroupName));
            TestUtilities.EndTest();
        }
        public void PublicIpAddressApiTestWithIdletTimeoutAndReverseFqdn()
        {
            var handler1 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            var handler2 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var resourcesClient         = ResourcesManagementTestUtilities.GetResourceManagementClientWithHandler(context, handler1);
                var networkManagementClient = NetworkManagementTestUtilities.GetNetworkManagementClientWithHandler(context, handler2);

                var location = ResourcesManagementTestUtilities.GetResourceLocation(resourcesClient, "Microsoft.Network/publicIPAddresses");

                string resourceGroupName = TestUtilities.GenerateName("csmrg");
                resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                              new ResourceGroup
                {
                    Location = location
                });

                // Create the parameter for PUT PublicIPAddress
                string publicIpName    = TestUtilities.GenerateName();
                string domainNameLabel = TestUtilities.GenerateName();
                string reverseFqdn;

                var publicIp = new PublicIPAddress()
                {
                    Location = location,
                    Tags     = new Dictionary <string, string>()
                    {
                        { "key", "value" }
                    },
                    PublicIPAllocationMethod = IPAllocationMethod.Dynamic,
                    DnsSettings = new PublicIPAddressDnsSettings()
                    {
                        DomainNameLabel = domainNameLabel,
                    },
                    IdleTimeoutInMinutes = 16,
                };

                // Put PublicIPAddress
                var putPublicIpAddressResponse = networkManagementClient.PublicIPAddresses.CreateOrUpdate(resourceGroupName, publicIpName, publicIp);
                Assert.Equal("Succeeded", putPublicIpAddressResponse.ProvisioningState);

                // Get PublicIPAddress
                var getPublicIpAddressResponse = networkManagementClient.PublicIPAddresses.Get(resourceGroupName, publicIpName);

                // Add Reverse FQDN
                reverseFqdn = getPublicIpAddressResponse.DnsSettings.Fqdn;
                getPublicIpAddressResponse.DnsSettings.ReverseFqdn = reverseFqdn;

                putPublicIpAddressResponse = networkManagementClient.PublicIPAddresses.CreateOrUpdate(resourceGroupName, publicIpName, getPublicIpAddressResponse);
                Assert.Equal("Succeeded", putPublicIpAddressResponse.ProvisioningState);

                // Get PublicIPAddress
                getPublicIpAddressResponse = networkManagementClient.PublicIPAddresses.Get(resourceGroupName, publicIpName);
                Assert.Equal(16, getPublicIpAddressResponse.IdleTimeoutInMinutes);
                Assert.Equal(reverseFqdn, getPublicIpAddressResponse.DnsSettings.ReverseFqdn);

                // Get List of PublicIPAddress
                var getPublicIpAddressListResponse = networkManagementClient.PublicIPAddresses.List(resourceGroupName);
                Assert.Single(getPublicIpAddressListResponse);
                ArePublicIpAddressesEqual(getPublicIpAddressResponse, getPublicIpAddressListResponse.First());

                // Get List of PublicIPAddress in a subscription
                var getPublicIpAddressListSubscriptionResponse = networkManagementClient.PublicIPAddresses.ListAll();
                Assert.NotEmpty(getPublicIpAddressListSubscriptionResponse);

                // Delete PublicIPAddress
                networkManagementClient.PublicIPAddresses.Delete(resourceGroupName, publicIpName);

                // Get PublicIPAddress
                getPublicIpAddressListResponse = networkManagementClient.PublicIPAddresses.List(resourceGroupName);
                Assert.Empty(getPublicIpAddressListResponse);
            }
        }
Пример #3
0
 public string GetMySqlLocation(ResourceManagementClient client)
 {
     return(ResourcesManagementTestUtilities.GetResourceLocation(client, "SuccessBricks.ClearDB/databases"));
 }
 public string GetWebsiteLocation(ResourceManagementClient client)
 {
     return(ResourcesManagementTestUtilities.GetResourceLocation(client, "Microsoft.Web/sites"));
 }
Пример #5
0
        public async Task PublicIpAddressApiTestIPv6()
        {
            string resourceGroupName = Recording.GenerateAssetName("csmrg");

            string location = await ResourcesManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/publicIPAddresses");

            await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new ResourceGroup(location));

            // Create the parameter for PUT PublicIPAddress
            string ipv6PublicIpName = Recording.GenerateAssetName("csmipv6publicip");
            string domainNameLabel  = Recording.GenerateAssetName("csmdnslabelpublicip");

            PublicIPAddress ipv6PublicIp = new PublicIPAddress()
            {
                Location = location,
                Tags     = new Dictionary <string, string>()
                {
                    { "key", "value" }
                },
                PublicIPAllocationMethod = IPAllocationMethod.Dynamic,
                DnsSettings = new PublicIPAddressDnsSettings()
                {
                    DomainNameLabel = domainNameLabel
                },
                PublicIPAddressVersion = IPVersion.IPv6
            };

            // Put PublicIPAddress
            PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await NetworkManagementClient.PublicIPAddresses.StartCreateOrUpdateAsync(resourceGroupName, ipv6PublicIpName, ipv6PublicIp);

            Response <PublicIPAddress> putPublicIpAddressResponse = await WaitForCompletionAsync(putPublicIpAddressResponseOperation);

            Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.ProvisioningState.ToString());

            // Get PublicIPAddress
            Response <PublicIPAddress> getPublicIpAddressResponse = await NetworkManagementClient.PublicIPAddresses.GetAsync(resourceGroupName, ipv6PublicIpName);

            Assert.NotNull(getPublicIpAddressResponse);

            Assert.AreEqual(IPVersion.IPv6, getPublicIpAddressResponse.Value.PublicIPAddressVersion);
            Assert.AreEqual(4, getPublicIpAddressResponse.Value.IdleTimeoutInMinutes);
            Assert.NotNull(getPublicIpAddressResponse.Value.ResourceGuid);

            // Get List of PublicIPAddress
            AsyncPageable <PublicIPAddress> getPublicIpAddressListResponseAP = NetworkManagementClient.PublicIPAddresses.ListAsync(resourceGroupName);
            List <PublicIPAddress>          getPublicIpAddressListResponse   = await getPublicIpAddressListResponseAP.ToEnumerableAsync();

            Has.One.EqualTo(getPublicIpAddressListResponse);
            ArePublicIpAddressesEqual(getPublicIpAddressResponse, getPublicIpAddressListResponse.First());

            // Get List of PublicIPAddress in a subscription
            AsyncPageable <PublicIPAddress> getPublicIpAddressListSubscriptionResponseAP = NetworkManagementClient.PublicIPAddresses.ListAllAsync();
            List <PublicIPAddress>          getPublicIpAddressListSubscriptionResponse   = await getPublicIpAddressListSubscriptionResponseAP.ToEnumerableAsync();

            Assert.IsNotEmpty(getPublicIpAddressListSubscriptionResponse);

            // Delete PublicIPAddress
            PublicIPAddressesDeleteOperation deleteOperation = await NetworkManagementClient.PublicIPAddresses.StartDeleteAsync(resourceGroupName, ipv6PublicIpName);

            await WaitForCompletionAsync(deleteOperation);

            // Get PublicIPAddress
            getPublicIpAddressListResponseAP = NetworkManagementClient.PublicIPAddresses.ListAsync(resourceGroupName);
            getPublicIpAddressListResponse   = await getPublicIpAddressListResponseAP.ToEnumerableAsync();

            Assert.IsEmpty(getPublicIpAddressListResponse);

            // Also check IPv4 PublicIP
            // Create the parameter for PUT PublicIPAddress
            string ipv4PublicIpName = Recording.GenerateAssetName("csmipv4publicip");

            PublicIPAddress ipv4PublicIp = new PublicIPAddress()
            {
                Location = location,
                Tags     = new Dictionary <string, string>()
                {
                    { "key", "value" }
                },
                PublicIPAllocationMethod = IPAllocationMethod.Dynamic,
                DnsSettings = new PublicIPAddressDnsSettings()
                {
                    DomainNameLabel = domainNameLabel
                },
                PublicIPAddressVersion = IPVersion.IPv4,
            };

            // Put PublicIPAddress
            PublicIPAddressesCreateOrUpdateOperation putIpv4PublicIpAddressResponseOperation = await NetworkManagementClient.PublicIPAddresses.StartCreateOrUpdateAsync(resourceGroupName, ipv4PublicIpName, ipv4PublicIp);

            Response <PublicIPAddress> putIpv4PublicIpAddressResponse = await WaitForCompletionAsync(putIpv4PublicIpAddressResponseOperation);

            Assert.AreEqual("Succeeded", putIpv4PublicIpAddressResponse.Value.ProvisioningState.ToString());

            // Get PublicIPAddress
            Response <PublicIPAddress> getIpv4PublicIpAddressResponse = await NetworkManagementClient.PublicIPAddresses.GetAsync(resourceGroupName, ipv4PublicIpName);

            Assert.NotNull(getIpv4PublicIpAddressResponse);

            Assert.AreEqual(IPVersion.IPv4, getIpv4PublicIpAddressResponse.Value.PublicIPAddressVersion);
            Assert.AreEqual(4, getIpv4PublicIpAddressResponse.Value.IdleTimeoutInMinutes);
            Assert.NotNull(getIpv4PublicIpAddressResponse.Value.ResourceGuid);

            // Delete PublicIPAddress
            await NetworkManagementClient.PublicIPAddresses.StartDeleteAsync(resourceGroupName, ipv4PublicIpName);
        }
Пример #6
0
        public async Task PublicIpAddressApiTestWithIdletTimeoutAndReverseFqdn()
        {
            string resourceGroupName = Recording.GenerateAssetName("csmrg");

            string location = await ResourcesManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/publicIPAddresses");

            await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new ResourceGroup(location));

            // Create the parameter for PUT PublicIPAddress
            string publicIpName    = Recording.GenerateAssetName("ipname");
            string domainNameLabel = Recording.GenerateAssetName("domain");
            string reverseFqdn;

            PublicIPAddress publicIp = new PublicIPAddress()
            {
                Location = location,
                Tags     = new Dictionary <string, string>()
                {
                    { "key", "value" }
                },
                PublicIPAllocationMethod = IPAllocationMethod.Dynamic,
                DnsSettings = new PublicIPAddressDnsSettings()
                {
                    DomainNameLabel = domainNameLabel,
                },
                IdleTimeoutInMinutes = 16,
            };

            // Put PublicIPAddress
            PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await NetworkManagementClient.PublicIPAddresses.StartCreateOrUpdateAsync(resourceGroupName, publicIpName, publicIp);

            Response <PublicIPAddress> putPublicIpAddressResponse = await WaitForCompletionAsync(putPublicIpAddressResponseOperation);

            Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.ProvisioningState.ToString());

            // Get PublicIPAddress
            Response <PublicIPAddress> getPublicIpAddressResponse = await NetworkManagementClient.PublicIPAddresses.GetAsync(resourceGroupName, publicIpName);

            // Add Reverse FQDN
            reverseFqdn = getPublicIpAddressResponse.Value.DnsSettings.Fqdn;
            getPublicIpAddressResponse.Value.DnsSettings.ReverseFqdn = reverseFqdn;

            putPublicIpAddressResponseOperation = await NetworkManagementClient.PublicIPAddresses.StartCreateOrUpdateAsync(resourceGroupName, publicIpName, getPublicIpAddressResponse);

            putPublicIpAddressResponse = await WaitForCompletionAsync(putPublicIpAddressResponseOperation);

            Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.ProvisioningState.ToString());

            // Get PublicIPAddress
            getPublicIpAddressResponse = await NetworkManagementClient.PublicIPAddresses.GetAsync(resourceGroupName, publicIpName);

            Assert.AreEqual(16, getPublicIpAddressResponse.Value.IdleTimeoutInMinutes);
            Assert.AreEqual(reverseFqdn, getPublicIpAddressResponse.Value.DnsSettings.ReverseFqdn);

            // Get List of PublicIPAddress
            AsyncPageable <PublicIPAddress> getPublicIpAddressListResponseAP = NetworkManagementClient.PublicIPAddresses.ListAsync(resourceGroupName);
            List <PublicIPAddress>          getPublicIpAddressListResponse   = await getPublicIpAddressListResponseAP.ToEnumerableAsync();

            Has.One.EqualTo(getPublicIpAddressListResponse);
            ArePublicIpAddressesEqual(getPublicIpAddressResponse, getPublicIpAddressListResponse.First());

            // Get List of PublicIPAddress in a subscription
            AsyncPageable <PublicIPAddress> getPublicIpAddressListSubscriptionResponseAP = NetworkManagementClient.PublicIPAddresses.ListAllAsync();
            List <PublicIPAddress>          getPublicIpAddressListSubscriptionResponse   = await getPublicIpAddressListSubscriptionResponseAP.ToEnumerableAsync();

            Assert.IsNotEmpty(getPublicIpAddressListSubscriptionResponse);

            // Delete PublicIPAddress
            PublicIPAddressesDeleteOperation deleteOperation = await NetworkManagementClient.PublicIPAddresses.StartDeleteAsync(resourceGroupName, publicIpName);

            await WaitForCompletionAsync(deleteOperation);

            // Get PublicIPAddress
            getPublicIpAddressListResponseAP = NetworkManagementClient.PublicIPAddresses.ListAsync(resourceGroupName);
            getPublicIpAddressListResponse   = await getPublicIpAddressListResponseAP.ToEnumerableAsync();

            Assert.IsEmpty(getPublicIpAddressListResponse);
        }