Skip to content

Commit

Permalink
fix build_ref, add test for sessionCookieEnabled false
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyjux committed Oct 16, 2024
1 parent 7fdc717 commit dc2f68e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion microservices/kubeApi/routers/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ def in_list (match, list):
return False

def build_ref(v):
return "%s%s%s%s" % (v['name'], v['selectTag'], v['host'], v['dataPlane'], v['sessionCookieEnabled'])
return "%s%s%s%s%s" % (v['name'], v['selectTag'], v['host'], v['dataPlane'], v['sessionCookieEnabled'])
4 changes: 2 additions & 2 deletions microservices/kubeApi/tests/routers/test_bulk_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_bulk_sync(client):
"name": "wild-ns-example",
"labels": {
"aps-select-tag": "ns.EXAMPLE-NS",
"aps-template-version": "v1"
"aps-template-version": "v2"
}
},
"spec": {
Expand All @@ -30,7 +30,7 @@ def test_bulk_sync(client):
"selectTag": "ns.EXAMPLE-NS",
"dataPlane": "data-plane-1",
"host": "abc.api.gov.bc.ca",
"sessionCookieEnabled": True
"sessionCookieEnabled": False
}]
response = client.post('/namespaces/examplens/routes/sync', json=data)
assert response.status_code == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def test_bulk_sync_new_route(client):
"name": "wild-ns-example",
"selectTag": "ns.EXAMPLE-NS",
"dataPlane": "data-plane-1",
"host": "abc.api.gov.bc.ca"
"host": "abc.api.gov.bc.ca",
"sessionCookieEnabled": False
}]
response = client.post('/namespaces/examplens/routes/sync', json=data)
assert response.status_code == 200
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from unittest import mock

def test_bulk_sync(client):
with mock.patch("routers.routes.get_gwa_ocp_routes") as call:
call.return_value = [{
"metadata": {
"name": "wild-ns-example",
"labels": {
"aps-select-tag": "ns.EXAMPLE-NS",
"aps-template-version": "v1"
}
},
"spec": {
"host": "abc.api.gov.bc.ca",
"to": {
"name": "data-plane-1"
}
}
}]


with mock.patch("routers.routes.prepare_apply_routes") as call_apply:
call_apply.return_value = 0

with mock.patch("routers.routes.apply_routes") as call_mismatch_routes:
call_mismatch_routes.return_value = None

data = [{
"name": "wild-ns-example",
"selectTag": "ns.EXAMPLE-NS",
"dataPlane": "data-plane-1",
"host": "abc.api.gov.bc.ca",
"sessionCookieEnabled": True
}]
response = client.post('/namespaces/examplens/routes/sync', json=data)
assert response.status_code == 200
assert response.json()['message'] == 'synced'

0 comments on commit dc2f68e

Please sign in to comment.