summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swiftclient/client.py2
-rw-r--r--tests/unit/test_swiftclient.py27
-rw-r--r--tox.ini9
3 files changed, 29 insertions, 9 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 4819c12..a2d7ada 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -1290,7 +1290,7 @@ class Connection(object):
self.starting_backoff = starting_backoff
self.max_backoff = max_backoff
self.auth_version = auth_version
- self.os_options = os_options or {}
+ self.os_options = dict(os_options or {})
if tenant_name:
self.os_options['tenant_name'] = tenant_name
if preauthurl:
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 97ae467..23b3138 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -1481,6 +1481,33 @@ class TestConnection(MockHttpTest):
('HEAD', '/v1/AUTH_pre_url', '', {'x-auth-token': 'post_token'}),
])
+ def test_preauth_url_trumps_os_preauth_url(self):
+ storage_url = 'http://storage.example.com/v1/AUTH_pre_url'
+ os_storage_url = 'http://storage.example.com/v1/AUTH_os_pre_url'
+ os_preauth_options = {
+ 'tenant_name': 'demo',
+ 'object_storage_url': os_storage_url,
+ }
+ orig_os_preauth_options = dict(os_preauth_options)
+ conn = c.Connection('http://auth.example.com', 'user', 'password',
+ os_options=os_preauth_options, auth_version=2,
+ preauthurl=storage_url, tenant_name='not_demo')
+ fake_keystone = fake_get_auth_keystone(
+ storage_url='http://storage.example.com/v1/AUTH_post_url',
+ token='post_token')
+ fake_conn = self.fake_http_connection(200)
+ with mock.patch.multiple('swiftclient.client',
+ get_auth_keystone=fake_keystone,
+ http_connection=fake_conn,
+ sleep=mock.DEFAULT):
+ conn.head_account()
+ self.assertRequests([
+ ('HEAD', '/v1/AUTH_pre_url', '', {'x-auth-token': 'post_token'}),
+ ])
+
+ # check that Connection has not modified our os_options
+ self.assertEqual(orig_os_preauth_options, os_preauth_options)
+
def test_get_auth_sets_url_and_token(self):
with mock.patch('swiftclient.client.get_auth') as mock_get_auth:
mock_get_auth.return_value = (
diff --git a/tox.ini b/tox.ini
index 207d3c3..8a70619 100644
--- a/tox.ini
+++ b/tox.ini
@@ -43,19 +43,12 @@ commands=
[flake8]
# it's not a bug that we aren't using all of hacking, ignore:
# H101: Use TODO(NAME)
-# H202: assertRaises Exception too broad
-# H232: Python 3.x incompatible octal 000001234 should be written as 0o1234
-# H233: Python 3.x incompatible use of print operator
-# H235: assert_ is deprecated, use assertTrue
# H301: one import per line
# H306: imports not in alphabetical order (time, os)
# H401: docstring should not start with a space
# H403: multi line docstrings should end on a new line
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
-# H501: Do not use self.__dict__ for string formatting
-# H702: Formatting operation should be outside of localization method call
-# H703: Multiple positional placeholders
-ignore = H101,H202,H232,H233,H235,H301,H306,H401,H403,H404,H405,H501,H702,H703
+ignore = H101,H301,H306,H401,H403,H404,H405
show-source = True
exclude = .venv,.tox,dist,doc,*egg