Debian Codegraph @

keystoneclient/tests/unit/auth/test_conf.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 from unittest import mock
14 import uuid
15
16 from oslo_config import cfg
17 from oslo_config import fixture as config
18
19 from keystoneclient.auth import base
20 from keystoneclient.auth import conf
21 from keystoneclient import exceptions
22 from keystoneclient.tests.unit.auth import utils
23
24
25 class ConfTests(utils.TestCase):
26
27 def setUp(self):
28 super(ConfTests, self).setUp()
29 self.deprecations.expect_deprecations()
30 self.conf_fixture = self.useFixture(config.Config())
31
32 # NOTE(jamielennox): we register the basic config options first because
33 # we need them in place before we can stub them. We will need to run
34 # the register again after we stub the auth section and auth plugin so
35 # it can load the plugin specific options.
36 conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
37
38 def test_loading_v2(self):
39 pass
40
41 def test_loading_v3(self):
42 pass
43
44 def test_loading_invalid_plugin(self):
45 auth_plugin = uuid.uuid4().hex
46 self.conf_fixture.config(auth_plugin=auth_plugin,
47 group=self.GROUP)
48
49 e = self.assertRaises(exceptions.NoMatchingPlugin,
50 conf.load_from_conf_options,
51 self.conf_fixture.conf,
52 self.GROUP)
53
54 self.assertEqual(auth_plugin, e.name)
55
56 def test_loading_with_no_data(self):
57 self.assertIsNone(conf.load_from_conf_options(self.conf_fixture.conf,
58 self.GROUP))
59
60 @mock.patch('stevedore.DriverManager')
61 def test_other_params(self, m):
62 m.return_value = utils.MockManager(utils.MockPlugin)
63 driver_name = uuid.uuid4().hex
64
65 self.conf_fixture.register_opts(utils.MockPlugin.get_options(),
66 group=self.GROUP)
67 self.conf_fixture.config(auth_plugin=driver_name,
68 group=self.GROUP,
69 **self.TEST_VALS)
70
71 a = conf.load_from_conf_options(self.conf_fixture.conf, self.GROUP)
72 self.assertTestVals(a)
73
74 m.assert_called_once_with(namespace=base.PLUGIN_NAMESPACE,
75 name=driver_name,
76 invoke_on_load=False)
77
78 @utils.mock_plugin
79 def test_same_section(self, m):
80 self.conf_fixture.register_opts(utils.MockPlugin.get_options(),
81 group=self.GROUP)
82 conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
83 self.conf_fixture.config(auth_plugin=uuid.uuid4().hex,
84 group=self.GROUP,
85 **self.TEST_VALS)
86
87 a = conf.load_from_conf_options(self.conf_fixture.conf, self.GROUP)
88 self.assertTestVals(a)
89
90 @utils.mock_plugin
91 def test_diff_section(self, m):
92 section = uuid.uuid4().hex
93
94 self.conf_fixture.config(auth_section=section, group=self.GROUP)
95 conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
96
97 self.conf_fixture.register_opts(utils.MockPlugin.get_options(),
98 group=section)
99 self.conf_fixture.config(group=section,
100 auth_plugin=uuid.uuid4().hex,
101 **self.TEST_VALS)
102
103 a = conf.load_from_conf_options(self.conf_fixture.conf, self.GROUP)
104 self.assertTestVals(a)
105
106 def test_plugins_are_all_opts(self):
107 pass
108
109 def test_get_common(self):
110 opts = conf.get_common_conf_options()
111 for opt in opts:
112 self.assertIsInstance(opt, cfg.Opt)
113 self.assertEqual(2, len(opts))
114
115 def test_get_named(self):
116 pass