| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import uuid |
| 14 |
|
| 15 |
from keystoneauth1 import fixture |
| 16 |
from keystoneauth1 import plugin |
| 17 |
|
| 18 |
from keystoneclient import access |
| 19 |
from keystoneclient.auth.identity import access as access_plugin |
| 20 |
from keystoneclient import session |
| 21 |
from keystoneclient.tests.unit import utils |
| 22 |
|
| 23 |
|
| 24 |
class AccessInfoPluginTests(utils.TestCase): |
| 25 |
|
| 26 |
def setUp(self): |
| 27 |
super(AccessInfoPluginTests, self).setUp() |
| 28 |
with self.deprecations.expect_deprecations_here(): |
| 29 |
self.session = session.Session() |
| 30 |
self.auth_token = uuid.uuid4().hex |
| 31 |
|
| 32 |
def _plugin(self, **kwargs): |
| 33 |
token = fixture.V3Token() |
| 34 |
s = token.add_service('identity') |
| 35 |
s.add_standard_endpoints(public=self.TEST_ROOT_URL) |
| 36 |
|
| 37 |
auth_ref = access.AccessInfo.factory(body=token, |
| 38 |
auth_token=self.auth_token) |
| 39 |
with self.deprecations.expect_deprecations_here(): |
| 40 |
return access_plugin.AccessInfoPlugin(auth_ref, **kwargs) |
| 41 |
|
| 42 |
def test_auth_ref(self): |
| 43 |
plugin = self._plugin() |
| 44 |
self.assertEqual(self.TEST_ROOT_URL, |
| 45 |
plugin.get_endpoint(self.session, |
| 46 |
service_type='identity', |
| 47 |
interface='public')) |
| 48 |
self.assertEqual(self.auth_token, plugin.get_token(session)) |
| 49 |
|
| 50 |
def test_auth_url(self): |
| 51 |
auth_url = 'http://keystone.test.url' |
| 52 |
plug = self._plugin(auth_url=auth_url) |
| 53 |
|
| 54 |
self.assertEqual(auth_url, |
| 55 |
plug.get_endpoint(self.session, |
| 56 |
interface=plugin.AUTH_INTERFACE)) |
| 57 |
|
| 58 |
def test_invalidate(self): |
| 59 |
plugin = self._plugin() |
| 60 |
auth_ref = plugin.auth_ref |
| 61 |
|
| 62 |
self.assertIsInstance(auth_ref, access.AccessInfo) |
| 63 |
self.assertFalse(plugin.invalidate()) |
| 64 |
self.assertIs(auth_ref, plugin.auth_ref) |