summaryrefslogtreecommitdiff
path: root/keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py')
-rw-r--r--keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py102
1 files changed, 0 insertions, 102 deletions
diff --git a/keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py b/keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py
deleted file mode 100644
index 7fcf376..0000000
--- a/keystone_tempest_plugin/tests/api/identity/v3/test_mapping_rules.py
+++ /dev/null
@@ -1,102 +0,0 @@
1# Copyright 2016 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.lib.common.utils import data_utils
16from tempest.lib import decorators
17from tempest.lib import exceptions as lib_exc
18
19from keystone_tempest_plugin.tests.api.identity.v3 import fixtures
20from keystone_tempest_plugin.tests import base
21
22
23class MappingRulesTest(base.BaseIdentityTest):
24
25 _MAPPING_REF = fixtures.mapping_ref()
26
27 def _assert_mapping_rules_attributes(self, mapping, mapping_id,
28 mapping_ref=None):
29 self.assertIn('id', mapping)
30 self.assertEqual(mapping_id, mapping['id'])
31
32 self.assertIn('rules', mapping)
33
34 if mapping_ref:
35 self.assertItemsEqual(mapping_ref['rules'], mapping['rules'])
36
37 def _create_mapping_rule(self, mapping_id, mapping_ref):
38 mapping = self.mappings_client.create_mapping_rule(
39 mapping_id, mapping_ref)['mapping']
40 self.addCleanup(self.mappings_client.delete_mapping_rule, mapping_id)
41 return mapping
42
43 @decorators.idempotent_id('4ca48c01-b6da-4759-acb6-007e15ad712a')
44 def test_mapping_rules_create(self):
45 mapping_id = data_utils.rand_uuid_hex()
46 mapping = self._create_mapping_rule(mapping_id, self._MAPPING_REF)
47 self._assert_mapping_rules_attributes(
48 mapping, mapping_id, self._MAPPING_REF)
49
50 @decorators.attr(type=['negative'])
51 @decorators.idempotent_id('341dac45-ce1f-4f15-afdc-1f9a7d7d7c40')
52 def test_mapping_rules_create_without_mandatory_attributes_fails(self):
53 mapping_id = data_utils.rand_uuid_hex()
54 self.assertRaises(
55 lib_exc.BadRequest,
56 self.mappings_client.create_mapping_rule,
57 mapping_id,
58 {})
59
60 @decorators.idempotent_id('8db213e3-1db0-48c6-863c-7a3ed23577ec')
61 def test_mapping_rules_get(self):
62 mapping_id = data_utils.rand_uuid_hex()
63 mapping_create = self._create_mapping_rule(
64 mapping_id, self._MAPPING_REF)
65
66 mapping_get = self.mappings_client.show_mapping_rule(mapping_id)[
67 'mapping']
68 self._assert_mapping_rules_attributes(
69 mapping_get, mapping_id, mapping_create)
70
71 @decorators.idempotent_id('bb80b242-2a6a-4d29-b45f-4035be574a6e')
72 def test_mapping_rules_list(self):
73 mapping_ids = []
74 for _ in range(3):
75 mapping_id = data_utils.rand_uuid_hex()
76 self._create_mapping_rule(mapping_id, self._MAPPING_REF)
77 mapping_ids.append(mapping_id)
78
79 mappings_list = self.mappings_client.list_mapping_rules()['mappings']
80 fetched_ids = [mapping['id'] for mapping in mappings_list]
81
82 for mapping_id in mapping_ids:
83 self.assertIn(mapping_id, fetched_ids)
84
85 @decorators.idempotent_id('1fc5d104-faf5-4809-8c89-29b5c1666a96')
86 def test_mapping_rule_update(self):
87 mapping_id = data_utils.rand_uuid_hex()
88 mapping_ref = fixtures.mapping_ref()
89 mapping = self._create_mapping_rule(mapping_id, mapping_ref)
90
91 new_local = [{'group': {'id': data_utils.rand_uuid_hex()}}]
92 mapping_ref['rules'][0]['local'] = new_local
93
94 mapping = self.mappings_client.update_mapping_rule(
95 mapping_id, mapping_ref)['mapping']
96 self._assert_mapping_rules_attributes(
97 mapping, mapping_id, mapping_ref)
98
99 mapping_get = self.mappings_client.show_mapping_rule(mapping_id)[
100 'mapping']
101 self._assert_mapping_rules_attributes(
102 mapping_get, mapping_id, mapping)