diff --git a/microservices/gatewayApi/tests/routes/v2/test_gateway.py b/microservices/gatewayApi/tests/routes/v2/test_gateway.py index dd8f9ec..4e5dccd 100644 --- a/microservices/gatewayApi/tests/routes/v2/test_gateway.py +++ b/microservices/gatewayApi/tests/routes/v2/test_gateway.py @@ -97,3 +97,26 @@ def test_happy_with_session_cookie_gateway_call(client): response = client.put('/v2/namespaces/sescookie/gateway', json=data) assert response.status_code == 200 assert json.dumps(response.json) == '{"message": "Sync successful.", "results": "Deck reported no changes"}' + + +def test_success_mtls_reference(client): + configFile = ''' + services: + - name: my-service + host: myupstream.local + ca_certificates: [ "0000-0000-0000-0000" ] + certificate: "8fc131ef-9752-43a4-ba70-eb10ba442d4e" + tags: ["ns.mytest", "another"] + routes: + - name: route-1 + hosts: [ my-service.api.gov.bc.ca ] + tags: ["ns.mytest", "another2"] + ''' + + data={ + "configFile": configFile, + "dryRun": False + } + response = client.put('/v2/namespaces/mytest/gateway', json=data) + assert response.status_code == 200 + assert json.dumps(response.json) == '{"message": "Sync successful.", "results": "Deck reported no changes"}' diff --git a/microservices/gatewayApi/v2/routes/gateway.py b/microservices/gatewayApi/v2/routes/gateway.py index 7401867..2690bfb 100644 --- a/microservices/gatewayApi/v2/routes/gateway.py +++ b/microservices/gatewayApi/v2/routes/gateway.py @@ -427,7 +427,12 @@ def validate_tags(yaml, required_tag): raise Exception('\n'.join(errors)) def traverse(source, errors, yaml, required_tag, qualifiers): - traversables = ['services', 'routes', 'plugins', 'upstreams', 'consumers', 'certificates', 'ca_certificates'] + # If at root level, allow different resources than if its traversed down a level + if source == "": + traversables = ['services', 'upstreams', 'consumers', 'certificates', 'ca_certificates'] + else: + traversables = ['routes', 'plugins'] + for k in yaml: if k in traversables: for index, item in enumerate(yaml[k]):