Skip to content

Commit

Permalink
Fix a bug in the route53 customization that was causing parsing error…
Browse files Browse the repository at this point in the history
…s on JSON bodies.
  • Loading branch information
garnaat committed Oct 23, 2013
1 parent 43df977 commit 86f589f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion awscli/customizations/route53resourceid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def _check_for_resource_id(param, value, **kwargs):
orig_value = value
value = value.split('/')[-1]
logger.debug('ResourceId %s -> %s', orig_value, value)
return value
return value
41 changes: 41 additions & 0 deletions tests/unit/route53/test_resource_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
from tests.unit import BaseAWSCommandParamsTest


CHANGEBATCH_JSON = ('{"Comment":"string","Changes":['
'{"Action":"CREATE","ResourceRecordSet":{'
'"Name":"test-foo.bar.com",'
'"Type":"CNAME",'
'"TTL":300,'
'"ResourceRecords":['
'{"Value":"foo-bar-com.us-west-1.elb.amazonaws.com"}'
']}}]}')

CHANGEBATCH_XML = ('<ChangeResourceRecordSetsRequest '
'xmlns="https://route53.amazonaws.com/doc/2012-12-12/">'
'<ChangeBatch><Comment>string</Comment>'
'<Changes><Change><Action>CREATE</Action>'
'<ResourceRecordSet>'
'<Name>test-foo.bar.com</Name>'
'<Type>CNAME</Type><TTL>300</TTL>'
'<ResourceRecords><ResourceRecord>'
'<Value>foo-bar-com.us-west-1.elb.amazonaws.com</Value>'
'</ResourceRecord></ResourceRecords>'
'</ResourceRecordSet></Change></Changes>'
'</ChangeBatch></ChangeResourceRecordSetsRequest>')

class TestGetHostedZone(BaseAWSCommandParamsTest):

prefix = 'route53 get-hosted-zone'
Expand All @@ -38,6 +60,25 @@ def test_short_resource_id(self):
ignore_params=['payload'])[0]


class TestChangeResourceRecord(BaseAWSCommandParamsTest):

prefix = 'route53 change-resource-record-sets'

def setUp(self):
super(TestChangeResourceRecord, self).setUp()

def test_full_resource_id(self):
args = ' --hosted-zone-id /change/ZD3IYMVP1KDDM'
args += ' --change-batch %s' % CHANGEBATCH_JSON
cmdline = self.prefix + args
result = {'uri_params': {'HostedZoneId': 'ZD3IYMVP1KDDM'},
'headers': {}}
self.assert_params_for_cmd(cmdline, result, expected_rc=0,
ignore_params=['payload'])[0]
self.assertEqual(self.last_params['payload'].getvalue(),
CHANGEBATCH_XML)


class TestGetChange(BaseAWSCommandParamsTest):

prefix = 'route53 get-change'
Expand Down

0 comments on commit 86f589f

Please sign in to comment.