]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
update MD5 header tests
authorStephon Striplin <stephon.striplin@dreamhost.com>
Wed, 27 Jul 2011 02:45:48 +0000 (19:45 -0700)
committerStephon Striplin <stephon.striplin@dreamhost.com>
Wed, 27 Jul 2011 17:29:06 +0000 (10:29 -0700)
* Rename a test
* Add more tests

s3tests/functional/test_headers.py

index 9186a046928a182f2ac400908e0b75a6024d5825..a0bc9302f2758c73399c16f122e20ff2a1677569 100644 (file)
@@ -114,7 +114,7 @@ def _setup_bad_object(headers=None, remove=None):
 
 @nose.with_setup(teardown=_clear_custom_headers)
 @attr('fails_on_dho')
-def test_object_create_bad_md5():
+def test_object_create_bad_md5_invalid():
     key = _setup_bad_object({'Content-MD5':'AWS HAHAHA'})
 
     e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
@@ -123,6 +123,33 @@ def test_object_create_bad_md5():
     eq(e.error_code, 'InvalidDigest')
 
 
+@nose.with_setup(teardown=_clear_custom_headers)
+@attr('fails_on_dho')
+def test_object_create_bad_md5_empty():
+    key = _setup_bad_object({'Content-MD5': ''})
+
+    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, 'InvalidDigest')
+
+
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_md5_unreadable():
+    key = _setup_bad_object({'Content-MD5': '\x07'})
+
+    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)
+def test_object_create_bad_md5_none():
+    key = _setup_bad_object(remove=('Content-MD5',))
+    key.set_contents_from_string('bar')
+
+
 # strangely, amazon doesn't report an error with a non-expect 100 also, our
 # error comes back as html, and not xml as I normally expect
 @nose.with_setup(teardown=_clear_custom_headers)