Add required properties field to rules schema
Added an extra field in the JSON schema for mapping rules, that specifies which properites are required. There is a specific remote rule that may only have a type key. This ensures that no other keys are specified. Change-Id: I80f0e5b4bdc275db2d6cd06a81968cef33423a4d
This commit is contained in:
parent
4fc6e97097
commit
77c0fe4a1c
|
@ -51,8 +51,8 @@ MAPPING_SCHEMA = {
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"empty": {
|
"empty": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
|
||||||
"required": ['type'],
|
"required": ['type'],
|
||||||
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -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": [
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -551,3 +551,13 @@ class MappingTests(FederationTests):
|
||||||
url = self.MAPPING_URL + uuid.uuid4().hex
|
url = self.MAPPING_URL + uuid.uuid4().hex
|
||||||
self.put(url, expected_status=400,
|
self.put(url, expected_status=400,
|
||||||
body={'mapping': mapping_fixtures.MAPPING_MISSING_LOCAL})
|
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})
|
||||||
|
|
Loading…
Reference in New Issue