2
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3
# not use this file except in compliance with the License. You may obtain
4
# a copy of the License at
6
# http://www.apache.org/licenses/LICENSE-2.0
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
# License for the specific language governing permissions and limitations
17
from .. import client # noqa
18
from .. import exceptions # noqa
21
class KeystoneRoleConstraintTest(testtools.TestCase):
23
def test_expected_exceptions(self):
24
self.assertEqual((exceptions.KeystoneRoleNotFound,),
25
client.KeystoneRoleConstraint.expected_exceptions,
26
"KeystoneRoleConstraint expected exceptions error")
28
def test_constrain(self):
29
constrain = client.KeystoneRoleConstraint()
30
client_mock = mock.MagicMock()
31
client_plugin_mock = mock.MagicMock()
32
client_plugin_mock.get_role_id.return_value = None
33
client_mock.client_plugin.return_value = client_plugin_mock
35
self.assertIsNone(constrain.validate_with_client(client_mock,
38
client_plugin_mock.get_role_id.assert_called_once_with('role_1')
41
class KeystoneProjectConstraintTest(testtools.TestCase):
43
def test_expected_exceptions(self):
44
self.assertEqual((exceptions.KeystoneProjectNotFound,),
45
client.KeystoneProjectConstraint.expected_exceptions,
46
"KeystoneProjectConstraint expected exceptions error")
48
def test_constrain(self):
49
constrain = client.KeystoneProjectConstraint()
50
client_mock = mock.MagicMock()
51
client_plugin_mock = mock.MagicMock()
52
client_plugin_mock.get_project_id.return_value = None
53
client_mock.client_plugin.return_value = client_plugin_mock
55
self.assertIsNone(constrain.validate_with_client(client_mock,
58
client_plugin_mock.get_project_id.assert_called_once_with('project_1')
61
class KeystoneGroupConstraintTest(testtools.TestCase):
63
def test_expected_exceptions(self):
64
self.assertEqual((exceptions.KeystoneGroupNotFound,),
65
client.KeystoneGroupConstraint.expected_exceptions,
66
"KeystoneGroupConstraint expected exceptions error")
68
def test_constrain(self):
69
constrain = client.KeystoneGroupConstraint()
70
client_mock = mock.MagicMock()
71
client_plugin_mock = mock.MagicMock()
72
client_plugin_mock.get_group_id.return_value = None
73
client_mock.client_plugin.return_value = client_plugin_mock
75
self.assertIsNone(constrain.validate_with_client(client_mock,
78
client_plugin_mock.get_group_id.assert_called_once_with('group_1')
81
class KeystoneDomainConstraintTest(testtools.TestCase):
83
def test_expected_exceptions(self):
84
self.assertEqual((exceptions.KeystoneDomainNotFound,),
85
client.KeystoneDomainConstraint.expected_exceptions,
86
"KeystoneDomainConstraint expected exceptions error")
88
def test_constrain(self):
89
constrain = client.KeystoneDomainConstraint()
90
client_mock = mock.MagicMock()
91
client_plugin_mock = mock.MagicMock()
92
client_plugin_mock.get_domain_id.return_value = None
93
client_mock.client_plugin.return_value = client_plugin_mock
95
self.assertIsNone(constrain.validate_with_client(client_mock,
98
client_plugin_mock.get_domain_id.assert_called_once_with('domain_1')
b'\\ No newline at end of file'