Route53 Delete: respect the given Type
This commit is contained in:
parent
df493ea18d
commit
6e97881896
@ -190,9 +190,13 @@ class FakeZone(BaseModel):
|
||||
self.rrsets.append(new_rrset)
|
||||
return new_rrset
|
||||
|
||||
def delete_rrset_by_name(self, name):
|
||||
def delete_rrset(self, rrset):
|
||||
self.rrsets = [
|
||||
record_set for record_set in self.rrsets if record_set.name != name]
|
||||
record_set
|
||||
for record_set in self.rrsets
|
||||
if record_set.name != rrset['Name'] or
|
||||
record_set.type_ != rrset['Type']
|
||||
]
|
||||
|
||||
def delete_rrset_by_id(self, set_identifier):
|
||||
self.rrsets = [
|
||||
|
@ -147,7 +147,7 @@ class Route53(BaseResponse):
|
||||
the_zone.delete_rrset_by_id(
|
||||
record_set["SetIdentifier"])
|
||||
else:
|
||||
the_zone.delete_rrset_by_name(record_set["Name"])
|
||||
the_zone.delete_rrset(record_set)
|
||||
|
||||
return 200, headers, CHANGE_RRSET_RESPONSE
|
||||
|
||||
|
@ -110,6 +110,7 @@ def test_rrset():
|
||||
|
||||
changes = ResourceRecordSets(conn, zoneid)
|
||||
changes.add_change("DELETE", "foo.bar.testdns.aws.com", "A")
|
||||
changes.add_change("DELETE", "foo.bar.testdns.aws.com", "TXT")
|
||||
changes.commit()
|
||||
|
||||
changes = ResourceRecordSets(conn, zoneid)
|
||||
@ -582,7 +583,7 @@ def test_change_resource_record_sets_crud_valid():
|
||||
cname_record_detail['TTL'].should.equal(60)
|
||||
cname_record_detail['ResourceRecords'].should.equal([{'Value': '192.168.1.1'}])
|
||||
|
||||
# Delete record.
|
||||
# Delete record with wrong type.
|
||||
delete_payload = {
|
||||
'Comment': 'delete prod.redis.db',
|
||||
'Changes': [
|
||||
@ -597,6 +598,23 @@ def test_change_resource_record_sets_crud_valid():
|
||||
}
|
||||
conn.change_resource_record_sets(HostedZoneId=hosted_zone_id, ChangeBatch=delete_payload)
|
||||
response = conn.list_resource_record_sets(HostedZoneId=hosted_zone_id)
|
||||
len(response['ResourceRecordSets']).should.equal(1)
|
||||
|
||||
# Delete record.
|
||||
delete_payload = {
|
||||
'Comment': 'delete prod.redis.db',
|
||||
'Changes': [
|
||||
{
|
||||
'Action': 'DELETE',
|
||||
'ResourceRecordSet': {
|
||||
'Name': 'prod.redis.db',
|
||||
'Type': 'A',
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
conn.change_resource_record_sets(HostedZoneId=hosted_zone_id, ChangeBatch=delete_payload)
|
||||
response = conn.list_resource_record_sets(HostedZoneId=hosted_zone_id)
|
||||
len(response['ResourceRecordSets']).should.equal(0)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user