def test_bucket_fails_with_both_acl_header_and_xml_PUT(self): elem = Element('AccessControlPolicy') owner = SubElement(elem, 'Owner') SubElement(owner, 'ID').text = 'id' acl = SubElement(elem, 'AccessControlList') grant = SubElement(acl, 'Grant') grantee = SubElement(grant, 'Grantee', nsmap={'xsi': XMLNS_XSI}) grantee.set('{%s}type' % XMLNS_XSI, 'Group') SubElement(grantee, 'URI').text = \ 'http://acs.oss.com/groups/global/AllUsers' SubElement(grant, 'Permission').text = 'READ' xml = tostring(elem) req = Request.blank('/bucket?acl', environ={'REQUEST_METHOD': 'PUT'}, headers={ 'Authorization': 'OSS test:tester:hmac', 'Date': self.get_date_header(), 'X-Oss-ACL': 'public-read' }, body=xml) status, headers, body = self.call_oss2swift(req) self.assertEqual(self._get_error_code(body), 'UnexpectedContent')
def test_bucket_acl_PUT(self): elem = Element('AccessControlPolicy') owner = SubElement(elem, 'Owner') SubElement(owner, 'ID').text = 'id' acl = SubElement(elem, 'AccessControlList') grant = SubElement(acl, 'Grant') grantee = SubElement(grant, 'Grantee', nsmap={'xsi': XMLNS_XSI}) grantee.set('{%s}type' % XMLNS_XSI, 'Group') SubElement(grantee, 'URI').text = \ 'http://acs.oss.com/groups/global/AllUsers' SubElement(grant, 'Permission').text = 'READ' xml = tostring(elem) req = Request.blank('/bucket?acl', environ={'REQUEST_METHOD': 'PUT'}, headers={ 'Authorization': 'OSS test:tester:hmac', 'Date': self.get_date_header() }, body=xml) status, headers, body = self.call_oss2swift(req) self.assertEqual(status.split()[0], '200') req = Request.blank('/bucket?acl', environ={ 'REQUEST_METHOD': 'PUT', 'wsgi.input': StringIO(xml) }, headers={ 'Authorization': 'OSS test:tester:hmac', 'Date': self.get_date_header(), 'Transfer-Encoding': 'chunked' }) self.assertIsNone(req.content_length) self.assertIsNone(req.message_length()) status, headers, body = self.call_oss2swift(req) self.assertEqual(status.split()[0], '200')