diff --git a/test/per_router/test_ix_public_peers.py b/test/per_router/test_ix_public_peers.py index abeb8f757cf59151f095a443d627823744bde02d..f282084c57bc18e12d3c4a4b23b5e45629a24fa5 100644 --- a/test/per_router/test_ix_public_peers.py +++ b/test/per_router/test_ix_public_peers.py @@ -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)