diff options
author | anc <alistair.coles@hp.com> | 2014-03-25 08:21:21 +0000 |
---|---|---|
committer | Alistair Coles <alistair.coles@hp.com> | 2014-07-23 16:55:38 +0100 |
commit | cae12940b1bff230381289b732b464d88423fec1 (patch) | |
tree | 41b1e60913e76b3856e8f338d724ca02966ab036 /tests/unit/utils.py | |
parent | 394cb57f630b3dfdc1d5b2e172ef0f1c16b8211f (diff) | |
download | python-swiftclient-cae12940b1bff230381289b732b464d88423fec1.tar.gz |
Add keystone v3 auth support
Enables swiftclient to authenticate using
the keystone v3 API, allowing user id's, user
domains and tenant/project domains to be
specified.
Since swiftclient imports keystoneclient, the
main changes in swiftclient/client.py are to
selectively import the correct keystoneclient
library version and pass a number of new
options to it via the get_auth() function. In
addition the get_keystoneclient_2_0 method
has been renamed get_auth_keystone to better
reflect its purpose since it now deals with
both v2 and v3 use cases.
In swiftclient/shell.py the new options are
added to the parser. To make the default help
message shorter, help for all the --os-*
options (including the existing v2 options)
is only displayed when explicitly requested
usng a new --os-help option.
A new set of unit tests is added to
test_shell.py to verify the parser. A comment
in tests/sample.conf explains how to
configure the existing functional tests to
run using keystone v3 API.
Note that to use keystone v3
with swift you will need to set
auth_version = v3.0 in the auth_token
middleware config section of
proxy-server.conf.
Change-Id: Ifda0b3263eb919a8c6a1b204ba0a1215ed6f642f
Diffstat (limited to 'tests/unit/utils.py')
-rw-r--r-- | tests/unit/utils.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 914bc8f..cb671cf 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -16,11 +16,11 @@ from requests import RequestException from time import sleep -def fake_get_keystoneclient_2_0(os_options, exc=None, **kwargs): - def fake_get_keystoneclient_2_0(auth_url, - user, - key, - actual_os_options, **actual_kwargs): +def fake_get_auth_keystone(os_options, exc=None, **kwargs): + def fake_get_auth_keystone(auth_url, + user, + key, + actual_os_options, **actual_kwargs): if exc: raise exc('test') if actual_os_options != os_options: @@ -37,9 +37,13 @@ def fake_get_keystoneclient_2_0(os_options, exc=None, **kwargs): actual_kwargs['cacert'] is None: from swiftclient import client as c raise c.ClientException("unverified-certificate") + if 'required_kwargs' in kwargs: + for k, v in kwargs['required_kwargs'].items(): + if v != actual_kwargs.get(k): + return "", None return "http://url/", "token" - return fake_get_keystoneclient_2_0 + return fake_get_auth_keystone def fake_http_connect(*code_iter, **kwargs): |