Skip to content
Snippets Groups Projects
Commit 447ac04d authored by Erik Reid's avatar Erik Reid
Browse files

add schema + validation for vpn rr peer list

parent 71c09de4
No related branches found
No related tags found
No related merge requests found
......@@ -12,15 +12,12 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
'test',
'data'))
# ROUTER_NAME = 'mx1.vie.at.geant.net'
ROUTER_NAME = 'mx2.lju.si.geant.net'
@pytest.fixture
def netconf(router):
netconf_filename = os.path.join(
TEST_DATA_DIRNAME,
ROUTER_NAME + '-netconf.xml')
router + '-netconf.xml')
doc = etree.parse(netconf_filename)
juniper.validate_netconf_config(doc)
return doc
......@@ -31,15 +28,19 @@ def test_ix_public_peers(netconf):
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"definitions": {
"ip-address": {
"type": "string",
"oneOf": [
{"pattern": r'^(\d+\.){3}\d+$'},
{"pattern": r'^([a-f\d]{4}:){7}[a-f\d]{4}$'}
]
},
}
},
"type": "object",
"properties": {
"name": {"$ref": "#/definitions/ip-address"},
"description": {"type": "string"},
"as": {
"type": "object",
......@@ -55,11 +56,38 @@ def test_ix_public_peers(netconf):
"additionalProperties": False
}
print("HERE123")
for p in juniper.ix_public_peers(netconf):
jsonschema.validate(p, schema)
print(p)
def test_vpn_rr_peers(netconf):
# there are actually no v6 addresses, pattern could be ommitted
# TODO: check if there's a robust justification for this
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ip-address": {
"type": "string",
"oneOf": [
{"pattern": r'^(\d+\.){3}\d+$'},
{"pattern": r'^([a-f\d]{4}:){7}[a-f\d]{4}$'}
]
}
},
"type": "object",
"properties": {
"name": {"$ref": "#/definitions/ip-address"},
"description": {"type": "string"},
"peer-as": {"type": "integer"}
},
"required": ["name", "description"],
"additionalProperties": False
}
for p in juniper.vpn_rr_peers(netconf):
jsonschema.validate(p, schema)
print(p)
# jsonschema.validate(p, schema)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment