| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 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 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 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 |