@@ -15,8 +15,23 @@ def test_happy_transform_data_by_ns():
15
15
]
16
16
}
17
17
]
18
- snis = []
19
- assert json .dumps (transform_data_by_ns (routes , snis )) == '{"ns1": [{"name": "wild-ns-ns1-test.api.gov.bc.ca", "selectTag": "ns.ns1", "host": "test.api.gov.bc.ca", "sessionCookieEnabled": false, "dataClass": null, "dataPlane": "test-dp", "sslCertificateId": "default"}]}'
18
+ certs = []
19
+ cert_snis = []
20
+ expected_value = {
21
+ "ns1" : [
22
+ {
23
+ "name" : "wild-ns-ns1-test.api.gov.bc.ca" ,
24
+ "selectTag" : "ns.ns1" ,
25
+ "host" : "test.api.gov.bc.ca" ,
26
+ "sessionCookieEnabled" : False ,
27
+ "dataClass" : None ,
28
+ "dataPlane" : "test-dp" ,
29
+ "sslCertificateId" : "default" ,
30
+ "certificates" : None
31
+ }
32
+ ]
33
+ }
34
+ assert json .dumps (transform_data_by_ns (routes , certs , cert_snis )) == json .dumps (expected_value )
20
35
21
36
def test_happy_transform_data_by_ns_with_override_session_cookie ():
22
37
with mock .patch ('clients.namespace.admin_api' ) as mock_admin_api :
@@ -31,8 +46,21 @@ def test_happy_transform_data_by_ns_with_override_session_cookie():
31
46
]
32
47
}
33
48
]
34
- snis = []
35
- assert json .dumps (transform_data_by_ns (routes , snis )) == '{"ns1": [{"name": "wild-ns-ns1-test.api.gov.bc.ca", "selectTag": "ns.ns1", "host": "test.api.gov.bc.ca", "sessionCookieEnabled": true, "dataClass": null, "dataPlane": "test-dp", "sslCertificateId": "default"}]}'
49
+ certs = []
50
+ cert_snis = []
51
+ expected_value = {
52
+ "ns1" : [{
53
+ "name" : "wild-ns-ns1-test.api.gov.bc.ca" ,
54
+ "selectTag" : "ns.ns1" ,
55
+ "host" : "test.api.gov.bc.ca" ,
56
+ "sessionCookieEnabled" : True ,
57
+ "dataClass" : None ,
58
+ "dataPlane" : "test-dp" ,
59
+ "sslCertificateId" : "default" ,
60
+ "certificates" : None
61
+ }]
62
+ }
63
+ assert json .dumps (transform_data_by_ns (routes , certs , cert_snis )) == json .dumps (expected_value )
36
64
37
65
def test_happy_transform_data_by_ns_with_override_data_plane ():
38
66
with mock .patch ('clients.namespace.admin_api' ) as mock_admin_api :
@@ -47,8 +75,21 @@ def test_happy_transform_data_by_ns_with_override_data_plane():
47
75
]
48
76
}
49
77
]
50
- snis = []
51
- assert json .dumps (transform_data_by_ns (routes , snis )) == '{"ns1": [{"name": "wild-ns-ns1-test.api.gov.bc.ca", "selectTag": "ns.ns1", "host": "test.api.gov.bc.ca", "sessionCookieEnabled": false, "dataClass": "high", "dataPlane": "test-dp", "sslCertificateId": "default"}]}'
78
+ certs = []
79
+ cert_snis = []
80
+ expected_value = {
81
+ "ns1" : [{
82
+ "name" : "wild-ns-ns1-test.api.gov.bc.ca" ,
83
+ "selectTag" : "ns.ns1" ,
84
+ "host" : "test.api.gov.bc.ca" ,
85
+ "sessionCookieEnabled" : False ,
86
+ "dataClass" : "high" ,
87
+ "dataPlane" : "test-dp" ,
88
+ "sslCertificateId" : "default" ,
89
+ "certificates" : None
90
+ }]
91
+ }
92
+ assert json .dumps (transform_data_by_ns (routes , certs , cert_snis )) == json .dumps (expected_value )
52
93
53
94
def test_happy_transform_data_by_ns_with_custom_domain ():
54
95
with mock .patch ('clients.namespace.admin_api' ) as mock_admin_api :
@@ -63,7 +104,18 @@ def test_happy_transform_data_by_ns_with_custom_domain():
63
104
]
64
105
}
65
106
]
66
- snis = [
107
+ certs = [
108
+ {
109
+ "id" : "41d14845-669f-4dcd-aff2-926fb32a4b25" ,
110
+ "cert" : "CERT" ,
111
+ "created_at" : 1731713874 ,
112
+ "tags" : [
113
+ "ns.ns1"
114
+ ],
115
+ "key" : "KEY" ,
116
+ }
117
+ ]
118
+ cert_snis = [
67
119
{
68
120
"name" : "test.custom.gov.bc.ca" ,
69
121
"id" : "79009c9e-0f4d-40b5-9707-bf2fe9f50502" ,
@@ -74,7 +126,32 @@ def test_happy_transform_data_by_ns_with_custom_domain():
74
126
]
75
127
}
76
128
]
77
- assert json .dumps (transform_data_by_ns (routes , snis )) == '{"ns1": [{"name": "wild-ns-ns1-test.custom.gov.bc.ca", "selectTag": "ns.ns1", "host": "test.custom.gov.bc.ca", "sessionCookieEnabled": false, "dataClass": null, "dataPlane": "test-dp", "sslCertificateId": "41d14845-669f-4dcd-aff2-926fb32a4b25"}]}'
129
+ expected_value = {
130
+ "ns1" : [{
131
+ "name" : "wild-ns-ns1-test.custom.gov.bc.ca" ,
132
+ "selectTag" : "ns.ns1" ,
133
+ "host" : "test.custom.gov.bc.ca" ,
134
+ "sessionCookieEnabled" : False ,
135
+ "dataClass" : None ,
136
+ "dataPlane" : "test-dp" ,
137
+ "sslCertificateId" : "41d14845-669f-4dcd-aff2-926fb32a4b25" ,
138
+ "certificates" : [
139
+ {
140
+ "id" : "41d14845-669f-4dcd-aff2-926fb32a4b25" ,
141
+ "cert" : "CERT" ,
142
+ "created_at" : 1731713874 ,
143
+ "tags" : [
144
+ "ns.ns1"
145
+ ],
146
+ "key" : "KEY" ,
147
+ "snis" : [
148
+ "test.custom.gov.bc.ca"
149
+ ]
150
+ }
151
+ ]
152
+ }]
153
+ }
154
+ assert json .dumps (transform_data_by_ns (routes , certs , cert_snis )) == json .dumps (expected_value )
78
155
79
156
80
157
def set_mock_admin_api_response (dt ):
0 commit comments