]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
update Content-Length header tests
authorStephon Striplin <stephon.striplin@dreamhost.com>
Wed, 27 Jul 2011 03:01:15 +0000 (20:01 -0700)
committerStephon Striplin <stephon.striplin@dreamhost.com>
Wed, 27 Jul 2011 17:30:00 +0000 (10:30 -0700)
* Add more tests
* Add nose.with_setup on some tests

s3tests/functional/test_headers.py

index 3450e03ddbc24749284d5e3049f4a49f1e5d4d7c..dfd19831b340458813f3a978c42d7b9fa7107b99 100644 (file)
@@ -193,6 +193,17 @@ def test_object_create_bad_contentlength_empty():
     eq(e.error_code, None)
 
 
+@nose.with_setup(teardown=_clear_custom_headers)
+@attr('fails_on_dho')
+def test_object_create_bad_contentlength_negative():
+    key = _setup_bad_object({'Content-Length': -1})
+
+    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, None)
+
+
 @nose.with_setup(teardown=_clear_custom_headers)
 @attr('fails_on_dho')
 def test_object_create_bad_contentlength_zero():
@@ -204,6 +215,27 @@ def test_object_create_bad_contentlength_zero():
     eq(e.error_code, 'BadDigest')
 
 
+@nose.with_setup(teardown=_clear_custom_headers)
+def test_object_create_bad_contentlength_none():
+    key = _setup_bad_object(remove=('Content-Length',))
+
+    e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar')
+    eq(e.status, 411)
+    eq(e.reason, 'Length Required')
+    eq(e.error_code,'MissingContentLength')
+
+
+@nose.with_setup(teardown=_clear_custom_headers)
+@attr('fails_on_dho')
+def test_object_create_bad_contentlength_utf8():
+    key = _setup_bad_object({'Content-Length': '\x07'})
+
+    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, None)
+
+
 @nose.with_setup(teardown=_clear_custom_headers)
 @attr('fails_on_dho')
 def test_object_create_bad_contentlength_mismatch_above():