From 199b8b46c5173e34b6ea9e66601ad191d160ef97 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 10 Aug 2011 14:55:34 -0700 Subject: [PATCH] Test S3 api for handling of Content-MD5 that does not match. The existing test_object_create_bad_md5_invalid is not valid base64, and hence triggers a different code path. This time, submit valid base64, but have the result not match the expected md5sum. --- s3tests/functional/test_headers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s3tests/functional/test_headers.py b/s3tests/functional/test_headers.py index 164c2ad..08e3902 100644 --- a/s3tests/functional/test_headers.py +++ b/s3tests/functional/test_headers.py @@ -159,6 +159,17 @@ def test_object_create_bad_md5_invalid(): eq(e.error_code, 'InvalidDigest') +@nose.with_setup(teardown=_clear_custom_headers) +@attr('fails_on_dho') +def test_object_create_bad_md5_wrong(): + key = _setup_bad_object({'Content-MD5':'YWJyYWNhZGFicmE='}) + + 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) @attr('fails_on_dho') def test_object_create_bad_md5_empty():