Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge "Add ability to authenticate with an account password"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Apr 6, 2016
2 parents 4a744d8 + 4ae13d1 commit 7f649c1
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 16 deletions.
3 changes: 2 additions & 1 deletion tests/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setUpClass(cls):
cls.auth_client.authenticate_user(
cls.auth_config.base_url,
cls.auth_config.user_name,
cls.auth_config.api_key)
cls.auth_config.api_key,
cls.auth_config.password)
else:
auth_token = str(uuid.uuid4())
cls.user_project_id = str(uuid.uuid4())
Expand Down
35 changes: 22 additions & 13 deletions tests/api/utils/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ def __init__(self):
self.default_headers['Content-Type'] = 'application/json'
self.default_headers['Accept'] = 'application/json'

def authenticate_user(self, auth_url, user_name, api_key):
"""Get Auth Token & Project ID using api_key
TODO (malini-kamalambal): Support getting token with password (or)
api key.
"""
request_body = {
"auth": {
"RAX-KSKEY:apiKeyCredentials": {
"username": user_name,
"apiKey": api_key
def authenticate_user(self, auth_url, user_name, api_key=None,
password=None):
"""Get Auth Token & Project ID using api_key"""

if api_key:
request_body = {
"auth": {
"RAX-KSKEY:apiKeyCredentials": {
"username": user_name,
"apiKey": api_key
},
},
},
}
}
elif password:
request_body = {
"auth": {
"passwordCredentials": {
"username": user_name,
"password": password
},
},
}

request_body = json.dumps(request_body)
url = auth_url + '/tokens'

Expand Down
5 changes: 5 additions & 0 deletions tests/api/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def api_key(self):
"""The user's api key, if applicable."""
return self.get_raw('api_key')

@property
def password(self):
"""The user's password, if applicable."""
return self.get_raw('password')

@property
def multi_user(self):
"""Flag to indicate if the tests need multiple accounts."""
Expand Down
3 changes: 2 additions & 1 deletion tests/endtoend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def setUpClass(cls):
auth_token, project_id = cls.auth_client.authenticate_user(
cls.auth_config.base_url,
cls.auth_config.user_name,
cls.auth_config.api_key)
cls.auth_config.api_key,
cls.auth_config.password)

cls.test_config = config.TestConfig()
cls.default_origin = cls.test_config.default_origin
Expand Down
5 changes: 5 additions & 0 deletions tests/endtoend/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def api_key(self):
"""The user's api key, if applicable."""
return self.get_raw('api_key')

@property
def password(self):
"""The user's password, if applicable."""
return self.get_raw('password')


class WebPageTestConfig(data_interfaces.ConfigSectionInterface):
"""Defines the webpage test config values."""
Expand Down
1 change: 1 addition & 0 deletions tests/etc/api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
auth_enabled=False
user_name={user name of the cloud account}
api_key={api key for this user name}
password={password for this user name}
base_url=https://identity.api.rackspacecloud.com/v2.0

multi_user=False
Expand Down
3 changes: 2 additions & 1 deletion tests/etc/endtoend.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[auth]
user_name={user name of the cloud account}
api_key={api key for this user name}
password={password for this user name}
base_url=https://identity.api.rackspacecloud.com/v2.0

[poppy]
Expand Down Expand Up @@ -38,7 +39,7 @@ test_locations=Wellington:Chrome, Indore:Firefox, Stockholm:Safari, Dulles:Firef

[test_configuration]
default_origin=127.0.0.1
# Use alternate_origin to test content heavy websites. The default origin
# Use alternate_origin to test content heavy websites. The default origin
# while useful to validate cdn functionality, is a very light flask site.
alternate_origin=1.2.3.4
ssl_origin=1.2.3.4
Expand Down

0 comments on commit 7f649c1

Please sign in to comment.