Skip to content

Commit

Permalink
Merge pull request #117 from bcgov/dev
Browse files Browse the repository at this point in the history
fix for validating ca_certificates (#116)
  • Loading branch information
ikethecoder authored Jul 3, 2024
2 parents 82eef97 + 98b4794 commit e40571d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 23 additions & 0 deletions microservices/gatewayApi/tests/routes/v2/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}'
7 changes: 6 additions & 1 deletion microservices/gatewayApi/v2/routes/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down

0 comments on commit e40571d

Please sign in to comment.