mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-22 09:29:43 +00:00
Merge pull request #314 from theanalyst/iam/user-policy-basic
iam: add a very basic user policy smoke test Reviewed-By: Casey Bodley <cbodley@redhat.com> Reviewed-By: Pritha Srivastava <prsivas@redhat.com> Reviewed-By: Yuval Lifshitz <yuvalif@yahoo.com>
This commit is contained in:
commit
c9c84faf48
2 changed files with 33 additions and 0 deletions
|
@ -265,6 +265,16 @@ def get_tenant_client(client_config=None):
|
||||||
config=client_config)
|
config=client_config)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
def get_tenant_iam_client():
|
||||||
|
|
||||||
|
client = boto3.client(service_name='iam',
|
||||||
|
region_name='us-east-1',
|
||||||
|
aws_access_key_id=config.tenant_access_key,
|
||||||
|
aws_secret_access_key=config.tenant_secret_key,
|
||||||
|
endpoint_url=config.default_endpoint,
|
||||||
|
use_ssl=config.default_is_secure)
|
||||||
|
return client
|
||||||
|
|
||||||
def get_unauthenticated_client():
|
def get_unauthenticated_client():
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id='',
|
aws_access_key_id='',
|
||||||
|
|
|
@ -64,6 +64,8 @@ from . import (
|
||||||
get_alt_email,
|
get_alt_email,
|
||||||
get_alt_client,
|
get_alt_client,
|
||||||
get_tenant_client,
|
get_tenant_client,
|
||||||
|
get_tenant_iam_client,
|
||||||
|
get_tenant_user_id,
|
||||||
get_buckets_list,
|
get_buckets_list,
|
||||||
get_objects_list,
|
get_objects_list,
|
||||||
get_main_kms_keyid,
|
get_main_kms_keyid,
|
||||||
|
@ -12341,3 +12343,24 @@ def test_object_read_unreadable():
|
||||||
status, error_code = _get_status_and_error_code(e.response)
|
status, error_code = _get_status_and_error_code(e.response)
|
||||||
eq(status, 400)
|
eq(status, 400)
|
||||||
eq(e.response['Error']['Message'], 'Couldn\'t parse the specified URI.')
|
eq(e.response['Error']['Message'], 'Couldn\'t parse the specified URI.')
|
||||||
|
|
||||||
|
@attr(resource='bucket')
|
||||||
|
@attr(method='get')
|
||||||
|
@attr(operation='Test User Policy')
|
||||||
|
@attr(assertion='succeeds')
|
||||||
|
@attr('user-policy')
|
||||||
|
def test_user_policy():
|
||||||
|
client = get_tenant_iam_client()
|
||||||
|
|
||||||
|
policy_document = json.dumps(
|
||||||
|
{"Version":"2012-10-17",
|
||||||
|
"Statement": {
|
||||||
|
"Effect":"Allow",
|
||||||
|
"Action":"*",
|
||||||
|
"Resource":"*"}}
|
||||||
|
)
|
||||||
|
client.put_user_policy(
|
||||||
|
PolicyDocument= policy_document,
|
||||||
|
PolicyName='AllAccessPolicy',
|
||||||
|
UserName=get_tenant_user_id(),
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue