Skip to content

Commit

Permalink
Fix route53 multiple values bug. Closes getmoto#358.
Browse files Browse the repository at this point in the history
  • Loading branch information
spulec committed Jun 6, 2015
1 parent 7ec3f13 commit 57f1199
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion moto/route53/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def rrset_response(request, full_url, headers):
action = value['Action']
record_set = value['ResourceRecordSet']
if action == 'CREATE':
record_set['ResourceRecords'] = [x['Value'] for x in record_set['ResourceRecords'].values()]
resource_records = record_set['ResourceRecords'].values()[0]
if not isinstance(resource_records, list):
# Depending on how many records there are, this may or may not be a list
resource_records = [resource_records]
record_set['ResourceRecords'] = [x['Value'] for x in resource_records]
the_zone.add_rrset(record_set)
elif action == "DELETE":
if 'SetIdentifier' in record_set:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_route53/test_route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ def test_rrset():
rrsets.should.have.length_of(0)


@mock_route53
def test_rrset_with_multiple_values():
conn = boto.connect_route53('the_key', 'the_secret')
zone = conn.create_hosted_zone("testdns.aws.com")
zoneid = zone["CreateHostedZoneResponse"]["HostedZone"]["Id"].split("/")[-1]

changes = ResourceRecordSets(conn, zoneid)
change = changes.add_change("CREATE", "foo.bar.testdns.aws.com", "A")
change.add_value("1.2.3.4")
change.add_value("5.6.7.8")
changes.commit()

rrsets = conn.get_all_rrsets(zoneid, type="A")
rrsets.should.have.length_of(1)
set(rrsets[0].resource_records).should.equal(set(['1.2.3.4', '5.6.7.8']))


@mock_route53
def test_create_health_check():
conn = boto.connect_route53('the_key', 'the_secret')
Expand Down

0 comments on commit 57f1199

Please sign in to comment.