diff options
| author | Ionuț Arțăriși <iartarisi@suse.cz> | 2012-09-13 15:45:40 +0200 |
|---|---|---|
| committer | Ionuț Arțăriși <iartarisi@suse.cz> | 2012-10-22 17:47:26 +0200 |
| commit | 56a4e4bd7da1353684d34e5a9817b88501e41d8c (patch) | |
| tree | 8e974d319118ba8f738288410d0960370ecea4e3 /tests | |
| parent | e04b0e16ae4ef3c63cedf05979cca93595f34f28 (diff) | |
| download | python-keystoneclient-56a4e4bd7da1353684d34e5a9817b88501e41d8c.tar.gz | |
add a new HTTPClient attr for setting the original IP
The original IP is useful in cases where keystoneclient is used by a
different openstack component and we need to know who made the original
request. Otherwise it gets overwritten by e.g. Dashboard's host's IP.
bug 1046837
Change-Id: Ic22c565e92010afd89c8573c375919215b70d73d
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_http.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_http.py b/tests/test_http.py index 676cee6..2e09642 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -62,3 +62,17 @@ class ClientTest(utils.TestCase): } mock_request.assert_called_with("http://127.0.0.1:5000/hi", "POST", headers=headers, body='[1, 2, 3]') + + def test_forwarded_for(self): + ORIGINAL_IP = "10.100.100.1" + cl = client.HTTPClient(username="username", password="password", + tenant_id="tenant", auth_url="auth_test", + original_ip=ORIGINAL_IP) + + with mock.patch.object(httplib2.Http, "request", mock_request): + res = cl.request('/', 'GET') + + args, kwargs = mock_request.call_args + self.assertIn( + ('Forwarded', "for=%s;by=%s" % (ORIGINAL_IP, cl.USER_AGENT)), + kwargs['headers'].items()) |
