summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-12-03 12:08:40 +0000
committerGerrit Code Review <review@openstack.org>2014-12-03 12:08:40 +0000
commit69981798bc2b4b02415e04c26983f3b1f37a3b63 (patch)
treed318b824dc6374c1a79b8141bec3087ff58ead5c /tests
parent6a6a5eff077bce9362728b46db1dee96c5943230 (diff)
parent5080d100999b17e86b62d463474affe2a4f1ed05 (diff)
downloadpython-glanceclient-69981798bc2b4b02415e04c26983f3b1f37a3b63.tar.gz
Merge "Send `identity_headers` through the wire"
Diffstat (limited to 'tests')
-rw-r--r--tests/test_http.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_http.py b/tests/test_http.py
index 31cd6d5..54e56e2 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -14,6 +14,7 @@
# under the License.
import json
+import mock
from mox3 import mox
import requests
import six
@@ -91,6 +92,31 @@ class TestClient(testtools.TestCase):
self.assertIsNone(http_client_object.auth_token)
self.assertNotIn('X-Auth-Token', http_client_object.session.headers)
+ def test_identity_headers_are_passed(self):
+ # Tests that if token or X-Auth-Token are not provided in the kwargs
+ # when creating the http client, the session headers don't contain
+ # the X-Auth-Token key.
+ identity_headers = {
+ 'X-User-Id': 'user',
+ 'X-Tenant-Id': 'tenant',
+ 'X-Roles': 'roles',
+ 'X-Identity-Status': 'Confirmed',
+ 'X-Service-Catalog': 'service_catalog',
+ }
+ kwargs = {'identity_headers': identity_headers}
+ http_client = http.HTTPClient(self.endpoint, **kwargs)
+
+ def check_headers(*args, **kwargs):
+ headers = kwargs.get('headers')
+ for k, v in six.iteritems(identity_headers):
+ self.assertEqual(v, headers[k])
+
+ return utils.FakeResponse({}, six.StringIO('{}'))
+
+ with mock.patch.object(http_client.session, 'request') as mreq:
+ mreq.side_effect = check_headers
+ http_client.get('http://example.com:9292/v1/images/my-image')
+
def test_connection_refused(self):
"""
Should receive a CommunicationError if connection refused.