Debian Codegraph @

mistralclient/tests/unit/v2/test_keystone.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain 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,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12 import mistralclient.auth.keystone
13 from mistralclient.tests.unit.v2 import base
14
15
16 class TestKeystone(base.BaseClientV2Test):
17 def setUp(self):
18 super(TestKeystone, self).setUp()
19 self.keystone = mistralclient.auth.keystone.KeystoneAuthHandler()
20
21 def test_get_auth_token(self):
22 auth = self.keystone._get_auth(
23 auth_token="token",
24 auth_url="url",
25 project_id="project_id",
26 )
27
28 self.assertEqual("url", auth.auth_url)
29 elements = auth.get_cache_id_elements()
30 self.assertIsNotNone(elements["token"])
31 self.assertIsNotNone(elements["project_id"])
32
33 def test_remove_domain(self):
34 params = {
35 "param1": "p",
36 "target_param2": "p2",
37 "user_domain_param3": "p3",
38 "target_project_domain_param4": "p4"
39 }
40 dedomained = self.keystone._remove_domain(params)
41 self.assertIn("param1", dedomained)
42 self.assertIn("target_param2", dedomained)
43 self.assertNotIn("user_domain_param3", dedomained)
44 self.assertNotIn("target_project_domain_param4", dedomained)
45
46 def test_separate_target_reqs(self):
47 params = {
48 "a": 1,
49 "target_b": 2,
50 "c": 3,
51 "target_d": 4,
52 "target_target": 5,
53 "param_target": 6
54 }
55 nontarget, target = self.keystone._separate_target_reqs(params)
56 self.assertIn("a", nontarget)
57 self.assertIn("c", nontarget)
58 self.assertIn("param_target", nontarget)
59 self.assertIn("b", target)
60 self.assertIn("d", target)
61 self.assertIn("target", target)
62
63 def test_verify(self):
64 self.assertTrue(self.keystone._verification_needed("", False))
65 self.assertFalse(self.keystone._verification_needed("", True))
66 self.assertFalse(self.keystone._verification_needed("cert", True))
67 self.assertEqual(
68 self.keystone._verification_needed("cert", False),
69 "cert"
70 )