diff options
author | Bradley Klein <brad.klein@hp.com> | 2014-05-05 15:00:03 -0400 |
---|---|---|
committer | Bradley Klein <brad.klein@hp.com> | 2014-08-04 15:52:56 -0600 |
commit | 2203b013fb66808ef280eff0285318ce21d9bc67 (patch) | |
tree | c2666f423cc616628e0f421cede9dcd87295cfe4 /neutronclient/tests/unit/test_ssl.py | |
parent | d07c65c7fc0e2db7842937350d64551b3f76d94d (diff) | |
download | python-neutronclient-2203b013fb66808ef280eff0285318ce21d9bc67.tar.gz |
Add keystone v3 auth support
This change enables the neutron client to use the keystone v3 API (in
addition to v2). This allows user domains and tenant/project domains to
be specified. This is necessary because keystone v2 API is deprecated
as of Icehouse.
The keystone session object (and auth plugin) can now be specified
and are required to use the keystone v3 API. The existing HTTPClient
is retained for backward compatibility. See changes in shell.py for
an example of how to construct the session and auth plugin.
Implements: blueprint keystone-api-v3-support
Change-Id: I9d0395d405b9fbe4db08ad3727f9413be7b82811
Diffstat (limited to 'neutronclient/tests/unit/test_ssl.py')
-rw-r--r-- | neutronclient/tests/unit/test_ssl.py | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/neutronclient/tests/unit/test_ssl.py b/neutronclient/tests/unit/test_ssl.py index 9c0816d..bc0e500 100644 --- a/neutronclient/tests/unit/test_ssl.py +++ b/neutronclient/tests/unit/test_ssl.py @@ -14,15 +14,17 @@ # under the License. import fixtures -from mox3 import mox import requests import testtools +import httpretty +from mox3 import mox + from neutronclient.client import HTTPClient from neutronclient.common.clientmanager import ClientManager from neutronclient.common import exceptions from neutronclient import shell as openstack_shell - +from neutronclient.tests.unit import test_auth as auth AUTH_TOKEN = 'test_token' END_URL = 'test_url' @@ -41,7 +43,13 @@ class TestSSL(testtools.TestCase): self.mox = mox.Mox() self.addCleanup(self.mox.UnsetStubs) + @httpretty.activate def test_ca_cert_passed(self): + # emulate Keystone version discovery + httpretty.register_uri(httpretty.GET, + auth.V3_URL, + body=auth.V3_VERSION_ENTRY) + self.mox.StubOutWithMock(ClientManager, '__init__') self.mox.StubOutWithMock(openstack_shell.NeutronShell, 'interact') @@ -66,14 +74,27 @@ class TestSSL(testtools.TestCase): raise_errors=mox.IgnoreArg(), log_credentials=mox.IgnoreArg(), timeout=mox.IgnoreArg(), + auth=mox.IgnoreArg(), + session=mox.IgnoreArg() ) openstack_shell.NeutronShell.interact().AndReturn(0) self.mox.ReplayAll() - openstack_shell.NeutronShell('2.0').run(['--os-cacert', CA_CERT]) + cmdline = ( + '--os-cacert %s --os-auth-url %s' % + (CA_CERT, auth.V3_URL)) + + openstack_shell.NeutronShell('2.0').run(cmdline.split()) self.mox.VerifyAll() + @httpretty.activate def test_ca_cert_passed_as_env_var(self): + + # emulate Keystone version discovery + httpretty.register_uri(httpretty.GET, + auth.V3_URL, + body=auth.V3_VERSION_ENTRY) + self.useFixture(fixtures.EnvironmentVariable('OS_CACERT', CA_CERT)) self.mox.StubOutWithMock(ClientManager, '__init__') @@ -100,11 +121,15 @@ class TestSSL(testtools.TestCase): raise_errors=mox.IgnoreArg(), log_credentials=mox.IgnoreArg(), timeout=mox.IgnoreArg(), + auth=mox.IgnoreArg(), + session=mox.IgnoreArg() ) openstack_shell.NeutronShell.interact().AndReturn(0) self.mox.ReplayAll() - openstack_shell.NeutronShell('2.0').run([]) + cmdline = ('--os-auth-url %s' % auth.V3_URL) + openstack_shell.NeutronShell('2.0').run(cmdline.split()) + self.mox.VerifyAll() def test_client_manager_properly_creates_httpclient_instance(self): @@ -121,8 +146,12 @@ class TestSSL(testtools.TestCase): tenant_name=mox.IgnoreArg(), token=mox.IgnoreArg(), username=mox.IgnoreArg(), - retries=mox.IgnoreArg(), - raise_errors=mox.IgnoreArg(), + user_id=mox.IgnoreArg(), + tenant_id=mox.IgnoreArg(), + timeout=mox.IgnoreArg(), + log_credentials=mox.IgnoreArg(), + service_type=mox.IgnoreArg(), + endpoint_type=mox.IgnoreArg() ) self.mox.ReplayAll() |