diff options
author | John Dickinson <me@not.mn> | 2014-02-13 23:33:01 -0800 |
---|---|---|
committer | John Dickinson <me@not.mn> | 2014-02-13 23:37:08 -0800 |
commit | 79f189a59352ee5b11a584924f5066b511b482b0 (patch) | |
tree | 4c2d8387ed24b0ab3fc9c58aedaadf83dcc27958 /tests | |
parent | 19d7e1812a99d73785146667ae2f3a7156f06898 (diff) | |
download | python-swiftclient-2.0.1.tar.gz |
Fix --insecure option on auth2.0.1
Change-Id: Ibe76d98d6075b84cbdb370b48f3498ab848142ad
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_swiftclient.py | 23 | ||||
-rw-r--r-- | tests/utils.py | 4 |
2 files changed, 24 insertions, 3 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 7a9f1f0..cb7a0c0 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -117,6 +117,9 @@ class MockHttpTest(testtools.TestCase): def request(method, url, *args, **kwargs): if query_string: self.assertTrue(url.endswith('?' + query_string)) + if url.endswith('invalid_cert') and not insecure: + from swiftclient import client as c + raise c.ClientException("invalid_certificate") return conn.request = request @@ -223,11 +226,25 @@ class TestGetAuth(MockHttpTest): auth_version="foo") def test_auth_v1(self): - c.http_connection = self.fake_http_connection(200) + c.http_connection = self.fake_http_connection(200, auth_v1=True) url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', auth_version="1.0") - self.assertEqual(url, None) - self.assertEqual(token, None) + self.assertEqual(url, 'storageURL') + self.assertEqual(token, 'someauthtoken') + + def test_auth_v1_insecure(self): + c.http_connection = self.fake_http_connection(200, auth_v1=True) + url, token = c.get_auth('http://www.test.com/invalid_cert', + 'asdf', 'asdf', + auth_version='1.0', + insecure=True) + self.assertEqual(url, 'storageURL') + self.assertEqual(token, 'someauthtoken') + + self.assertRaises(c.ClientException, c.get_auth, + 'http://www.test.com/invalid_cert', + 'asdf', 'asdf', + auth_version='1.0') def test_auth_v2(self): os_options = {'tenant_name': 'asdf'} diff --git a/tests/utils.py b/tests/utils.py index ff2834a..dcaca9e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -100,6 +100,10 @@ def fake_http_connect(*code_iter, **kwargs): headers['content-length'] = '4' if 'headers' in kwargs: headers.update(kwargs['headers']) + if 'auth_v1' in kwargs: + headers.update( + {'x-storage-url': 'storageURL', + 'x-auth-token': 'someauthtoken'}) return headers.items() def read(self, amt=None): |