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

this is covered in test_juniper_data

parent 37ea9656
No related branches found
No related tags found
No related merge requests found
import os
import jsonschema
from lxml import etree
import pytest
import inventory_provider
from inventory_provider import juniper
TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
inventory_provider.__path__[0],
'..',
'test',
'data'))
@pytest.fixture
def netconf(router):
netconf_filename = os.path.join(
TEST_DATA_DIRNAME,
router + '-netconf.xml')
doc = etree.parse(netconf_filename)
juniper.validate_netconf_config(doc)
return doc
def test_ix_public_peers(netconf):
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"},
"as": {
"type": "object",
"properties": {
"local": {"type": "integer"},
"peer": {"type": "integer"},
},
"required": ["local", "peer"],
"additionalProperties": False
}
},
"required": ["name", "description", "as"],
"additionalProperties": False
}
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)
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