2016-06-03 09:57:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  boto3  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  botocore . exceptions  import  ClientError  
						 
					
						
							
								
									
										
										
										
											2013-11-14 11:14:14 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 19:44:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  sure   # noqa # pylint: disable=unused-import  
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  botocore  
						 
					
						
							
								
									
										
										
										
											2020-10-06 07:54:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  pytest  
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  moto  import  mock_ec2 ,  mock_route53  
						 
					
						
							
								
									
										
										
										
											2013-11-14 11:14:14 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_create_hosted_zone ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    firstzone  =  response [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    firstzone . should . have . key ( " Id " ) . match ( r " /hostedzone/[A-Z0-9]+ " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    firstzone . should . have . key ( " Name " ) . equal ( " testdns.aws.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    firstzone . should . have . key ( " Config " ) . equal ( { " PrivateZone " :  False } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    firstzone . should . have . key ( " ResourceRecordSetCount " ) . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delegation  =  response [ " DelegationSet " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    delegation . should . have . key ( " NameServers " ) . length_of ( 4 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delegation [ " NameServers " ] . should . contain ( " ns-2048.awsdns-64.com " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delegation [ " NameServers " ] . should . contain ( " ns-2049.awsdns-65.net " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delegation [ " NameServers " ] . should . contain ( " ns-2050.awsdns-66.org " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delegation [ " NameServers " ] . should . contain ( " ns-2051.awsdns-67.co.uk " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_hosted_zones ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res  =  conn . list_hosted_zones ( ) [ " HostedZones " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res . should . have . length_of ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone1  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns1.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone2  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns2.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res  =  conn . list_hosted_zones ( ) [ " HostedZones " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res . should . have . length_of ( 2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res . should . contain ( zone1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res . should . contain ( zone2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_delete_hosted_zone ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone1  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns1.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( Name = " testdns2.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . delete_hosted_zone ( Id = zone1 [ " Id " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res  =  conn . list_hosted_zones ( ) [ " HostedZones " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    res . should . have . length_of ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 17:53:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_delete_hosted_zone_with_change_sets ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " foo.bar.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 1.2.3.4 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . delete_hosted_zone ( Id = zone_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " HostedZoneNotEmpty " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " The hosted zone contains resource records that are not SOA or NS records. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 08:25:36 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_hosted_zone_count_no_zones ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count  =  conn . get_hosted_zone_count ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count . should . have . key ( " HostedZoneCount " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isinstance ( zone_count [ " HostedZoneCount " ] ,  int ) . should . be . true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count [ " HostedZoneCount " ] . should . be . equal ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_hosted_zone_count_one_zone ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone  =  " a " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_name  =  f " test. { zone } .com. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = zone_name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = f " test  { zone }  com " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count  =  conn . get_hosted_zone_count ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count . should . have . key ( " HostedZoneCount " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isinstance ( zone_count [ " HostedZoneCount " ] ,  int ) . should . be . true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count [ " HostedZoneCount " ] . should . be . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_hosted_zone_count_many_zones ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_indexes  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  char  in  range ( ord ( " a " ) ,  ord ( " d " )  +  1 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  char2  in  range ( ord ( " a " ) ,  ord ( " z " )  +  1 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            zone_indexes . append ( f " { chr ( char ) } { chr ( char2 ) } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create 100-ish zones and make sure we get 100 back.  This works 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # for 702 zones {a..zz}, but seemed a needless waste of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # time/resources. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  zone  in  zone_indexes : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        zone_name  =  f " test. { zone } .com. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        zones [ zone ]  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            Name = zone_name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneConfig = dict ( PrivateZone = False ,  Comment = f " test  { zone }  com " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count  =  conn . get_hosted_zone_count ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count . should . have . key ( " HostedZoneCount " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    isinstance ( zone_count [ " HostedZoneCount " ] ,  int ) . should . be . true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count [ " HostedZoneCount " ] . shouldnt . be . equal ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_count [ " HostedZoneCount " ] . should . be . equal ( len ( zone_indexes ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_unknown_hosted_zone ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  ex : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . get_hosted_zone ( Id = " unknown " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  ex . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " NoSuchHostedZone " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-08 14:42:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( " No hosted zone found with ID: unknown " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-19 13:43:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_update_hosted_zone_comment ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  response [ " HostedZone " ] [ " Id " ] . split ( " / " ) [ - 1 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . update_hosted_zone_comment ( Id = zone_id ,  Comment = " yolo " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    resp  =  conn . get_hosted_zone ( Id = zone_id ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    resp [ " Config " ] . should . have . key ( " Comment " ) . equals ( " yolo " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_resource_record_set_unknown_zone ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  ex : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . list_resource_record_sets ( HostedZoneId = " abcd " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  ex . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " NoSuchHostedZone " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-08 14:42:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( " No hosted zone found with ID: abcd " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_resource_record_set_unknown_type ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns1.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  ex : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . list_resource_record_sets ( HostedZoneId = zone [ " Id " ] ,  StartRecordType = " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  ex . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " 400 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( " Bad Request " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_use_health_check_in_resource_record_set ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    check  =  conn . create_health_check ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = " ? " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HealthCheckConfig = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " IPAddress " :  " 10.0.0.25 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Port " :  80 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Type " :  " HTTP " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " ResourcePath " :  " / " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " RequestInterval " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " FailureThreshold " :  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HealthCheck " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    check_id  =  check [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  zone [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " foo.bar.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " HealthCheckId " :  check_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 1.2.3.4 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    record_sets  =  conn . list_resource_record_sets ( HostedZoneId = zone_id ) [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " ResourceRecordSets " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    record_sets [ 2 ] [ " Name " ] . should . equal ( " foo.bar.testdns.aws.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    record_sets [ 2 ] [ " HealthCheckId " ] . should . equal ( check_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_hosted_zone_comment_preserved ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    firstzone  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = { " Comment " :  " test comment " } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  firstzone [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone  =  conn . get_hosted_zone ( Id = zone_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone [ " HostedZone " ] [ " Config " ] [ " Comment " ] . should . equal ( " test comment " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zones  =  conn . list_hosted_zones ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zones [ " HostedZones " ] [ 0 ] [ " Config " ] [ " Comment " ] . should . equal ( " test comment " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_deleting_weighted_route ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  zone [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  identifier  in  [ " success-test-foo " ,  " success-test-bar " ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Name " :  " cname.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " SetIdentifier " :  identifier , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Weight " :  50 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id ,  StartRecordName = " cname " ,  StartRecordType = " CNAME " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cnames . should . have . length_of ( 4 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " DELETE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " cname.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  " success-test-foo " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 10:07:30 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        " Weight " :  50 , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id ,  StartRecordName = " cname " ,  StartRecordType = " CNAME " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cnames . should . have . length_of ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames [ - 1 ] [ " Name " ] . should . equal ( " cname.testdns.aws.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames [ - 1 ] [ " SetIdentifier " ] . should . equal ( " success-test-bar " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_deleting_latency_route ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  zone [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  _id ,  region  in  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " success-test-foo " ,  " us-west-2 " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " success-test-bar " ,  " us-west-1 " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Name " :  " cname.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " SetIdentifier " :  _id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Region " :  region , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " ResourceRecords " :  [ { " Value " :  " example.com " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id ,  StartRecordName = " cname " ,  StartRecordType = " CNAME " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cnames . should . have . length_of ( 4 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    foo_cname  =  [ 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 01:03:17 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        cname 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  cname  in  cnames 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  cname . get ( " SetIdentifier " )  and  cname [ " SetIdentifier " ]  ==  " success-test-foo " 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ] [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    foo_cname [ " Region " ] . should . equal ( " us-west-2 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " DELETE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " cname.testdns.aws.com " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  " success-test-foo " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 10:07:30 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        " Region " :  " us-west-2 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " example.com " } ] , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = zone_id ,  StartRecordName = " cname " ,  StartRecordType = " CNAME " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cnames . should . have . length_of ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames [ - 1 ] [ " SetIdentifier " ] . should . equal ( " success-test-bar " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cnames [ - 1 ] [ " Region " ] . should . equal ( " us-west-1 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 10:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_or_change_tags_for_resource_request ( ) :  
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 19:43:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    health_check  =  conn . create_health_check ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = " foobar " , 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 19:43:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HealthCheckConfig = { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " IPAddress " :  " 192.0.2.44 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Port " :  123 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Type " :  " HTTP " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " ResourcePath " :  " / " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " RequestInterval " :  30 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " FailureThreshold " :  123 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " HealthThreshold " :  123 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 19:43:48 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    healthcheck_id  =  health_check [ " HealthCheck " ] [ " Id " ] 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-28 13:55:19 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # confirm this works for resources with zero tags 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should . equal ( [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-28 13:55:19 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    tag1  =  { " Key " :  " Deploy " ,  " Value " :  " True " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    tag2  =  { " Key " :  " Name " ,  " Value " :  " UnitTest " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Test adding a tag for a resource id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id ,  AddTags = [ tag1 ,  tag2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Check to make sure that the response has the 'ResourceTagSet' key 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 21:37:43 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response  =  conn . list_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . contain ( " ResourceTagSet " ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Validate that each key was added 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should . contain ( tag1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should . contain ( tag2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceTagSet " ] [ " Tags " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-22 18:44:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Try to remove the tags 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceId = healthcheck_id , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        RemoveTagKeys = [ tag1 [ " Key " ] ] , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Check to make sure that the response has the 'ResourceTagSet' key 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 21:37:43 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response  =  conn . list_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . contain ( " ResourceTagSet " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should_not . contain ( tag1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should . contain ( tag2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Remove the second tag 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceId = healthcheck_id , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        RemoveTagKeys = [ tag2 [ " Key " ] ] , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 21:37:43 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response  =  conn . list_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should_not . contain ( tag2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Re-add the tags 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id ,  AddTags = [ tag1 ,  tag2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Remove both 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceId = healthcheck_id , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        RemoveTagKeys = [ tag1 [ " Key " ] ,  tag2 [ " Key " ] ] , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-20 17:41:23 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-02-23 21:37:43 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response  =  conn . list_tags_for_resource ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ResourceType = " healthcheck " ,  ResourceId = healthcheck_id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response [ " ResourceTagSet " ] [ " Tags " ] . should . equal ( [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_ec2  
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_hosted_zones_by_name ( ) :  
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create mock VPC so we can get a VPC ID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ec2c  =  boto3 . client ( " ec2 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    vpc_id  =  ec2c . create_vpc ( CidrBlock = " 10.1.0.0/16 " ) . get ( " Vpc " ) . get ( " VpcId " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    region  =  " us-east-1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = region ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        Name = " test.b.com. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = True ,  Comment = " test com " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VPC = { " VPCRegion " :  region ,  " VPCId " :  vpc_id } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b  =  conn . list_hosted_zones_by_name ( DNSName = " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zone_b [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b [ " HostedZones " ] [ 0 ] . should . have . key ( " Config " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b [ " HostedZones " ] [ 0 ] [ " Config " ] . should . have . key ( " PrivateZone " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b [ " HostedZones " ] [ 0 ] [ " Config " ] [ " PrivateZone " ] . should . be . equal ( True ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # We declared this a a private hosted zone above, so let's make 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # sure it really is! 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_b_id  =  zone_b [ " HostedZones " ] [ 0 ] [ " Id " ] . split ( " / " ) [ - 1 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hosted_zone  =  conn . get_hosted_zone ( Id = zone_b_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Pull the HostedZone block out and test it. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hosted_zone . should . have . key ( " HostedZone " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz  =  b_hosted_zone [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz . should . have . key ( " Config " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz [ " Config " ] . should . have . key ( " PrivateZone " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz [ " Config " ] [ " PrivateZone " ] . should . be . equal ( True ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Check for the VPCs block since this *should* be a VPC-Private Zone 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hosted_zone . should . have . key ( " VPCs " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hosted_zone [ " VPCs " ] . should . have . length_of ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz_vpcs  =  b_hosted_zone [ " VPCs " ] [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz_vpcs . should . have . key ( " VPCId " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz_vpcs . should . have . key ( " VPCRegion " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 20:44:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    b_hz_vpcs [ " VPCId " ] . should_not . equal ( " " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz_vpcs [ " VPCRegion " ] . should_not . equal ( " " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    b_hz_vpcs [ " VPCId " ] . should . be . equal ( vpc_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    b_hz_vpcs [ " VPCRegion " ] . should . be . equal ( region ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Now create other zones and test them. 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " test.a.org. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " bar " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test org " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " test.a.org. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " bar " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test org 2 " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Now makes sure the other zones we created above are NOT private... 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] . should . have . key ( " Config " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Config " ] . should . have . key ( " PrivateZone " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Config " ] [ " PrivateZone " ] . should . be . equal ( False ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] . should . have . key ( " Config " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] [ " Config " ] . should . have . key ( " PrivateZone " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] [ " Config " ] [ " PrivateZone " ] . should . be . equal ( False ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-13 14:09:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # test sort order 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 2 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 06:58:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_hosted_zones_by_dns_name ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " test.b.com. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test com " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 06:58:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " test.a.org. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " bar " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test org " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 06:58:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " test.a.org. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " bar " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test org 2 " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 06:58:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " my.test.net. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " baz " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " test net " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # test lookup 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " DNSName " ] . should . equal ( " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " DNSName " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " DNSName " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " my.test.net. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " DNSName " ] . should . equal ( " my.test.net. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " my.test.net " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " DNSName " ] . should . equal ( " my.test.net. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # test sort order 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 4 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " test.b.com. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 1 ] [ " Name " ] . should . equal ( " my.test.net. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 2 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 3 ] [ " Name " ] . should . equal ( " test.a.org. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_sets_crud_valid ( ) :  
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create A Record. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_endpoint_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " Create A record prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = a_record_endpoint_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    a_record_detail [ " Name " ] . should . equal ( " prod.redis.db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " Type " ] . should . equal ( " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " TTL " ] . should . equal ( 10 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " ResourceRecords " ] . should . equal ( [ { " Value " :  " 127.0.0.1 " } ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-02-27 10:54:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Update A Record. 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cname_record_endpoint_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " Update A record prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  60 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 192.168.1.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = cname_record_endpoint_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cname_record_detail [ " Name " ] . should . equal ( " prod.redis.db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " Type " ] . should . equal ( " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " TTL " ] . should . equal ( 60 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " ResourceRecords " ] . should . equal ( [ { " Value " :  " 192.168.1.1 " } ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Update to add Alias. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_alias_record_endpoint_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " Update to Alias prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  60 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " AliasTarget " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " HostedZoneId " :  hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " DNSName " :  " prod.redis.alias. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " EvaluateTargetHealth " :  False , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = cname_alias_record_endpoint_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cname_alias_record_detail  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cname_alias_record_detail [ " Name " ] . should . equal ( " prod.redis.db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_alias_record_detail [ " Type " ] . should . equal ( " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_alias_record_detail [ " TTL " ] . should . equal ( 60 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_alias_record_detail [ " AliasTarget " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " HostedZoneId " :  hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " DNSName " :  " prod.redis.alias. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " EvaluateTargetHealth " :  False , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_alias_record_detail . should_not . contain ( " ResourceRecords " ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-21 21:09:04 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-17 15:53:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Delete record. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delete_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " delete prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-17 15:53:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " DELETE " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 10:07:30 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  60 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 192.168.1.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-17 15:53:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-17 15:53:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = delete_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-17 15:53:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_sets_crud_valid_with_special_xml_chars ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create TXT Record. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    txt_record_endpoint_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Create TXT record prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " TXT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " SomeInitialValue " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = txt_record_endpoint_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    a_record_detail [ " Name " ] . should . equal ( " prod.redis.db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " Type " ] . should . equal ( " TXT " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " TTL " ] . should . equal ( 10 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_detail [ " ResourceRecords " ] . should . equal ( [ { " Value " :  " SomeInitialValue " } ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Update TXT Record with XML Special Character &. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    txt_record_with_special_char_endpoint_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Update TXT record prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " TXT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  60 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " SomeInitialValue&NewValue " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = txt_record_with_special_char_endpoint_payload , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    cname_record_detail [ " Name " ] . should . equal ( " prod.redis.db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " Type " ] . should . equal ( " TXT " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " TTL " ] . should . equal ( 60 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cname_record_detail [ " ResourceRecords " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        [ { " Value " :  " SomeInitialValue&NewValue " } ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Delete record. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    delete_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " delete prod.redis.db " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " DELETE " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 10:07:30 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " TXT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " SomeInitialValue " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = delete_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 02:23:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 10:07:30 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_set__delete_should_match_create ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # To delete a resource record set, you must specify all the same values that you specified when you created it. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    client  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    name  =  " example.com " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  client . create_hosted_zone ( Name = name ,  CallerReference = name ) [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " HostedZone " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    create_call  =  client . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " TTL " :  300 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 192.168.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    waiter  =  client . get_waiter ( " resource_record_sets_changed " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    waiter . wait ( Id = create_call [ " ChangeInfo " ] [ " Id " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        client . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Action " :  " DELETE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Name " :  name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " Type " :  " A " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            # Missing TTL and ResourceRecords 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " InvalidInput " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with [Action=DELETE, Name=example.com, Type=A, SetIdentifier=null] " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_weighted_resource_record_sets ( ) :  
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-2 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        Name = " test.vpc.internal. " ,  CallerReference = str ( hash ( " test " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.vpc.internal. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Create 2 weighted records 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " test.vpc.internal " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  " test1 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Weight " :  50 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " AliasTarget " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " HostedZoneId " :  " Z3AADJGX6KTTL2 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " DNSName " :  " internal-test1lb-447688172.us-east-2.elb.amazonaws.com. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " EvaluateTargetHealth " :  True , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " test.vpc.internal " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  " test2 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Weight " :  50 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " AliasTarget " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " HostedZoneId " :  " Z3AADJGX6KTTL2 " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " DNSName " :  " internal-testlb2-1116641781.us-east-2.elb.amazonaws.com. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " EvaluateTargetHealth " :  True , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    rr_sets  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " ResourceRecordSets " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    record  =  [ r  for  r  in  rr_sets  if  r [ " Type " ]  ==  " A " ] [ 0 ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Update the first record to have a weight of 90 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  record [ " Name " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  record [ " Type " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  record [ " SetIdentifier " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Weight " :  90 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " AliasTarget " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " HostedZoneId " :  record [ " AliasTarget " ] [ " HostedZoneId " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " DNSName " :  record [ " AliasTarget " ] [ " DNSName " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " EvaluateTargetHealth " :  record [ " AliasTarget " ] [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                " EvaluateTargetHealth " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    record  =  [ r  for  r  in  rr_sets  if  r [ " Type " ]  ==  " A " ] [ 1 ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Update the second record to have a weight of 10 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  record [ " Name " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  record [ " Type " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " SetIdentifier " :  record [ " SetIdentifier " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Weight " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " AliasTarget " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " HostedZoneId " :  record [ " AliasTarget " ] [ " HostedZoneId " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " DNSName " :  record [ " AliasTarget " ] [ " DNSName " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " EvaluateTargetHealth " :  record [ " AliasTarget " ] [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                " EvaluateTargetHealth " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  record  in  response [ " ResourceRecordSets " ] : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 01:03:17 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  record . get ( " SetIdentifier " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  record [ " SetIdentifier " ]  ==  " test1 " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                record [ " Weight " ] . should . equal ( 90 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  record [ " SetIdentifier " ]  ==  " test2 " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                record [ " Weight " ] . should . equal ( 10 ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 16:37:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_failover_record_sets ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-2 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( Name = " test.zone. " ,  CallerReference = str ( hash ( " test " ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.zone. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create geolocation record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " failover.test.zone. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        " Failover " :  " PRIMARY " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    record  =  response [ " ResourceRecordSets " ] [ 2 ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    record [ " Failover " ] . should . equal ( " PRIMARY " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_geolocation_record_sets ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-2 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( Name = " test.zone. " ,  CallerReference = str ( hash ( " test " ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " test.zone. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create geolocation record 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " georecord1.test.zone. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        " GeoLocation " :  { " ContinentCode " :  " EU " } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  " georecord2.test.zone. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 127.0.0.2 " } ] , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        " GeoLocation " :  { " CountryCode " :  " US " ,  " SubdivisionCode " :  " NY " } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 13:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    rrs  =  response [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    rrs [ 2 ] [ " GeoLocation " ] . should . equal ( { " ContinentCode " :  " EU " } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    rrs [ 3 ] [ " GeoLocation " ] . should . equal ( { " CountryCode " :  " US " ,  " SubdivisionCode " :  " NY " } ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 12:46:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_invalid ( ) :  
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    invalid_a_record_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " this should fail " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.scooby.doo " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-06 07:54:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    with  pytest . raises ( botocore . exceptions . ClientError ) : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id ,  ChangeBatch = invalid_a_record_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    invalid_cname_record_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " this should also fail " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.scooby.doo " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-06 07:54:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    with  pytest . raises ( botocore . exceptions . ClientError ) : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id ,  ChangeBatch = invalid_cname_record_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-28 21:26:32 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 16:22:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_invalid_action_value ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    invalid_a_record_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " this should fail " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " INVALID_ACTION " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  " prod.scooby.doo " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( botocore . exceptions . ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id ,  ChangeBatch = invalid_a_record_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " InvalidInput " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Invalid XML ; cvc-enumeration-valid: Value  ' INVALID_ACTION '  is not facet-valid " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        "  with respect to enumeration  ' [CREATE, DELETE, UPSERT] ' . It must be a value from the enumeration. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 16:22:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 22:35:20 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
									
										
										
										
											2022-12-22 00:38:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  test_change_resource_record_set_create__should_fail_when_record_already_exists ( ) :  
						 
					
						
							
								
									
										
										
										
											2022-11-30 22:35:20 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ZONE  =  " cname.local " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    FQDN  =  f " test. { ZONE } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    FQDN_TARGET  =  " develop.domain.com " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    client  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zone_id  =  client . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = ZONE ,  CallerReference = " ref " ,  DelegationSetId = " string " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    changes  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  FQDN , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  600 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  FQDN_TARGET } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    client . change_resource_record_sets ( HostedZoneId = zone_id ,  ChangeBatch = changes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        client . change_resource_record_sets ( HostedZoneId = zone_id ,  ChangeBatch = changes ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 00:38:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 22:35:20 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " InvalidChangeBatch " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 00:38:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Tried to create resource record set [name= ' test.cname.local. ' , type= ' CNAME ' ] but it already exists " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_set__should_create_record_when_using_upsert ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    route53_client  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone  =  route53_client . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " example.com " ,  CallerReference = " irrelevant " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    resource_record  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Name " :  " test.example.com. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Type " :  " CNAME " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " TTL " :  60 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " ResourceRecords " :  [ { " Value " :  " www.test.example.com " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    route53_client . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone [ " Id " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ { " Action " :  " UPSERT " ,  " ResourceRecordSet " :  resource_record } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  route53_client . list_resource_record_sets ( HostedZoneId = hosted_zone [ " Id " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # The 1st and 2nd records are NS and SOA records, respectively. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceRecordSets " ] [ 2 ] . should . equal ( resource_record ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # a subsequest UPSERT with the same ChangeBatch should succeed as well 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    route53_client . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone [ " Id " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ChangeBatch = { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Changes " :  [ { " Action " :  " UPSERT " ,  " ResourceRecordSet " :  resource_record } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  route53_client . list_resource_record_sets ( HostedZoneId = hosted_zone [ " Id " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # The 1st and 2nd records are NS and SOA records, respectively. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( response [ " ResourceRecordSets " ] ) . should . equal ( 3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ResourceRecordSets " ] [ 2 ] . should . equal ( resource_record ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 22:35:20 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_resource_record_sets_name_type_filters ( ) :  
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    create_hosted_zone_response  =  conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    hosted_zone_id  =  create_hosted_zone_response [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def  create_resource_record_set ( rec_type ,  rec_name ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-17 21:41:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " Comment " :  f " create  { rec_type }  record  { rec_name } " , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            " Changes " :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Name " :  rec_name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " Type " :  rec_type , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id ,  ChangeBatch = payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # record_type, record_name 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    all_records  =  [ 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( " A " ,  " a.a.db. " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " A " ,  " a.b.db. " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " A " ,  " b.b.db. " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " CNAME " ,  " b.b.db. " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " CNAME " ,  " b.c.db. " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( " CNAME " ,  " c.c.db. " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  record_type ,  record_name  in  all_records : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        create_resource_record_set ( record_type ,  record_name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    start_with  =  2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StartRecordType = all_records [ start_with ] [ 0 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        StartRecordName = all_records [ start_with ] [ 1 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-27 18:53:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response [ " IsTruncated " ] . should . equal ( False ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 08:44:26 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    returned_records  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( record [ " Type " ] ,  record [ " Name " ] )  for  record  in  response [ " ResourceRecordSets " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ] 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-23 17:25:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    len ( returned_records ) . should . equal ( len ( all_records )  -  start_with ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  desired_record  in  all_records [ start_with : ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        returned_records . should . contain ( desired_record ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-20 07:21:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_change ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-2 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    change_id  =  " 123456 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . get_change ( Id = change_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ChangeInfo " ] [ " Id " ] . should . equal ( change_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response [ " ChangeInfo " ] [ " Status " ] . should . equal ( " INSYNC " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_change_resource_record_sets_records_limit ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 06:28:31 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = False ,  Comment = " db " ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Changes creating exactly 1,000 resource records. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    changes  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ci  in  range ( 4 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        resourcerecords  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  rri  in  range ( 250 ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-17 21:41:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            resourcerecords . append ( { " Value " :  f " 127.0.0. { rri } " } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        changes . append ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-17 21:41:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Name " :  f " foo { ci } .db. " , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  resourcerecords , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    create_1000_resource_records_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Create four records with 250 resource records each " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  changes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = create_1000_resource_records_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Changes creating over 1,000 resource records. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    too_many_changes  =  create_1000_resource_records_payload [ " Changes " ] . copy ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    too_many_changes . append ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Name " :  " toomany.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    create_1001_resource_records_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Create four records with 250 resource records each, plus one more " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  too_many_changes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ChangeBatch = create_1001_resource_records_payload , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " InvalidChangeBatch " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Changes upserting exactly 500 resource records. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    changes  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ci  in  range ( 2 ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        resourcerecords  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  rri  in  range ( 250 ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-17 21:41:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            resourcerecords . append ( { " Value " :  f " 127.0.0. { rri } " } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        changes . append ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-17 21:41:08 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Name " :  f " foo { ci } .db. " , 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-10 08:47:27 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  resourcerecords , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    upsert_500_resource_records_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Upsert two records with 250 resource records each " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  changes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = upsert_500_resource_records_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Changes upserting over 1,000 resource records. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    too_many_changes  =  upsert_500_resource_records_payload [ " Changes " ] . copy ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    too_many_changes . append ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " Action " :  " UPSERT " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Name " :  " toomany.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    upsert_501_resource_records_payload  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Comment " :  " Upsert two records with 250 resource records each, plus one more " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " Changes " :  too_many_changes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  pytest . raises ( ClientError )  as  exc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HostedZoneId = hosted_zone_id ,  ChangeBatch = upsert_501_resource_records_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err  =  exc . value . response [ " Error " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Code " ] . should . equal ( " InvalidChangeBatch " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    err [ " Message " ] . should . equal ( " Number of records limit of 1000 exceeded. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_list_resource_recordset_pagination ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        CallerReference = str ( hash ( " foo " ) ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneConfig = dict ( PrivateZone = True ,  Comment = " db " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones  =  conn . list_hosted_zones_by_name ( DNSName = " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    len ( zones [ " HostedZones " ] ) . should . equal ( 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    zones [ " HostedZones " ] [ 0 ] [ " Name " ] . should . equal ( " db. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  zones [ " HostedZones " ] [ 0 ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Create A Record. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    a_record_endpoint_payload  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:58:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Comment " :  " Create 500 A records " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        " Changes " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " Action " :  " CREATE " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " ResourceRecordSet " :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Name " :  f " env { idx } .redis.db. " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " Type " :  " A " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " TTL " :  10 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " ResourceRecords " :  [ { " Value " :  " 127.0.0.1 " } ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  idx  in  range ( 500 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    conn . change_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  ChangeBatch = a_record_endpoint_payload 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id ,  MaxItems = " 100 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " ResourceRecordSets " ) . length_of ( 100 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " IsTruncated " ) . equals ( True ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " MaxItems " ) . equals ( " 100 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " NextRecordName " ) . equals ( " env187.redis.db. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " NextRecordType " ) . equals ( " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StartRecordName = response [ " NextRecordName " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StartRecordType = response [ " NextRecordType " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " ResourceRecordSets " ) . length_of ( 300 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " IsTruncated " ) . equals ( True ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " MaxItems " ) . equals ( " 300 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " NextRecordName " ) . equals ( " env457.redis.db. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " NextRecordType " ) . equals ( " A " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response  =  conn . list_resource_record_sets ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        HostedZoneId = hosted_zone_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StartRecordName = response [ " NextRecordName " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StartRecordType = response [ " NextRecordType " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 15:58:55 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " ResourceRecordSets " ) . length_of ( 102 ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-30 23:53:05 -01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    response . should . have . key ( " IsTruncated " ) . equals ( False ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . should . have . key ( " MaxItems " ) . equals ( " 300 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . shouldnt . have . key ( " NextRecordName " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    response . shouldnt . have . key ( " NextRecordType " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-19 13:43:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								@mock_route53  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  test_get_dns_sec ( ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    client  =  boto3 . client ( " route53 " ,  region_name = " us-east-1 " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    hosted_zone_id  =  client . create_hosted_zone ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Name = " testdns.aws.com. " ,  CallerReference = str ( hash ( " foo " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ) [ " HostedZone " ] [ " Id " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    dns_sec  =  client . get_dnssec ( HostedZoneId = hosted_zone_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    dns_sec . should . have . key ( " Status " ) . equals ( { " ServeSignature " :  " NOT_SIGNING " } )