From 3099ffb85d3182f2eaef2e5507c4089ef5c3a17d Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Wed, 12 Mar 2014 18:43:31 +0000 Subject: [PATCH] Object storage tests to use default auth_provider Object storage test uses get_auth_provider(), it should just take the existing auth_provider instead. Partially implements: bp multi-keystone-api-version-tests Change-Id: I790c22becb28ef8c2946efcc4b1c47f8e295fb74 --- .../api/object_storage/test_account_quotas.py | 2 +- .../test_account_quotas_negative.py | 2 +- .../test_account_services_negative.py | 2 +- .../api/object_storage/test_container_acl.py | 2 +- .../test_container_acl_negative.py | 2 +- tempest/exceptions/__init__.py | 4 ++++ tempest/manager.py | 17 ++++++++--------- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py index b14adc053b..a3098a5be1 100644 --- a/tempest/api/object_storage/test_account_quotas.py +++ b/tempest/api/object_storage/test_account_quotas.py @@ -68,7 +68,7 @@ class AccountQuotasTest(base.BaseObjectTest): # Retrieve a ResellerAdmin auth data and use it to set a quota # on the client's account cls.reselleradmin_auth_data = \ - cls.os_reselleradmin.get_auth_provider().auth_data + cls.os_reselleradmin.auth_provider.auth_data def setUp(self): super(AccountQuotasTest, self).setUp() diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py index 402cd9054a..7648ea1779 100644 --- a/tempest/api/object_storage/test_account_quotas_negative.py +++ b/tempest/api/object_storage/test_account_quotas_negative.py @@ -68,7 +68,7 @@ class AccountQuotasNegativeTest(base.BaseObjectTest): # Retrieve a ResellerAdmin auth data and use it to set a quota # on the client's account cls.reselleradmin_auth_data = \ - cls.os_reselleradmin.get_auth_provider().auth_data + cls.os_reselleradmin.auth_provider.auth_data def setUp(self): super(AccountQuotasNegativeTest, self).setUp() diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py index ea93aa35be..71eaab5839 100644 --- a/tempest/api/object_storage/test_account_services_negative.py +++ b/tempest/api/object_storage/test_account_services_negative.py @@ -31,7 +31,7 @@ class AccountNegativeTest(base.BaseObjectTest): test_os = clients.Manager(self.data.test_user, self.data.test_password, self.data.test_tenant) - test_auth_provider = test_os.get_auth_provider() + test_auth_provider = test_os.auth_provider # Get auth for the test user test_auth_provider.auth_data diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py index 085ef51835..c865ee1ab3 100644 --- a/tempest/api/object_storage/test_container_acl.py +++ b/tempest/api/object_storage/test_container_acl.py @@ -27,7 +27,7 @@ class ObjectTestACLs(base.BaseObjectTest): test_os = clients.Manager(cls.data.test_user, cls.data.test_password, cls.data.test_tenant) - cls.test_auth_data = test_os.get_auth_provider().auth_data + cls.test_auth_data = test_os.auth_provider.auth_data @classmethod def tearDownClass(cls): diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py index a5a0950850..547bf87bb7 100644 --- a/tempest/api/object_storage/test_container_acl_negative.py +++ b/tempest/api/object_storage/test_container_acl_negative.py @@ -29,7 +29,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): test_os = clients.Manager(cls.data.test_user, cls.data.test_password, cls.data.test_tenant) - cls.test_auth_data = test_os.get_auth_provider().auth_data + cls.test_auth_data = test_os.auth_provider.auth_data @classmethod def tearDownClass(cls): diff --git a/tempest/exceptions/__init__.py b/tempest/exceptions/__init__.py index 06dee71c00..485f532693 100644 --- a/tempest/exceptions/__init__.py +++ b/tempest/exceptions/__init__.py @@ -20,6 +20,10 @@ class InvalidConfiguration(base.TempestException): message = "Invalid Configuration" +class InvalidCredentials(base.TempestException): + message = "Invalid Credentials" + + class InvalidHttpSuccessCode(base.RestClientException): message = "The success code is different than the expected one" diff --git a/tempest/manager.py b/tempest/manager.py index 708447ef9c..63235dbc4c 100644 --- a/tempest/manager.py +++ b/tempest/manager.py @@ -75,13 +75,12 @@ class Manager(object): tenant_name=CONF.identity.tenant_name ) - def get_auth_provider(self, credentials=None): - auth_params = dict(client_type=getattr(self, 'client_type', None), - interface=getattr(self, 'interface', None)) + def get_auth_provider(self, credentials): + if credentials is None: + raise exceptions.InvalidCredentials( + 'Credentials must be specified') auth_provider_class = self.get_auth_provider_class(self.auth_version) - # If invalid / incomplete credentials are provided, use default ones - if credentials is None or \ - not auth_provider_class.check_credentials(credentials): - credentials = self.credentials - auth_params['credentials'] = credentials - return auth_provider_class(**auth_params) + return auth_provider_class( + client_type=getattr(self, 'client_type', None), + interface=getattr(self, 'interface', None), + credentials=credentials)