Created
February 14, 2014 06:24
-
-
Save smerritt/8996613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swiftclient/client.py b/swiftclient/client.py | |
index ee80769..275c6b7 100644 | |
--- a/swiftclient/client.py | |
+++ b/swiftclient/client.py | |
@@ -219,8 +219,9 @@ def http_connection(*arg, **kwarg): | |
return conn.parsed_url, conn | |
-def get_auth_1_0(url, user, key, snet): | |
- parsed, conn = http_connection(url) | |
+def get_auth_1_0(url, user, key, snet, **kwargs): | |
+ insecure = kwargs.get('insecure', False) | |
+ parsed, conn = http_connection(url, insecure=insecure) | |
method = 'GET' | |
conn.request(method, parsed.path, '', | |
{'X-Auth-User': user, 'X-Auth-Key': key}) | |
@@ -307,11 +308,13 @@ def get_auth(auth_url, user, key, **kwargs): | |
os_options = kwargs.get('os_options', {}) | |
storage_url, token = None, None | |
+ insecure = kwargs.get('insecure', False) | |
if auth_version in ['1.0', '1', 1]: | |
storage_url, token = get_auth_1_0(auth_url, | |
user, | |
key, | |
- kwargs.get('snet')) | |
+ kwargs.get('snet'), | |
+ insecure=insecure) | |
elif auth_version in ['2.0', '2', 2]: | |
# We are allowing to specify a token/storage-url to re-use | |
# without having to re-authenticate. | |
@@ -335,7 +338,6 @@ def get_auth(auth_url, user, key, **kwargs): | |
if (not 'tenant_name' in os_options): | |
raise ClientException('No tenant specified') | |
- insecure = kwargs.get('insecure', False) | |
cacert = kwargs.get('cacert', None) | |
storage_url, token = get_keystoneclient_2_0(auth_url, user, | |
key, os_options, | |
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py | |
index 7a9f1f0..f33f395 100644 | |
--- a/tests/test_swiftclient.py | |
+++ b/tests/test_swiftclient.py | |
@@ -229,6 +229,27 @@ class TestGetAuth(MockHttpTest): | |
self.assertEqual(url, None) | |
self.assertEqual(token, None) | |
+ def test_auth_v1_insecure(self): | |
+ got_insecures = [] | |
+ | |
+ fake_hc = self.fake_http_connection(200) | |
+ | |
+ def mock_hc(*a, **kw): | |
+ got_insecures.append(kw.get('insecure')) | |
+ return fake_hc(*a, **kw) | |
+ | |
+ with mock.patch.object(c, 'http_connection', mock_hc): | |
+ c.get_auth('https://example.com/', 'asdf', 'asdf', | |
+ auth_version='1.0') | |
+ c.get_auth('https://example.com/', 'asdf', 'asdf', | |
+ auth_version='1.0', | |
+ insecure=False) | |
+ c.get_auth('https://example.com/', 'asdf', 'asdf', | |
+ auth_version='1.0', | |
+ insecure=True) | |
+ | |
+ self.assertEqual(got_insecures, [False, False, True]) | |
+ | |
def test_auth_v2(self): | |
os_options = {'tenant_name': 'asdf'} | |
c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment