public void VPCTests() { var vpc1 = CreateVPC(); var vpc2 = CreateVPC(); string createdZoneId = null; try { CreateHostedZoneRequest createRequest = new CreateHostedZoneRequest { Name = ZONE_NAME, CallerReference = CALLER_REFERENCE, HostedZoneConfig = new HostedZoneConfig { Comment = COMMENT }, VPC = vpc1 }; createdZoneId = UtilityMethods.WaitUntilSuccess <string>(() => Client.CreateHostedZoneAsync(createRequest).Result.HostedZone.Id ); var hostedZoneInfo = Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }).Result; Assert.NotNull(hostedZoneInfo.VPCs); Assert.Equal(1, hostedZoneInfo.VPCs.Count); Assert.True(hostedZoneInfo.HostedZone.Config.PrivateZone); var changeInfo = Client.AssociateVPCWithHostedZoneAsync(new AssociateVPCWithHostedZoneRequest { VPC = vpc2, Comment = COMMENT, HostedZoneId = createdZoneId }).Result.ChangeInfo; Assert.NotNull(changeInfo); Assert.NotNull(changeInfo.Comment); assertValidChangeInfo(changeInfo); hostedZoneInfo = Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }).Result; Assert.NotNull(hostedZoneInfo.VPCs); Assert.Equal(2, hostedZoneInfo.VPCs.Count); changeInfo = Client.DisassociateVPCFromHostedZoneAsync(new DisassociateVPCFromHostedZoneRequest { HostedZoneId = createdZoneId, VPC = vpc2 }).Result.ChangeInfo; assertValidChangeInfo(changeInfo); hostedZoneInfo = Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }).Result; Assert.NotNull(hostedZoneInfo.VPCs); Assert.Equal(1, hostedZoneInfo.VPCs.Count); changeInfo = Client.DeleteHostedZoneAsync(new DeleteHostedZoneRequest { Id = createdZoneId }).Result.ChangeInfo; assertValidChangeInfo(changeInfo); } finally { DeleteVPC(vpc1); DeleteVPC(vpc2); DeleteHostedZone(createdZoneId); } }
public void DelegationSetTests() { string createdZoneId = null; try { List <string> createdSets = new List <string>(); var sets = Client.ListReusableDelegationSetsAsync(new ListReusableDelegationSetsRequest()).Result; var setCount = sets.DelegationSets.Count; var callerReference = "DNSMigration" + DateTime.Now.ToFileTime(); var createResponse = Client.CreateReusableDelegationSetAsync(new CreateReusableDelegationSetRequest { CallerReference = callerReference }).Result; Assert.NotNull(createResponse.Location); var delegationSet = createResponse.DelegationSet; Assert.NotNull(delegationSet); Assert.NotNull(delegationSet.CallerReference); Assert.NotNull(delegationSet.Id); Assert.NotNull(delegationSet.NameServers); Assert.NotEqual(0, delegationSet.NameServers.Count); createdSets.Add(delegationSet.Id); sets = Client.ListReusableDelegationSetsAsync(new ListReusableDelegationSetsRequest()).Result; Assert.Equal(setCount + 1, sets.DelegationSets.Count); CreateHostedZoneRequest createRequest = new CreateHostedZoneRequest { Name = ZONE_NAME, CallerReference = CALLER_REFERENCE, HostedZoneConfig = new HostedZoneConfig { Comment = COMMENT }, DelegationSetId = delegationSet.Id }; createdZoneId = UtilityMethods.WaitUntilSuccess <string>(() => Client.CreateHostedZoneAsync(createRequest).Result.HostedZone.Id ); var hostedZoneInfo = Client.GetHostedZoneAsync(new GetHostedZoneRequest { Id = createdZoneId }).Result; Assert.NotNull(hostedZoneInfo.VPCs); Assert.False(hostedZoneInfo.HostedZone.Config.PrivateZone); Assert.Equal(delegationSet.Id, hostedZoneInfo.DelegationSet.Id); var hostedZones = Client.ListHostedZonesAsync(new ListHostedZonesRequest { DelegationSetId = delegationSet.Id }).Result.HostedZones; Assert.Equal(1, hostedZones.Count); // add a second set callerReference = "DNSMigration" + DateTime.Now.ToFileTime(); createResponse = Client.CreateReusableDelegationSetAsync(new CreateReusableDelegationSetRequest { CallerReference = callerReference }).Result; delegationSet = createResponse.DelegationSet; createdSets.Add(delegationSet.Id); int totalSetCount = 0; string nextMarker = null; do { var response = Client.ListReusableDelegationSetsAsync(new ListReusableDelegationSetsRequest { MaxItems = "1", Marker = nextMarker }).Result; totalSetCount += response.DelegationSets.Count; nextMarker = response.NextMarker; } while (!string.IsNullOrEmpty(nextMarker)); Assert.Equal(setCount + 2, totalSetCount); Client.DeleteHostedZoneAsync(new DeleteHostedZoneRequest { Id = createdZoneId }).Wait(); createdZoneId = null; foreach (var setId in createdSets) { Client.DeleteReusableDelegationSetAsync(new DeleteReusableDelegationSetRequest { Id = setId }).Wait(); } sets = Client.ListReusableDelegationSetsAsync(new ListReusableDelegationSetsRequest()).Result; Assert.Equal(setCount, sets.DelegationSets.Count); } finally { DeleteHostedZone(createdZoneId); } }