Debian Codegraph @

keystoneclient/tests/functional/v3/test_domain_configs.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.exceptions import http
16 from keystoneclient.tests.functional import base
17 from keystoneclient.tests.functional.v3 import client_fixtures as fixtures
18
19
20 class DomainConfigsTestCase(base.V3ClientTestCase):
21
22 def setUp(self):
23 super(DomainConfigsTestCase, self).setUp()
24 self.test_domain = fixtures.Domain(self.client)
25 self.useFixture(self.test_domain)
26
27 def check_domain_config(self, config, config_ref):
28 for attr in config_ref:
29 self.assertEqual(
30 getattr(config, attr),
31 config_ref[attr],
32 'Expected different %s' % attr)
33
34 def _new_ref(self):
35 return {'identity': {'driver': uuid.uuid4().hex},
36 'ldap': {'url': uuid.uuid4().hex}}
37
38 def test_create_domain_config(self):
39 config_ref = self._new_ref()
40 config = self.client.domain_configs.create(
41 self.test_domain.id, config_ref)
42 self.addCleanup(
43 self.client.domain_configs.delete, self.test_domain.id)
44 self.check_domain_config(config, config_ref)
45
46 def test_create_invalid_domain_config(self):
47 invalid_groups_ref = {
48 uuid.uuid4().hex: {uuid.uuid4().hex: uuid.uuid4().hex},
49 uuid.uuid4().hex: {uuid.uuid4().hex: uuid.uuid4().hex}}
50 self.assertRaises(http.Forbidden,
51 self.client.domain_configs.create,
52 self.test_domain.id,
53 invalid_groups_ref)
54
55 invalid_options_ref = {
56 'identity': {uuid.uuid4().hex: uuid.uuid4().hex},
57 'ldap': {uuid.uuid4().hex: uuid.uuid4().hex}}
58 self.assertRaises(http.Forbidden,
59 self.client.domain_configs.create,
60 self.test_domain.id,
61 invalid_options_ref)
62
63 def test_get_domain_config(self):
64 config = fixtures.DomainConfig(self.client, self.test_domain.id)
65 self.useFixture(config)
66
67 config_ret = self.client.domain_configs.get(self.test_domain.id)
68 self.check_domain_config(config_ret, config.ref)
69
70 def test_update_domain_config(self):
71 config = fixtures.DomainConfig(self.client, self.test_domain.id)
72 self.useFixture(config)
73
74 update_config_ref = self._new_ref()
75 config_ret = self.client.domain_configs.update(
76 self.test_domain.id, update_config_ref)
77 self.check_domain_config(config_ret, update_config_ref)
78
79 def test_update_invalid_domain_config(self):
80 config = fixtures.DomainConfig(self.client, self.test_domain.id)
81 self.useFixture(config)
82
83 invalid_groups_ref = {
84 uuid.uuid4().hex: {uuid.uuid4().hex: uuid.uuid4().hex},
85 uuid.uuid4().hex: {uuid.uuid4().hex: uuid.uuid4().hex}}
86 self.assertRaises(http.Forbidden,
87 self.client.domain_configs.update,
88 self.test_domain.id,
89 invalid_groups_ref)
90
91 invalid_options_ref = {
92 'identity': {uuid.uuid4().hex: uuid.uuid4().hex},
93 'ldap': {uuid.uuid4().hex: uuid.uuid4().hex}}
94 self.assertRaises(http.Forbidden,
95 self.client.domain_configs.update,
96 self.test_domain.id,
97 invalid_options_ref)
98
99 def test_domain_config_delete(self):
100 config_ref = self._new_ref()
101 self.client.domain_configs.create(self.test_domain.id, config_ref)
102
103 self.client.domain_configs.delete(self.test_domain.id)
104 self.assertRaises(http.NotFound,
105 self.client.domain_configs.get,
106 self.project_domain_id)