//public static void AssertValidAfdOriginGroup(AfdOriginGroup model, AfdOriginGroup 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);
        //    if (model.Data.LoadBalancingSettings != null || getResult.Data.LoadBalancingSettings != null)
        //    {
        //        Assert.NotNull(model.Data.LoadBalancingSettings);
        //        Assert.NotNull(getResult.Data.LoadBalancingSettings);
        //        Assert.AreEqual(model.Data.LoadBalancingSettings.SampleSize, getResult.Data.LoadBalancingSettings.SampleSize);
        //        Assert.AreEqual(model.Data.LoadBalancingSettings.SuccessfulSamplesRequired, getResult.Data.LoadBalancingSettings.SuccessfulSamplesRequired);
        //        Assert.AreEqual(model.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds, getResult.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds);
        //    }
        //    if (model.Data.HealthProbeSettings != null || getResult.Data.HealthProbeSettings != null)
        //    {
        //        Assert.NotNull(model.Data.HealthProbeSettings);
        //        Assert.NotNull(getResult.Data.HealthProbeSettings);
        //        Assert.AreEqual(model.Data.HealthProbeSettings.ProbeIntervalInSeconds, getResult.Data.HealthProbeSettings.ProbeIntervalInSeconds);
        //        Assert.AreEqual(model.Data.HealthProbeSettings.ProbePath, getResult.Data.HealthProbeSettings.ProbePath);
        //        Assert.AreEqual(model.Data.HealthProbeSettings.ProbeProtocol, getResult.Data.HealthProbeSettings.ProbeProtocol);
        //        Assert.AreEqual(model.Data.HealthProbeSettings.ProbeRequestType, getResult.Data.HealthProbeSettings.ProbeRequestType);
        //    }
        //    Assert.AreEqual(model.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes, getResult.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes);
        //    Assert.AreEqual(model.Data.SessionAffinityState, getResult.Data.SessionAffinityState);
        //    Assert.AreEqual(model.Data.ProvisioningState, getResult.Data.ProvisioningState);
        //    Assert.AreEqual(model.Data.DeploymentStatus, getResult.Data.DeploymentStatus);
        //    //Todo: ResponseBasedAfdOriginErrorDetectionSettings
        //}

        //public static void AssertAfdOriginGroupUpdate(AfdOriginGroup updatedAfdOriginGroup, AfdOriginGroupUpdateOptions updateOptions)
        //{
        //    Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.SampleSize, updateOptions.LoadBalancingSettings.SampleSize);
        //    Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.SuccessfulSamplesRequired, updateOptions.LoadBalancingSettings.SuccessfulSamplesRequired);
        //    Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds, updateOptions.LoadBalancingSettings.AdditionalLatencyInMilliseconds);
        //}

        public static void AssertValidCustomDomain(CdnCustomDomainResource model, CdnCustomDomainResource getResult)
        {
            Assert.AreEqual(model.Data.Name, getResult.Data.Name);
            Assert.AreEqual(model.Data.Id, getResult.Data.Id);
            Assert.AreEqual(model.Data.ResourceType, getResult.Data.ResourceType);
            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);
        }
        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.
            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-1.azuretest.net";
            CdnCustomDomainResource cdnCustomDomain = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

            Assert.AreEqual(cdnCustomDomainName, cdnCustomDomain.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnCustomDomains().CreateOrUpdateAsync(WaitUntil.Completed, cdnCustomDomainName, null));
        }
Ejemplo n.º 3
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 "customdomaintest-5.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-5.azuretest.net";
            CdnCustomDomainResource cdnCustomDomain = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

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

            Assert.DoesNotThrowAsync(async() => await cdnCustomDomain.EnableCustomHttpsAsync(WaitUntil.Completed, customDomainHttpsOptions));
            Assert.DoesNotThrowAsync(async() => await cdnCustomDomain.DisableCustomHttpsAsync(WaitUntil.Completed));
        }
        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);
        }