public async Task Update() { //This test doesn't create a new afd custom domain bucause the update actoin needs to manualy add dns txt record and validate. SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest"); ProfileResource afdProfile = await rg.GetProfiles().GetAsync("testAFDProfile"); FrontDoorCustomDomainResource afdCustomDomain = await afdProfile.GetFrontDoorCustomDomains().GetAsync("customdomain4afd-azuretest-net"); FrontDoorCustomDomainPatch updateOptions = new FrontDoorCustomDomainPatch { TlsSettings = new FrontDoorCustomDomainHttpsContent(FrontDoorCertificateType.ManagedCertificate) { MinimumTlsVersion = FrontDoorMinimumTlsVersion.Tls1_0 }, }; var lro = await afdCustomDomain.UpdateAsync(WaitUntil.Completed, updateOptions); ; FrontDoorCustomDomainResource updatedAfdCustomDomain = lro.Value; ResourceDataHelper.AssertAfdDomainUpdate(updatedAfdCustomDomain, updateOptions); }
public static void AssertValidAfdCustomDomain(FrontDoorCustomDomainResource model, FrontDoorCustomDomainResource 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.TlsSettings.CertificateType, getResult.Data.TlsSettings.CertificateType); Assert.AreEqual(model.Data.TlsSettings.MinimumTlsVersion, getResult.Data.TlsSettings.MinimumTlsVersion); if (model.Data.TlsSettings.Secret != null || getResult.Data.TlsSettings.Secret != null) { Assert.NotNull(model.Data.TlsSettings.Secret); Assert.NotNull(getResult.Data.TlsSettings.Secret); Assert.AreEqual(model.Data.TlsSettings.Secret.Id, getResult.Data.TlsSettings.Secret.Id); } if (model.Data.DnsZone != null || getResult.Data.DnsZone != null) { Assert.NotNull(model.Data.DnsZone); Assert.NotNull(getResult.Data.DnsZone); Assert.AreEqual(model.Data.DnsZone.Id, getResult.Data.DnsZone.Id); } Assert.AreEqual(model.Data.ProvisioningState, getResult.Data.ProvisioningState); Assert.AreEqual(model.Data.DeploymentStatus, getResult.Data.DeploymentStatus); Assert.AreEqual(model.Data.DomainValidationState, getResult.Data.DomainValidationState); Assert.AreEqual(model.Data.HostName, getResult.Data.HostName); if (model.Data.ValidationProperties != null || getResult.Data.ValidationProperties != null) { Assert.NotNull(model.Data.ValidationProperties); Assert.NotNull(getResult.Data.ValidationProperties); Assert.AreEqual(model.Data.ValidationProperties.ValidationToken, getResult.Data.ValidationProperties.ValidationToken); Assert.AreEqual(model.Data.ValidationProperties.ExpiresOn, getResult.Data.ValidationProperties.ExpiresOn); } }
public async Task RefreshVlidationToken() { //This test doesn't create a new afd custom domain bucause the refresh validation token actoin needs to manualy add dns txt record and validate. SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await subscription.GetResourceGroups().GetAsync("CdnTest"); ProfileResource afdProfile = await rg.GetProfiles().GetAsync("testAFDProfile"); FrontDoorCustomDomainResource afdCustomDomain = await afdProfile.GetFrontDoorCustomDomains().GetAsync("customdomain4afd-azuretest-net"); Assert.DoesNotThrowAsync(async() => await afdCustomDomain.RefreshValidationTokenAsync(WaitUntil.Completed)); }
public async Task CreateOrUpdate() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor); string afdCustomDomainName = Recording.GenerateAssetName("AFDCustomDomain-"); string afdHostName = "customdomain4afd-1.azuretest.net"; FrontDoorCustomDomainResource afdCustomDomain = await CreateAfdCustomDomain(afdProfileResource, afdCustomDomainName, afdHostName); Assert.AreEqual(afdCustomDomainName, afdCustomDomain.Data.Name); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetFrontDoorCustomDomains().CreateOrUpdateAsync(WaitUntil.Completed, null, afdCustomDomain.Data)); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetFrontDoorCustomDomains().CreateOrUpdateAsync(WaitUntil.Completed, afdCustomDomainName, null)); }
public async Task Get() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor); string afdCustomDomainName = Recording.GenerateAssetName("AFDCustomDomain-"); string afdHostName = "customdomain4afd-3.azuretest.net"; FrontDoorCustomDomainResource AfdCustomDomain = await CreateAfdCustomDomain(afdProfileResource, afdCustomDomainName, afdHostName); FrontDoorCustomDomainResource getAfdCustomDomain = await afdProfileResource.GetFrontDoorCustomDomains().GetAsync(afdCustomDomainName); ResourceDataHelper.AssertValidAfdCustomDomain(AfdCustomDomain, getAfdCustomDomain); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetFrontDoorCustomDomains().GetAsync(null)); }
public async Task Delete() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); ProfileResource afdProfile = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor); string afdCustomDomainName = Recording.GenerateAssetName("AFDCustomDomain-"); string afdHostName = "customdomain4afd-4.azuretest.net"; FrontDoorCustomDomainResource afdCustomDomain = await CreateAfdCustomDomain(afdProfile, afdCustomDomainName, afdHostName); await afdCustomDomain.DeleteAsync(WaitUntil.Completed); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await afdCustomDomain.GetAsync()); Assert.AreEqual(404, ex.Status); }
public static void AssertAfdDomainUpdate(FrontDoorCustomDomainResource updatedAfdDomain, FrontDoorCustomDomainPatch updateOptions) { Assert.AreEqual(updatedAfdDomain.Data.TlsSettings.CertificateType, updateOptions.TlsSettings.CertificateType); Assert.AreEqual(updatedAfdDomain.Data.TlsSettings.MinimumTlsVersion, updateOptions.TlsSettings.MinimumTlsVersion); }