Debian Codegraph @

keystoneclient/tests/unit/auth/test_access.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
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)