diff options
author | Juan Antonio Osorio Robles <juan.osorio.robles@ericsson.com> | 2015-06-29 15:06:53 +0300 |
---|---|---|
committer | Juan Antonio Osorio Robles <juan.osorio.robles@ericsson.com> | 2015-07-06 14:33:52 +0300 |
commit | d6ae7b064de36552dde1e111734e3b7aec599a1f (patch) | |
tree | 2436691d53759a86862beb1c6b3d50a7ddf48527 /functionaltests | |
parent | 8cebffdffb9b85003972b1bdd611ace203c2a657 (diff) | |
download | python-barbicanclient-d6ae7b064de36552dde1e111734e3b7aec599a1f.tar.gz |
Enable endpoint filter parameters for the CLI
Currently the barbican client library can take parameters necessary for
keystone to give a proper endpoint given certain options. these options
could be 'service type', 'service name', 'region name', 'interface' and
'version'. These options, however, were not available from the CLI. So
the user would be stuck with the default options; which are not really
useful if you're trying to access the barbican instance from another
region.
This CR enables such options for the CLI also.
Change-Id: I66f9ec4d1330297c11bad0336decef5465a80cc3
Diffstat (limited to 'functionaltests')
-rw-r--r-- | functionaltests/client/test_client_connectivity.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/functionaltests/client/test_client_connectivity.py b/functionaltests/client/test_client_connectivity.py index 0306769..21ad689 100644 --- a/functionaltests/client/test_client_connectivity.py +++ b/functionaltests/client/test_client_connectivity.py @@ -20,6 +20,7 @@ from barbicanclient import client from barbicanclient import exceptions from keystoneclient.auth import identity from keystoneclient import session +import keystoneclient.openstack.common.apiclient.exceptions as ks_exceptions CONF = config.get_config() @@ -70,6 +71,14 @@ class WhenTestingClientConnectivity(BaseTestCase): self.assertRaises(exceptions.HTTPClientError, client.orders.list) self.assertRaises(exceptions.HTTPClientError, client.secrets.list) + def assert_client_cannot_get_endpoint(self, client): + self.assertRaises(ks_exceptions.EndpointNotFound, + client.containers.list) + self.assertRaises(ks_exceptions.EndpointNotFound, + client.orders.list) + self.assertRaises(ks_exceptions.EndpointNotFound, + client.secrets.list) + def test_can_access_server_if_endpoint_and_session_specified(self): barbicanclient = client.Client( endpoint=CONF.keymanager.url, @@ -93,6 +102,71 @@ class WhenTestingClientConnectivity(BaseTestCase): self.assert_client_can_contact_barbican(barbicanclient) + def test_client_can_access_server_if_endpoint_filters_specified(self): + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface=client._DEFAULT_SERVICE_INTERFACE, + service_type=client._DEFAULT_SERVICE_TYPE, + version=client._DEFAULT_API_VERSION, + ) + + self.assert_client_can_contact_barbican(barbicanclient) + + def test_client_cannot_access_server_if_endpoint_filter_wrong(self): + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface=client._DEFAULT_SERVICE_INTERFACE, + service_type='wrong-service-type', + version=client._DEFAULT_API_VERSION, + ) + + self.assert_client_cannot_get_endpoint(barbicanclient) + + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface='wrong-interface', + service_type=client._DEFAULT_SERVICE_TYPE, + version=client._DEFAULT_API_VERSION, + ) + + self.assert_client_cannot_get_endpoint(barbicanclient) + + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface=client._DEFAULT_SERVICE_INTERFACE, + service_type=client._DEFAULT_SERVICE_TYPE, + service_name='wrong-service-name', + version=client._DEFAULT_API_VERSION, + ) + + self.assert_client_cannot_get_endpoint(barbicanclient) + + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface=client._DEFAULT_SERVICE_INTERFACE, + service_type=client._DEFAULT_SERVICE_TYPE, + region_name='wrong-region-name', + version=client._DEFAULT_API_VERSION, + ) + + self.assert_client_cannot_get_endpoint(barbicanclient) + + def test_client_cannot_access_server_if_nonexistent_version_specified(self): + barbicanclient = client.Client( + project_id=CONF.keymanager.project_id, + auth=self.auth, + interface=client._DEFAULT_SERVICE_INTERFACE, + service_type=client._DEFAULT_SERVICE_TYPE, + version='wrong-version', + ) + + self.assertRaises(TypeError, barbicanclient.containers.list) + def test_client_cannot_access_server_if_nonexistent_version_specified(self): barbicanclient = client.Client( endpoint=CONF.keymanager.url, |