diff --git a/keystone/contrib/federation/utils.py b/keystone/contrib/federation/utils.py index 5b0b4a5473..738d5a152f 100644 --- a/keystone/contrib/federation/utils.py +++ b/keystone/contrib/federation/utils.py @@ -51,8 +51,8 @@ MAPPING_SCHEMA = { "definitions": { "empty": { "type": "object", + "required": ['type'], "properties": { - "required": ['type'], "type": { "type": "string" }, diff --git a/keystone/tests/mapping_fixtures.py b/keystone/tests/mapping_fixtures.py index ce6a5d7922..1bd33127b0 100644 --- a/keystone/tests/mapping_fixtures.py +++ b/keystone/tests/mapping_fixtures.py @@ -209,3 +209,35 @@ MAPPING_MISSING_LOCAL = { } ] } + +MAPPING_WRONG_TYPE = { + "rules": [ + { + "local": [ + { + "user": "$1" + } + ], + "remote": [ + { + "not_type": "UserName" + } + ] + } + ] +} + +MAPPING_MISSING_TYPE = { + "rules": [ + { + "local": [ + { + "user": "$1" + } + ], + "remote": [ + {} + ] + } + ] +} diff --git a/keystone/tests/test_v3_federation.py b/keystone/tests/test_v3_federation.py index de7a7405d2..ff7e517bf8 100644 --- a/keystone/tests/test_v3_federation.py +++ b/keystone/tests/test_v3_federation.py @@ -551,3 +551,13 @@ class MappingTests(FederationTests): url = self.MAPPING_URL + uuid.uuid4().hex self.put(url, expected_status=400, body={'mapping': mapping_fixtures.MAPPING_MISSING_LOCAL}) + + def test_create_mapping_missing_type(self): + url = self.MAPPING_URL + uuid.uuid4().hex + self.put(url, expected_status=400, + body={'mapping': mapping_fixtures.MAPPING_MISSING_TYPE}) + + def test_create_mapping_wrong_type(self): + url = self.MAPPING_URL + uuid.uuid4().hex + self.put(url, expected_status=400, + body={'mapping': mapping_fixtures.MAPPING_WRONG_TYPE})