Skip to content

Commit

Permalink
Merge branch 'takumn-fix-structured-xml-label' into develop
Browse files Browse the repository at this point in the history
* takumn-fix-structured-xml-label:
  Add unittest for #196
  Choose proper XML label for structured payload
  • Loading branch information
jamesls committed Aug 6, 2014
2 parents 9ad9499 + 8db023a commit b1a2d62
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions botocore/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def to_xml(self, value, label=None):
inner_xml = ''
for item in value:
xmlname = self.xmlname
if not xmlname:
if self.members.xmlname:
xmlname = self.members.xmlname
inner_xml += self.members.to_xml(item, xmlname)
if self.flattened:
Expand Down Expand Up @@ -565,7 +565,7 @@ def to_xml(self, value, label=None):
xml += '>'
for member in self.members:
if member.name in value and not hasattr(member, 'xmlattribute'):
xml += member.to_xml(value[member.name], member.name)
xml += member.to_xml(value[member.name], member.get_label())
xml += '</%s>' % label
return xml

Expand Down
31 changes: 31 additions & 0 deletions tests/unit/test_s3_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
'<Status>Enabled</Status><Transition><Days>0</Days>'
'<StorageClass>GLACIER</StorageClass></Transition></Rule>'
'</LifecycleConfiguration>')
PUT_OBJECT_ACL = (
'<AccessControlPolicy><AccessControlList>'
'<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'xsi:type="CanonicalUser"><DisplayName>name</DisplayName><ID>myid</ID>'
'</Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList>'
'<Owner><DisplayName>name</DisplayName><ID>myid</ID>'
'</Owner></AccessControlPolicy>')


POLICY = ('{"Version": "2008-10-17","Statement": [{"Sid": "AddPerm",'
'"Effect": "Allow","Principal": {"AWS": "*"},'
Expand Down Expand Up @@ -323,3 +331,26 @@ def test_complete_multipart_upload(self):
# Explicitly check that <Parts> is not in the payload anywhere.
self.assertNotIn('<Parts>', xml_payload)
self.assertNotIn('</Parts>', xml_payload)

def test_put_object_acl(self):
op = self.s3.get_operation('PutObjectAcl')
params = op.build_parameters(
bucket=self.bucket_name, key=self.key_name,
access_control_policy={
"Owner": {
"DisplayName": "name",
"ID": "myid"
},
"Grants": [
{
"Grantee": {
"DisplayName": "name",
"Type": "CanonicalUser",
"ID": "myid"
},
"Permission": "FULL_CONTROL"
}
]
})
xml_payload = params['payload'].getvalue()
self.assertEqual(xml_payload, PUT_OBJECT_ACL)

0 comments on commit b1a2d62

Please sign in to comment.