public static void AssertValidCustomDomain(CdnCustomDomain model, CdnCustomDomain getResult)
 {
     Assert.AreEqual(model.Data.Name, getResult.Data.Name);
     Assert.AreEqual(model.Data.Id, getResult.Data.Id);
     Assert.AreEqual(model.Data.Type, getResult.Data.Type);
     Assert.AreEqual(model.Data.HostName, getResult.Data.HostName);
     Assert.AreEqual(model.Data.ResourceState, getResult.Data.ResourceState);
     Assert.AreEqual(model.Data.CustomHttpsProvisioningState, getResult.Data.CustomHttpsProvisioningState);
     Assert.AreEqual(model.Data.CustomHttpsProvisioningSubstate, getResult.Data.CustomHttpsProvisioningSubstate);
     Assert.AreEqual(model.Data.ValidationData, getResult.Data.ValidationData);
     Assert.AreEqual(model.Data.ProvisioningState, getResult.Data.ProvisioningState);
 }
Example #2
0
        public async Task CreateOrUpdate()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-1.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

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

            Assert.AreEqual(cdnCustomDomainName, cdnCustomDomain.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnCustomDomains().CreateOrUpdateAsync(cdnCustomDomainName, null));
        }
        public async Task EnableAndDisable()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-5.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

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

            Assert.ThrowsAsync <RequestFailedException>(async() => await cdnCustomDomain.DisableCustomHttpsAsync());
            CdnManagedHttpsOptions customDomainHttpsOptions = new CdnManagedHttpsOptions(ProtocolType.ServerNameIndication, new CdnCertificateSourceParameters(CdnCertificateSourceParametersOdataType.MicrosoftAzureCdnModelsCdnCertificateSourceParameters, CertificateType.Dedicated));

            Assert.DoesNotThrowAsync(async() => await cdnCustomDomain.EnableCustomHttpsAsync(customDomainHttpsOptions));
            Assert.DoesNotThrowAsync(async() => await cdnCustomDomain.DisableCustomHttpsAsync());
        }
        public async Task Delete()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-4.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            //The CName mapping needs to be deleted before deleting the custom domain.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

            string cdnCustomDomainName = "customDomain-811";
            var    lro = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            CdnCustomDomain cdnCustomDomain = lro.Value;
            await cdnCustomDomain.DeleteAsync();

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

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