summaryrefslogtreecommitdiff
path: root/tempest/auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'tempest/auth.py')
-rw-r--r--tempest/auth.py80
1 files changed, 30 insertions, 50 deletions
diff --git a/tempest/auth.py b/tempest/auth.py
index c84ad6bb5..b1ead29ad 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -40,11 +40,9 @@ class AuthProvider(object):
Provide authentication
"""
- def __init__(self, credentials, client_type='tempest',
- interface=None):
+ def __init__(self, credentials, interface=None):
"""
:param credentials: credentials for authentication
- :param client_type: 'tempest' or 'official'
:param interface: 'json' or 'xml'. Applicable for tempest client only
"""
credentials = self._convert_credentials(credentials)
@@ -52,9 +50,8 @@ class AuthProvider(object):
self.credentials = credentials
else:
raise TypeError("Invalid credentials")
- self.client_type = client_type
self.interface = interface
- if self.client_type == 'tempest' and self.interface is None:
+ if self.interface is None:
self.interface = 'json'
self.cache = None
self.alt_auth_data = None
@@ -68,11 +65,10 @@ class AuthProvider(object):
return credentials
def __str__(self):
- return "Creds :{creds}, client type: {client_type}, interface: " \
- "{interface}, cached auth data: {cache}".format(
- creds=self.credentials, client_type=self.client_type,
- interface=self.interface, cache=self.cache
- )
+ return "Creds :{creds}, interface: {interface}, " \
+ "cached auth data: {cache}".format(
+ creds=self.credentials, interface=self.interface,
+ cache=self.cache)
@abc.abstractmethod
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -208,9 +204,8 @@ class KeystoneAuthProvider(AuthProvider):
token_expiry_threshold = datetime.timedelta(seconds=60)
- def __init__(self, credentials, client_type='tempest', interface=None):
- super(KeystoneAuthProvider, self).__init__(credentials, client_type,
- interface)
+ def __init__(self, credentials, interface=None):
+ super(KeystoneAuthProvider, self).__init__(credentials, interface)
self.auth_client = self._auth_client()
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -244,15 +239,12 @@ class KeystoneAuthProvider(AuthProvider):
def _get_auth(self):
# Bypasses the cache
- if self.client_type == 'tempest':
- auth_func = getattr(self.auth_client, 'get_token')
- auth_params = self._auth_params()
+ auth_func = getattr(self.auth_client, 'get_token')
+ auth_params = self._auth_params()
- # returns token, auth_data
- token, auth_data = auth_func(**auth_params)
- return token, auth_data
- else:
- raise NotImplementedError
+ # returns token, auth_data
+ token, auth_data = auth_func(**auth_params)
+ return token, auth_data
def get_token(self):
return self.auth_data[0]
@@ -263,23 +255,17 @@ class KeystoneV2AuthProvider(KeystoneAuthProvider):
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
def _auth_client(self):
- if self.client_type == 'tempest':
- if self.interface == 'json':
- return json_id.TokenClientJSON()
- else:
- return xml_id.TokenClientXML()
+ if self.interface == 'json':
+ return json_id.TokenClientJSON()
else:
- raise NotImplementedError
+ return xml_id.TokenClientXML()
def _auth_params(self):
- if self.client_type == 'tempest':
- return dict(
- user=self.credentials.username,
- password=self.credentials.password,
- tenant=self.credentials.tenant_name,
- auth_data=True)
- else:
- raise NotImplementedError
+ return dict(
+ user=self.credentials.username,
+ password=self.credentials.password,
+ tenant=self.credentials.tenant_name,
+ auth_data=True)
def _fill_credentials(self, auth_data_body):
tenant = auth_data_body['token']['tenant']
@@ -350,24 +336,18 @@ class KeystoneV3AuthProvider(KeystoneAuthProvider):
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
def _auth_client(self):
- if self.client_type == 'tempest':
- if self.interface == 'json':
- return json_v3id.V3TokenClientJSON()
- else:
- return xml_v3id.V3TokenClientXML()
+ if self.interface == 'json':
+ return json_v3id.V3TokenClientJSON()
else:
- raise NotImplementedError
+ return xml_v3id.V3TokenClientXML()
def _auth_params(self):
- if self.client_type == 'tempest':
- return dict(
- user=self.credentials.username,
- password=self.credentials.password,
- tenant=self.credentials.tenant_name,
- domain=self.credentials.user_domain_name,
- auth_data=True)
- else:
- raise NotImplementedError
+ return dict(
+ user=self.credentials.username,
+ password=self.credentials.password,
+ tenant=self.credentials.tenant_name,
+ domain=self.credentials.user_domain_name,
+ auth_data=True)
def _fill_credentials(self, auth_data_body):
# project or domain, depending on the scope