Introduce `schema_version` in the federated attribute mapping API
Depends-On: https://review.opendev.org/c/openstack/keystone/+/739966 Change-Id: I276ebd49094368dd823e50ff11a6e65fa2a6dcfb
This commit is contained in:
parent
dc8d9d3541
commit
2ed10e9a72
|
@ -81,6 +81,21 @@ class _RulesReader(object):
|
||||||
else:
|
else:
|
||||||
return rules
|
return rules
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def add_federated_schema_version_option(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--schema-version',
|
||||||
|
metavar='<schema_version>',
|
||||||
|
required=False,
|
||||||
|
default=None,
|
||||||
|
help=_(
|
||||||
|
"The federated attribute mapping schema version. The "
|
||||||
|
"default value on the client side is 'None'; however, that "
|
||||||
|
"will lead the backend to set the default according to "
|
||||||
|
"'attribute_mapping_default_schema_version' option."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CreateMapping(command.ShowOne, _RulesReader):
|
class CreateMapping(command.ShowOne, _RulesReader):
|
||||||
_description = _("Create new mapping")
|
_description = _("Create new mapping")
|
||||||
|
@ -98,6 +113,7 @@ class CreateMapping(command.ShowOne, _RulesReader):
|
||||||
required=True,
|
required=True,
|
||||||
help=_('Filename that contains a set of mapping rules (required)'),
|
help=_('Filename that contains a set of mapping rules (required)'),
|
||||||
)
|
)
|
||||||
|
_RulesReader.add_federated_schema_version_option(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
@ -105,7 +121,9 @@ class CreateMapping(command.ShowOne, _RulesReader):
|
||||||
|
|
||||||
rules = self._read_rules(parsed_args.rules)
|
rules = self._read_rules(parsed_args.rules)
|
||||||
mapping = identity_client.federation.mappings.create(
|
mapping = identity_client.federation.mappings.create(
|
||||||
mapping_id=parsed_args.mapping, rules=rules
|
mapping_id=parsed_args.mapping,
|
||||||
|
rules=rules,
|
||||||
|
schema_version=parsed_args.schema_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping._info.pop('links', None)
|
mapping._info.pop('links', None)
|
||||||
|
@ -158,7 +176,7 @@ class ListMapping(command.Lister):
|
||||||
# rules, (s)he should show specific ones.
|
# rules, (s)he should show specific ones.
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
data = identity_client.federation.mappings.list()
|
data = identity_client.federation.mappings.list()
|
||||||
columns = ('ID',)
|
columns = ('ID', 'schema_version')
|
||||||
items = [utils.get_item_properties(s, columns) for s in data]
|
items = [utils.get_item_properties(s, columns) for s in data]
|
||||||
return (columns, items)
|
return (columns, items)
|
||||||
|
|
||||||
|
@ -178,6 +196,8 @@ class SetMapping(command.Command, _RulesReader):
|
||||||
metavar='<filename>',
|
metavar='<filename>',
|
||||||
help=_('Filename that contains a new set of mapping rules'),
|
help=_('Filename that contains a new set of mapping rules'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_RulesReader.add_federated_schema_version_option(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
@ -186,7 +206,9 @@ class SetMapping(command.Command, _RulesReader):
|
||||||
rules = self._read_rules(parsed_args.rules)
|
rules = self._read_rules(parsed_args.rules)
|
||||||
|
|
||||||
mapping = identity_client.federation.mappings.update(
|
mapping = identity_client.federation.mappings.update(
|
||||||
mapping=parsed_args.mapping, rules=rules
|
mapping=parsed_args.mapping,
|
||||||
|
rules=rules,
|
||||||
|
schema_version=parsed_args.schema_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping._info.pop('links', None)
|
mapping._info.pop('links', None)
|
||||||
|
|
|
@ -63,6 +63,7 @@ class TestMappingCreate(TestMapping):
|
||||||
self.mapping_mock.create.assert_called_with(
|
self.mapping_mock.create.assert_called_with(
|
||||||
mapping_id=identity_fakes.mapping_id,
|
mapping_id=identity_fakes.mapping_id,
|
||||||
rules=identity_fakes.MAPPING_RULES,
|
rules=identity_fakes.MAPPING_RULES,
|
||||||
|
schema_version=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
collist = ('id', 'rules')
|
collist = ('id', 'rules')
|
||||||
|
@ -106,12 +107,12 @@ class TestMappingList(TestMapping):
|
||||||
self.mapping_mock.list.return_value = [
|
self.mapping_mock.list.return_value = [
|
||||||
fakes.FakeResource(
|
fakes.FakeResource(
|
||||||
None,
|
None,
|
||||||
{'id': identity_fakes.mapping_id},
|
{'id': identity_fakes.mapping_id, 'schema_version': '1.0'},
|
||||||
loaded=True,
|
loaded=True,
|
||||||
),
|
),
|
||||||
fakes.FakeResource(
|
fakes.FakeResource(
|
||||||
None,
|
None,
|
||||||
{'id': 'extra_mapping'},
|
{'id': 'extra_mapping', 'schema_version': '2.0'},
|
||||||
loaded=True,
|
loaded=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -128,10 +129,13 @@ class TestMappingList(TestMapping):
|
||||||
|
|
||||||
self.mapping_mock.list.assert_called_with()
|
self.mapping_mock.list.assert_called_with()
|
||||||
|
|
||||||
collist = ('ID',)
|
collist = ('ID', 'schema_version')
|
||||||
self.assertEqual(collist, columns)
|
self.assertEqual(collist, columns)
|
||||||
|
|
||||||
datalist = [(identity_fakes.mapping_id,), ('extra_mapping',)]
|
datalist = [
|
||||||
|
(identity_fakes.mapping_id, '1.0'),
|
||||||
|
('extra_mapping', '2.0'),
|
||||||
|
]
|
||||||
self.assertEqual(datalist, data)
|
self.assertEqual(datalist, data)
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,6 +177,7 @@ class TestMappingSet(TestMapping):
|
||||||
self.mapping_mock.update.assert_called_with(
|
self.mapping_mock.update.assert_called_with(
|
||||||
mapping=identity_fakes.mapping_id,
|
mapping=identity_fakes.mapping_id,
|
||||||
rules=identity_fakes.MAPPING_RULES_2,
|
rules=identity_fakes.MAPPING_RULES_2,
|
||||||
|
schema_version=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
Loading…
Reference in New Issue