Add endpoint handling to Token/Endpoint auth

This auth plugin was initially created before get_endpoint was
available. Implement the get_endpoint method so that we can use the
plugin with relative URLs.

Closes-Bug: #1323926
Change-Id: Ic868f509e708ad29faf86ec5ceeab2a9c98a24fc
This commit is contained in:
Jamie Lennox
2014-04-30 11:58:17 +10:00
parent 0e834d2e9d
commit 1b519535f7

View File

@@ -33,3 +33,17 @@ class TokenEndpointTest(utils.TestCase):
self.assertEqual(data.text, 'body')
self.assertRequestHeaderEqual('X-Auth-Token', self.TEST_TOKEN)
@httpretty.activate
def test_basic_endpoint_case(self):
self.stub_url(httpretty.GET, ['p'], body='body')
a = token_endpoint.Token(self.TEST_URL, self.TEST_TOKEN)
s = session.Session(auth=a)
data = s.get('/p',
authenticated=True,
endpoint_filter={'service': 'identity'})
self.assertEqual(self.TEST_URL, a.get_endpoint(s))
self.assertEqual('body', data.text)
self.assertRequestHeaderEqual('X-Auth-Token', self.TEST_TOKEN)