blob: 16f8dfa604b0a3b998fc9dede5574ea6e1cfd2f8 [file] [log] [blame]
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Security rules schema",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"rule": {
"type": "string"
},
"configuration": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"parameter": {
"type": "string"
},
"value": {
"anyOf": [
{
"type": ["string", "number", "boolean"]
},
{
"type": "array",
"items": {
"type": ["string", "number", "boolean"]
}
}
]
}
}
},
"required": [
"parameter"
]
}
},
"required": [
"type", "rule"
],
"additionalProperties": false
},
"tests": [
{
"id": "VALID_1",
"description": "type, rule, and multiple configurations with array, string, number, and boolean value types",
"data": [
{
"type": "customType",
"rule": "customRule",
"configuration": [
{
"parameter": "customParam1",
"value": ["customValue1", 1, true]
},
{
"parameter": "customParam2",
"value": true
}
]
}
],
"valid": true
},
{
"id": "VALID_2",
"description": "configuration without value",
"data": [
{
"type": "customType",
"rule": "customRule",
"configuration": [
{
"parameter": "customParam1"
}
]
}
],
"valid": true
},
{
"id": "VALID_3",
"description": "type and rule without configuration",
"data": [
{
"type": "customType",
"rule": "customRule"
}
],
"valid": true
},
{
"id": "VALID_4",
"$comment": "This test should be INVALID but JSON Schema doesn't allow individual field uniqueness check(https://github.com/json-schema-org/json-schema-vocabularies/issues/22)",
"description": "unique type field check",
"data": [
{
"type": "customType",
"rule": "customRule1"
},
{
"type": "customType",
"rule": "customRule2"
}
],
"valid": true
},
{
"id": "INVALID_1",
"description": "unique items check",
"data": [
{
"type": "customType",
"rule": "customRule"
},
{
"type": "customType",
"rule": "customRule"
}
],
"valid": false
},
{
"id": "INVALID_2",
"description": "type and rule missing",
"data": [
{}
],
"valid": false
},
{
"id": "INVALID_3",
"description": "null configuration value check",
"data": [
{
"type": "customType",
"rule": "customRule",
"configuration": [
{
"parameter": "customParam",
"value": null
}
]
},
{
"type": "customType",
"rule": "customRule"
}
],
"valid": false
}
]
}