mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 03:47:22 +00:00
Improve list bucket invalid and bad auth tests
Explicitly test invalid access keys and valid access keys but invalid secret keys. Also disable anonymous list bucket test for AWS. radosgw uses this for connectivity testing but AWS does not allow it: http://ceph.com/docs/master/radosgw/config/#verify-the-runtime http://docs.aws.amazon.com/AmazonS3/latest/API/RESTServiceGET.html
This commit is contained in:
parent
a23c81187b
commit
5a995a9e14
1 changed files with 16 additions and 4 deletions
|
@ -3873,12 +3873,12 @@ def test_buckets_create_then_list():
|
||||||
raise RuntimeError("S3 implementation's GET on Service did not return bucket we created: %r", bucket.name)
|
raise RuntimeError("S3 implementation's GET on Service did not return bucket we created: %r", bucket.name)
|
||||||
|
|
||||||
# Common code to create a connection object, which'll use bad authorization information
|
# Common code to create a connection object, which'll use bad authorization information
|
||||||
def _create_connection_bad_auth():
|
def _create_connection_bad_auth(aws_access_key_id='badauth'):
|
||||||
# We're going to need to manually build a connection using bad authorization info.
|
# We're going to need to manually build a connection using bad authorization info.
|
||||||
# But to save the day, lets just hijack the settings from s3.main. :)
|
# But to save the day, lets just hijack the settings from s3.main. :)
|
||||||
main = s3.main
|
main = s3.main
|
||||||
conn = boto.s3.connection.S3Connection(
|
conn = boto.s3.connection.S3Connection(
|
||||||
aws_access_key_id='badauth',
|
aws_access_key_id=aws_access_key_id,
|
||||||
aws_secret_access_key='roflmao',
|
aws_secret_access_key='roflmao',
|
||||||
is_secure=main.is_secure,
|
is_secure=main.is_secure,
|
||||||
port=main.port,
|
port=main.port,
|
||||||
|
@ -3891,6 +3891,7 @@ def _create_connection_bad_auth():
|
||||||
@attr(method='get')
|
@attr(method='get')
|
||||||
@attr(operation='list all buckets (anonymous)')
|
@attr(operation='list all buckets (anonymous)')
|
||||||
@attr(assertion='succeeds')
|
@attr(assertion='succeeds')
|
||||||
|
@attr('fails_on_aws')
|
||||||
def test_list_buckets_anonymous():
|
def test_list_buckets_anonymous():
|
||||||
# Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
|
# Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism,
|
||||||
# emulating standard HTTP access.
|
# emulating standard HTTP access.
|
||||||
|
@ -3906,12 +3907,23 @@ def test_list_buckets_anonymous():
|
||||||
@attr(method='get')
|
@attr(method='get')
|
||||||
@attr(operation='list all buckets (bad auth)')
|
@attr(operation='list all buckets (bad auth)')
|
||||||
@attr(assertion='fails 403')
|
@attr(assertion='fails 403')
|
||||||
def test_list_buckets_bad_auth():
|
def test_list_buckets_invalid_auth():
|
||||||
conn = _create_connection_bad_auth()
|
conn = _create_connection_bad_auth()
|
||||||
e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
|
e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
|
||||||
eq(e.status, 403)
|
eq(e.status, 403)
|
||||||
eq(e.reason, 'Forbidden')
|
eq(e.reason, 'Forbidden')
|
||||||
eq(e.error_code, 'AccessDenied')
|
eq(e.error_code, 'InvalidAccessKeyId')
|
||||||
|
|
||||||
|
@attr(resource='bucket')
|
||||||
|
@attr(method='get')
|
||||||
|
@attr(operation='list all buckets (bad auth)')
|
||||||
|
@attr(assertion='fails 403')
|
||||||
|
def test_list_buckets_bad_auth():
|
||||||
|
conn = _create_connection_bad_auth(aws_access_key_id=s3.main.aws_access_key_id)
|
||||||
|
e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets)
|
||||||
|
eq(e.status, 403)
|
||||||
|
eq(e.reason, 'Forbidden')
|
||||||
|
eq(e.error_code, 'SignatureDoesNotMatch')
|
||||||
|
|
||||||
@attr(resource='bucket')
|
@attr(resource='bucket')
|
||||||
@attr(method='put')
|
@attr(method='put')
|
||||||
|
|
Loading…
Reference in a new issue