diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_swiftclient.py | 19 | ||||
-rw-r--r-- | tests/utils.py | 4 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 0584d39..08bf6cc 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -220,6 +220,25 @@ class TestGetAuth(MockHttpTest): self.assertTrue(url.startswith("http")) self.assertTrue(token) + def test_auth_v2_with_os_region_name(self): + os_options={'region_name': 'good-region', + 'tenant_name': 'asdf'} + c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options) + url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', + os_options=os_options, + auth_version="2.0") + self.assertTrue(url.startswith("http")) + self.assertTrue(token) + + def test_auth_v2_no_endpoint(self): + os_options={'region_name': 'unknown_region', + 'tenant_name': 'asdf'} + c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( + os_options, + c.ClientException) + self.assertRaises(c.ClientException, c.get_auth, + 'http://www.tests.com', 'asdf', 'asdf', + os_options=os_options, auth_version='2.0') class TestGetAccount(MockHttpTest): diff --git a/tests/utils.py b/tests/utils.py index ea6aeb3..570c2ea 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,11 +16,13 @@ from httplib import HTTPException from eventlet import Timeout, sleep -def fake_get_keystoneclient_2_0(os_options): +def fake_get_keystoneclient_2_0(os_options, exc=None): def fake_get_keystoneclient_2_0(auth_url, user, key, actual_os_options): + if exc: + raise exc('test') if actual_os_options != os_options: return "", None return ("http://url/", "token") |