Skip to content

Commit dc2f68e

Browse files
committed
fix build_ref, add test for sessionCookieEnabled false
1 parent 7fdc717 commit dc2f68e

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

microservices/kubeApi/routers/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,4 @@ def in_list (match, list):
249249
return False
250250

251251
def build_ref(v):
252-
return "%s%s%s%s" % (v['name'], v['selectTag'], v['host'], v['dataPlane'], v['sessionCookieEnabled'])
252+
return "%s%s%s%s%s" % (v['name'], v['selectTag'], v['host'], v['dataPlane'], v['sessionCookieEnabled'])

microservices/kubeApi/tests/routers/test_bulk_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def test_bulk_sync(client):
77
"name": "wild-ns-example",
88
"labels": {
99
"aps-select-tag": "ns.EXAMPLE-NS",
10-
"aps-template-version": "v1"
10+
"aps-template-version": "v2"
1111
}
1212
},
1313
"spec": {
@@ -30,7 +30,7 @@ def test_bulk_sync(client):
3030
"selectTag": "ns.EXAMPLE-NS",
3131
"dataPlane": "data-plane-1",
3232
"host": "abc.api.gov.bc.ca",
33-
"sessionCookieEnabled": True
33+
"sessionCookieEnabled": False
3434
}]
3535
response = client.post('/namespaces/examplens/routes/sync', json=data)
3636
assert response.status_code == 200

microservices/kubeApi/tests/routers/test_bulk_sync_new_route.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def test_bulk_sync_new_route(client):
7272
"name": "wild-ns-example",
7373
"selectTag": "ns.EXAMPLE-NS",
7474
"dataPlane": "data-plane-1",
75-
"host": "abc.api.gov.bc.ca"
75+
"host": "abc.api.gov.bc.ca",
76+
"sessionCookieEnabled": False
7677
}]
7778
response = client.post('/namespaces/examplens/routes/sync', json=data)
7879
assert response.status_code == 200
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from unittest import mock
2+
3+
def test_bulk_sync(client):
4+
with mock.patch("routers.routes.get_gwa_ocp_routes") as call:
5+
call.return_value = [{
6+
"metadata": {
7+
"name": "wild-ns-example",
8+
"labels": {
9+
"aps-select-tag": "ns.EXAMPLE-NS",
10+
"aps-template-version": "v1"
11+
}
12+
},
13+
"spec": {
14+
"host": "abc.api.gov.bc.ca",
15+
"to": {
16+
"name": "data-plane-1"
17+
}
18+
}
19+
}]
20+
21+
22+
with mock.patch("routers.routes.prepare_apply_routes") as call_apply:
23+
call_apply.return_value = 0
24+
25+
with mock.patch("routers.routes.apply_routes") as call_mismatch_routes:
26+
call_mismatch_routes.return_value = None
27+
28+
data = [{
29+
"name": "wild-ns-example",
30+
"selectTag": "ns.EXAMPLE-NS",
31+
"dataPlane": "data-plane-1",
32+
"host": "abc.api.gov.bc.ca",
33+
"sessionCookieEnabled": True
34+
}]
35+
response = client.post('/namespaces/examplens/routes/sync', json=data)
36+
assert response.status_code == 200
37+
assert response.json()['message'] == 'synced'

0 commit comments

Comments
 (0)