]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
add Authorization header tests
authorStephon Striplin <stephon.striplin@dreamhost.com>
Wed, 27 Jul 2011 03:13:44 +0000 (20:13 -0700)
committerStephon Striplin <stephon.striplin@dreamhost.com>
Thu, 28 Jul 2011 23:46:53 +0000 (16:46 -0700)
s3tests/functional/test_headers.py

index bdc626cc96fc4aea8f2b05fcccc6b014019da76d..164c2ad6dad4413d80c638543e48242660255f4d 100644 (file)
@@ -358,6 +358,59 @@ def test_object_create_bad_ua_none():
     key.set_contents_from_string('bar')
 
 
+@nose.with_setup(teardown=_clear_custom_headers)
+@attr('fails_on_dho')
+def test_object_create_bad_authorization_invalid():
+    key = _setup_bad_object({'Authorization': 'AWS HAHAHA'})
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 400)
+    eq(e.reason, 'Bad Request')
+    eq(e.error_code, 'InvalidArgument')
+
+
+# the teardown is really messed up here. check it out
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_authorization_unreadable():
+    key = _setup_bad_object({'Authorization': '\x07'})
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    eq(e.error_code, 'AccessDenied')
+
+
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_authorization_empty():
+    key = _setup_bad_object({'Authorization': ''})
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    eq(e.error_code, 'AccessDenied')
+
+
+# the teardown is really messed up here. check it out
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_authorization_none():
+    key = _setup_bad_object(remove=('Authorization',))
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    eq(e.error_code, 'AccessDenied')
+
+
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_authorization_incorrect():
+    key = _setup_bad_object({'Authorization': 'AWS AKIAIGR7ZNNBHC5BKSUA:FWeDfwojDSdS2Ztmpfeubhd9isU='})
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 403)
+    eq(e.reason, 'Forbidden')
+    assert e.error_code in ('AccessDenied', 'SignatureDoesNotMatch')
+
+
 @nose.with_setup(teardown=_clear_custom_headers)
 @attr('fails_on_dho')
 def test_object_create_bad_date_invalid():