public async Task List()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-2.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            ProfileResource cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpointResource cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = Recording.GenerateAssetName("customDomain-");
            string hostName            = "customdomaintest-2.azuretest.net";

            _ = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

            int count = 0;

            await foreach (var tempCustomDomain in cdnEndpoint.GetCdnCustomDomains().GetAllAsync())
            {
                if (tempCustomDomain.Data.HostName.Equals("customdomaintest-2.azuretest.net"))
                {
                    count++;
                }
            }
            Assert.AreEqual(count, 1);
        }
Exemplo n.º 2
0
        protected async Task <CdnCustomDomainResource> CreateCdnCustomDomain(CdnEndpointResource endpoint, string customDomainName, string hostName)
        {
            CustomDomainOptions input = ResourceDataHelper.CreateCdnCustomDomainData(hostName);
            var lro = await endpoint.GetCdnCustomDomains().CreateOrUpdateAsync(WaitUntil.Completed, customDomainName, input);

            return(lro.Value);
        }
        public async Task Get()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-3.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            ProfileResource cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpointResource cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = Recording.GenerateAssetName("customDomain-");
            string hostName            = "customdomaintest-3.azuretest.net";
            CdnCustomDomainResource cdnCustomDomain = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

            CdnCustomDomainResource getCdnCustomDomain = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            ResourceDataHelper.AssertValidCustomDomain(cdnCustomDomain, getCdnCustomDomain);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnCustomDomains().GetAsync(null));
        }
Exemplo n.º 4
0
        public async Task Disable()
        {
            //In this test, the CName mapping from custom domain "customdomaintest5.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            ProfileResource cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpointResource cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = "customdomaintest5-azuretest-net";
            CdnCustomDomainResource cdnCustomDomain = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            var lro = await cdnCustomDomain.DisableCustomHttpsAsync(WaitUntil.Completed);

            CdnCustomDomainResource disabledCdnCustomDomain = lro.Value;

            Assert.AreEqual(disabledCdnCustomDomain.Data.CustomHttpsProvisioningState, CustomHttpsProvisioningState.Disabled);
        }
        public async Task EnableAndDisable()
        {
            //In this test, the CName mapping from custom domain "customdomaintest5.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            ProfileResource cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpointResource cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = "customdomaintest5-azuretest-net";
            var    lro = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            CdnCustomDomainResource cdnCustomDomain = lro.Value;

            Assert.ThrowsAsync <RequestFailedException>(async() => await cdnCustomDomain.DisableCustomHttpsAsync());
            CdnManagedHttpsOptions  customDomainHttpsOptions = new CdnManagedHttpsOptions(ProtocolType.ServerNameIndication, new CdnCertificateSourceParameters(CdnCertificateSourceParametersTypeName.CdnCertificateSourceParameters, CertificateType.Dedicated));
            CdnCustomDomainResource enabledCdnCustomDomain   = await cdnCustomDomain.EnableCustomHttpsAsync(customDomainHttpsOptions);

            Assert.AreEqual(enabledCdnCustomDomain.Data.CustomHttpsProvisioningState, CustomHttpsProvisioningState.Enabling);
        }
        public async Task Delete()
        {
            //In this test, the CName mapping from custom domain "customdomaintest4.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            //The CName mapping needs to be deleted before deleting the custom domain.
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            ProfileResource cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpointResource cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = "customdomaintest4-azuretest-net";
            var    lro = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            CdnCustomDomainResource cdnCustomDomain = lro.Value;
            await cdnCustomDomain.DeleteAsync(WaitUntil.Completed);

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await cdnCustomDomain.GetAsync());

            Assert.AreEqual(404, ex.Status);
        }