diff --git a/schemas/L2VPN.json b/schemas/L2VPN.json new file mode 100644 index 0000000..7bac68e --- /dev/null +++ b/schemas/L2VPN.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "L2VPN", + "type": "object", + "properties": { + "vlan_range": { + "type": "array", + "uniqueItems": true, + "items": [ + { + "anyOf": [ + { + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": [ + { + "type": "number" + } + ] + }, + { + "type": "number" + } + ] + } + ] + } + } +} diff --git a/schemas/Port.json b/schemas/Port.json index 75f127f..e875b00 100644 --- a/schemas/Port.json +++ b/schemas/Port.json @@ -19,7 +19,20 @@ "type": "string" }, "nni": { - "type": "boolean" + "type": "string" + }, + "services": { + "type": "object", + "properties": { + "l2vpn-ptp": { + "type": "object", + "$ref": "L2VPN.json" + }, + "l2vpn-pmtp": { + "type": "object", + "$ref": "L2VPN.json" + } + } }, "type": { "type": "string", diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 85556fa..6681e18 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -78,6 +78,38 @@ def test_port_schema(self): self._read_schema(self.PORT_SCHEMA_FILE), ) + def test_port_schema_l2vpn_p2p(self): + jsonschema.validate( + self._read_json(TestData.PORT_FILE_L2VPN_PTP), + self._read_schema(self.PORT_SCHEMA_FILE), + ) + + def test_port_schema_l2vpn_p2p_invalid(self): + self.assertRaises( + json.decoder.JSONDecodeError, + self._read_json, + TestData.PORT_FILE_L2VPN_PTP_INVALID, + ) + + def test_port_schema_l2vpn_p2p_bad_range(self): + jsonschema.validate( + self._read_json(TestData.PORT_FILE_L2VPN_PTP_BAD_RANGE), + self._read_schema(self.PORT_SCHEMA_FILE), + ) + + def test_port_schema_l2vpn_p2p_ptmp(self): + jsonschema.validate( + self._read_json(TestData.PORT_FILE_L2VPN_PTP_PTMP), + self._read_schema(self.PORT_SCHEMA_FILE), + ) + + def test_port_schema_l2vpn_p2p_ptmp_invalid(self): + self.assertRaises( + json.decoder.JSONDecodeError, + self._read_json, + TestData.PORT_FILE_L2VPN_PTP_PTMP_INVALID, + ) + def test_service_schema(self): jsonschema.validate( self._read_json(TestData.SERVICE_FILE),