17
17
from datetime import datetime
20
21
from webob import Request, Response
21
22
from webob.exc import HTTPUnauthorized, HTTPCreated, HTTPNoContent,\
22
23
HTTPAccepted, HTTPBadRequest, HTTPNotFound, HTTPConflict
23
24
import xml.dom.minidom
25
from nose.plugins.skip import SkipTest
28
from swift.common.middleware import swift3
31
# Skip the swift3 tests if boto is not installed
27
from swift.common.middleware import swift3
34
30
class FakeApp(object):
35
31
def __init__(self):
554
548
resp = local_app(req.environ, local_app.app.do_start_response)
555
549
self._check_acl('test:tester', resp)
551
def test_canonical_string(self):
553
The hashes here were generated by running the same requests against
554
boto.utils.canonical_string
556
def verify(hash, path, headers):
557
req = Request.blank(path, headers=headers)
558
self.assertEquals(hash,
559
hashlib.md5(swift3.canonical_string(req)).hexdigest())
561
verify('6dd08c75e42190a1ce9468d1fd2eb787', '/bucket/object',
562
{'Content-Type': 'text/plain', 'X-Amz-Something': 'test',
565
verify('c8447135da232ae7517328f3429df481', '/bucket/object',
566
{'Content-Type': 'text/plain', 'X-Amz-Something': 'test'})
568
verify('bf49304103a4de5c325dce6384f2a4a2', '/bucket/object',
569
{'content-type': 'text/plain'})
571
verify('be01bd15d8d47f9fe5e2d9248cc6f180', '/bucket/object', {})
573
verify('8d28cc4b8322211f6cc003256cd9439e', 'bucket/object',
574
{'Content-MD5': 'somestuff'})
576
verify('a822deb31213ad09af37b5a7fe59e55e', '/bucket/object?acl', {})
578
verify('cce5dd1016595cb706c93f28d3eaa18f', '/bucket/object',
579
{'Content-Type': 'text/plain', 'X-Amz-A': 'test',
580
'X-Amz-Z': 'whatever', 'X-Amz-B': 'lalala',
581
'X-Amz-Y': 'lalalalalalala'})
557
583
if __name__ == '__main__':