From f32e6405a7131fd365ab2b5d6345ee1d5b713a7f Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Fri, 1 Mar 2019 14:49:16 +0100 Subject: [PATCH] added interface list to peer-info response schema --- test/test_classifier_routes.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/test_classifier_routes.py b/test/test_classifier_routes.py index 40241cac..0c711b9b 100644 --- a/test/test_classifier_routes.py +++ b/test/test_classifier_routes.py @@ -23,10 +23,10 @@ def test_trap_metadata(client_with_mocked_data): VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info'} -IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'ix-public-peer-group'} +IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'ix-public-peer-group', 'interfaces'} -@pytest.mark.parametrize("peer_address,expected_response_keys", [ +@pytest.mark.parametrize('peer_address,expected_response_keys', [ ('109.105.110.54', VPN_RR_PEER_INFO_KEYS), ('2001:07f8:001c:024a:0000:0000:316e:0001', IX_PUBLIC_PEER_INFO_KEYS), ('2001:07f8:000b:0100:01d1:a5d1:0310:0029', IX_PUBLIC_PEER_INFO_KEYS), @@ -47,6 +47,13 @@ def test_peer_info( {"pattern": r'^([a-f\d]{4}:){7}[a-f\d]{4}$'} ] }, + "interface-address": { + "type": "string", + "oneOf": [ + {"pattern": r'^(\d+\.){3}\d+/\d+$'}, + {"pattern": r'^[a-f\d:]+/\d+$'} + ] + }, "vpn-rr-peer": { "type": "object", "properties": { @@ -81,15 +88,30 @@ def test_peer_info( "type": "array", "items": {"$ref": "#/definitions/ip-address"} }, + "interface-info": { + "type": "object", + "properties": { + "name": {"$ref": "#/definitions/ip-address"}, + "interface address": {"$ref": "#/definitions/interface-address"}, + "interface name": {"type": "string"}, + "router": {"type": "string"} + }, + "required": ["name", "interface address", "interface name", "router"], + "additionalProperties": False + } - }, + }, "type": "object", "properties": { "ix-public-peer-info": {"$ref": "#/definitions/ix-public-peer"}, "ix-public-peer-group": { "$ref": "#/definitions/ix-public-peer-group"}, - "vpn-rr-peer-info": {"$ref": "#/definitions/vpn-rr-peer"} + "vpn-rr-peer-info": {"$ref": "#/definitions/vpn-rr-peer"}, + "interfaces": { + "type": "array", + "items": {"$ref": "#/definitions/interface-info"} + } }, "additionalProperties": False } @@ -102,6 +124,7 @@ def test_peer_info( response_data = json.loads(rv.data.decode('utf-8')) jsonschema.validate(response_data, response_schema) + assert set(response_data.keys()) == expected_response_keys -- GitLab