summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorRoxana Gherle <roxana.gherle@hp.com>2015-05-22 16:22:35 -0700
committerRoxana Gherle <roxana.gherle@hp.com>2015-07-02 10:10:46 -0700
commit5521e4c504c6a3a06f17a9e4f80444743aa293c7 (patch)
treea07d4db3dae479087997bf60c3f1a434afdcdd8a /openstackclient/tests
parent7e067c6f4f2dddfd9ea4b4a3df90959a7d8f2f0f (diff)
downloadpython-openstackclient-5521e4c504c6a3a06f17a9e4f80444743aa293c7.tar.gz
Add --os-endpoint-type cli optional argument
User should be able to specify the endpoint type through a CLI optional argument/ENV variable setting. We will name this new optional argument: --os-endpoint-type (Env: OS_ENDPOINT_TYPE) and based on the value given, the service API will use that specific endpoint type. Possible values: public, admin, internal. DocImpact Closes-Bug: #1454392 Change-Id: Ife3d4e46b44c0ddcd712b1130e27e362545a9a29
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/common/test_clientmanager.py11
-rw-r--r--openstackclient/tests/common/test_utils.py10
-rw-r--r--openstackclient/tests/fakes.py2
-rw-r--r--openstackclient/tests/test_shell.py8
4 files changed, 31 insertions, 0 deletions
diff --git a/openstackclient/tests/common/test_clientmanager.py b/openstackclient/tests/common/test_clientmanager.py
index 4e2f46b4..e86ef509 100644
--- a/openstackclient/tests/common/test_clientmanager.py
+++ b/openstackclient/tests/common/test_clientmanager.py
@@ -54,6 +54,7 @@ class FakeOptions(object):
self.identity_api_version = '2.0'
self.timing = None
self.region_name = None
+ self.endpoint_type = None
self.url = None
self.auth = {}
self.default_domain = 'default'
@@ -123,6 +124,8 @@ class TestClientManager(utils.TestCase):
auth_url=fakes.AUTH_URL,
),
auth_type='v2token',
+ endpoint_type=fakes.ENDPOINT_TYPE,
+ region_name=fakes.REGION_NAME,
),
api_version=API_VERSION,
verify=True
@@ -137,6 +140,14 @@ class TestClientManager(utils.TestCase):
client_manager.auth,
auth_v2.Token,
)
+ self.assertEqual(
+ fakes.ENDPOINT_TYPE,
+ client_manager._endpoint_type,
+ )
+ self.assertEqual(
+ fakes.REGION_NAME,
+ client_manager._region_name,
+ )
self.assertFalse(client_manager._insecure)
self.assertTrue(client_manager._verify)
diff --git a/openstackclient/tests/common/test_utils.py b/openstackclient/tests/common/test_utils.py
index d9f5b7a5..a25a5ba5 100644
--- a/openstackclient/tests/common/test_utils.py
+++ b/openstackclient/tests/common/test_utils.py
@@ -159,6 +159,16 @@ class TestUtils(test_utils.TestCase):
self.assertFalse(utils.wait_for_delete(manager, res_id))
self.assertFalse(mock_sleep.called)
+ def test_build_kwargs_dict_value_set(self):
+ self.assertEqual({'arg_bla': 'bla'},
+ utils.build_kwargs_dict('arg_bla', 'bla'))
+
+ def test_build_kwargs_dict_value_None(self):
+ self.assertEqual({}, utils.build_kwargs_dict('arg_bla', None))
+
+ def test_build_kwargs_dict_value_empty_str(self):
+ self.assertEqual({}, utils.build_kwargs_dict('arg_bla', ''))
+
class NoUniqueMatch(Exception):
pass
diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py
index 323f9543..a9322ec3 100644
--- a/openstackclient/tests/fakes.py
+++ b/openstackclient/tests/fakes.py
@@ -26,6 +26,8 @@ AUTH_URL = "http://0.0.0.0"
USERNAME = "itchy"
PASSWORD = "scratchy"
PROJECT_NAME = "poochie"
+REGION_NAME = "richie"
+ENDPOINT_TYPE = "catchy"
TEST_RESPONSE_DICT = fixture.V2Token(token_id=AUTH_TOKEN,
user_name=USERNAME)
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index b080ae91..674d8345 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -38,6 +38,7 @@ DEFAULT_REGION_NAME = "ZZ9_Plural_Z_Alpha"
DEFAULT_TOKEN = "token"
DEFAULT_SERVICE_URL = "http://127.0.0.1:8771/v3.0/"
DEFAULT_AUTH_PLUGIN = "v2password"
+DEFAULT_ENDPOINT_TYPE = "internal"
DEFAULT_COMPUTE_API_VERSION = "2"
DEFAULT_IDENTITY_API_VERSION = "2"
@@ -61,6 +62,7 @@ CLOUD_1 = {
},
'region_name': 'occ-cloud',
'donut': 'glazed',
+ 'endpoint_type': 'public',
}
}
}
@@ -104,6 +106,7 @@ global_options = {
'--os-default-domain': (DEFAULT_DOMAIN_NAME, True, True),
'--os-cacert': ('/dev/null', True, True),
'--timing': (True, True, False),
+ '--os-endpoint-type': (DEFAULT_ENDPOINT_TYPE, True, True)
}
auth_options = {
@@ -123,6 +126,7 @@ auth_options = {
'--os-auth-type': ("v2password", True, True),
'--os-token': (DEFAULT_TOKEN, True, True),
'--os-url': (DEFAULT_SERVICE_URL, True, True),
+ '--os-endpoint-type': (DEFAULT_ENDPOINT_TYPE, True, True),
}
@@ -608,6 +612,10 @@ class TestShellCli(TestShell):
'glazed',
_shell.cloud.config['donut'],
)
+ self.assertEqual(
+ 'public',
+ _shell.cloud.config['endpoint_type'],
+ )
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")