From: Stephon Striplin Date: Wed, 27 Jul 2011 03:12:48 +0000 (-0700) Subject: add Date header tests X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3b15fc7547c863db3bfcbc46f4e284c5b3fb8c67;p=s3-tests.git add Date header tests --- diff --git a/s3tests/functional/test_headers.py b/s3tests/functional/test_headers.py index 90c02685..659059bc 100644 --- a/s3tests/functional/test_headers.py +++ b/s3tests/functional/test_headers.py @@ -320,3 +320,87 @@ def test_object_create_bad_ua_unreadable(): def test_object_create_bad_ua_none(): key = _setup_bad_object(remove=('User-Agent',)) key.set_contents_from_string('bar') + + +@nose.with_setup(teardown=_clear_custom_headers) +@attr('fails_on_dho') +def test_object_create_bad_date_invalid(): + key = _setup_bad_object({'Date': 'Bad Date'}) + + 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) +@attr('fails_on_dho') +def test_object_create_bad_date_empty(): + key = _setup_bad_object({'Date': ''}) + + 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) +@attr('fails_on_dho') +def test_object_create_bad_date_unreadable(): + key = _setup_bad_object({'Date': '\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) +@attr('fails_on_dho') +def test_object_create_bad_date_none(): + key = _setup_bad_object(remove=('Date',)) + + 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_date_before_today(): + key = _setup_bad_object({'Date': 'Tue, 07 Jul 2010 21:53:04 GMT'}) + + e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar') + eq(e.status, 403) + eq(e.reason, 'Forbidden') + eq(e.error_code, 'RequestTimeTooSkewed') + + +@nose.with_setup(teardown=_clear_custom_headers) +def test_object_create_bad_date_after_today(): + key = _setup_bad_object({'Date': 'Tue, 07 Jul 2030 21:53:04 GMT'}) + + e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar') + eq(e.status, 403) + eq(e.reason, 'Forbidden') + eq(e.error_code, 'RequestTimeTooSkewed') + + +@nose.with_setup(teardown=_clear_custom_headers) +def test_object_create_bad_date_before_epoch(): + key = _setup_bad_object({'Date': 'Tue, 07 Jul 1950 21:53:04 GMT'}) + + 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_date_after_end(): + key = _setup_bad_object({'Date': 'Tue, 07 Jul 9999 21:53:04 GMT'}) + + e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar') + eq(e.status, 403) + eq(e.reason, 'Forbidden') + eq(e.error_code, 'RequestTimeTooSkewed')