-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sure # noqa # pylint: disable=unused-import | ||
import xmltodict | ||
|
||
import moto.server as server | ||
|
||
|
||
def test_list_recordset(): | ||
backend = server.create_backend_app("route53") | ||
test_client = backend.test_client() | ||
|
||
# create hosted zone | ||
request_data = '<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><Name>example.com</Name><CallerReference>2014-04-01-18:47</CallerReference></CreateHostedZoneRequest>' | ||
res = test_client.post("2013-04-01/hostedzone", data=request_data) | ||
body = parse_xml(res.data) | ||
zone_id = body["CreateHostedZoneResponse"]["HostedZone"]["Id"].rsplit("/")[-1] | ||
|
||
# change record set | ||
# Contains a special character | ||
request_data = '<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><ChangeBatch><Changes><Change><Action>CREATE</Action><ResourceRecordSet><Name>n.example.com</Name><Type>TXT</Type><SetIdentifier>string</SetIdentifier><Weight>1</Weight><Region>us-east-1</Region><ResourceRecords><ResourceRecord><Value>val&sth</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>' | ||
test_client.post(f"2013-04-01/hostedzone/{zone_id}/rrset/", data=request_data) | ||
|
||
# list record set | ||
res = test_client.get(f"2013-04-01/hostedzone/{zone_id}/rrset") | ||
# Ampersand should be properly encoded | ||
res.data.decode("utf-8").should.contain("<Value><![CDATA[val&sth]]></Value>") | ||
|
||
|
||
def parse_xml(body): | ||
return xmltodict.parse(body, dict_constructor=dict) |