Skip to content

Commit a58bc9a

Browse files
committed
Add Mockoon-based registration tests
This commit introduces a suite of integration tests for the registrar client using Mockoon to simulate a registrar server. These tests provide coverage for HTTP and HTTPS interactions, including agent registration, activation, and API version retrieval. Key changes include: * New GitHub Actions Workflow: A dedicated workflow, mockoon-registrar-tests, has been added to mockoon.yaml to run the new registrar tests in CI. [cite_start]This workflow installs and runs the Mockoon CLI with a new data file. * Mockoon Registrar Configuration: A new JSON file, registrar.json [cite_start], defines the mock registrar's API endpoints, including /version /v1.2/agents/{uuid} for registration and activation, and their TLS-secured counterparts. * Rust Integration Tests: New tests have been added to registrar_client.rs to cover: ** HTTP agent registration and activation. ** API version endpoint retrieval. ** Client behavior with retry configurations. ** Verification of the TLS code path during client build. * Test Execution Script: The mockoon_registrar_tests.sh script manages the setup and teardown of the testing environment. It starts the Mockoon server on port 3001, handles certificate generation and executes the Cargo tests. It also includes cleanup logic to stop the Mockoon server after the test run. Assisted-by: Gemini <[email protected]> Signed-off-by: Sergio Arroutbi <[email protected]>
1 parent 5c83cbb commit a58bc9a

File tree

4 files changed

+652
-2
lines changed

4 files changed

+652
-2
lines changed

.github/workflows/mockoon.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name: "Mockoon Tests"
88
branches: [master]
99

1010
jobs:
11-
mockoon-tests:
11+
mockoon-verifier-tests:
1212
runs-on: ubuntu-latest
1313
container:
1414
image: quay.io/keylime/keylime-ci:latest
@@ -24,5 +24,24 @@ jobs:
2424
port: 3000
2525
- name: Set git safe.directory for the working directory
2626
run: git config --system --add safe.directory "$PWD"
27-
- name: Mockoon tests custom script execution
27+
- name: Mockoon verifier tests custom script execution
2828
run: bash tests/mockoon_tests.sh
29+
30+
mockoon-registrar-tests:
31+
runs-on: ubuntu-latest
32+
container:
33+
image: quay.io/keylime/keylime-ci:latest
34+
steps:
35+
- uses: actions/checkout@v5
36+
- name: NPM installation
37+
run: dnf install -y npm
38+
- name: Run Mockoon CLI
39+
uses: mockoon/cli-action@v2
40+
with:
41+
version: latest
42+
data-file: keylime-push-model-agent/test-data/registrar.json
43+
port: 3001
44+
- name: Set git safe.directory for the working directory
45+
run: git config --system --add safe.directory "$PWD"
46+
- name: Mockoon registrar tests custom script execution
47+
run: bash tests/mockoon_registrar_tests.sh
Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
{
2+
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
3+
"lastMigration": 33,
4+
"name": "Registrar",
5+
"endpointPrefix": "",
6+
"latency": 0,
7+
"port": 3001,
8+
"hostname": "",
9+
"folders": [],
10+
"routes": [
11+
{
12+
"uuid": "ver-endpoint-uuid-001",
13+
"type": "http",
14+
"documentation": "Registrar API version endpoint",
15+
"method": "get",
16+
"endpoint": "version",
17+
"responses": [
18+
{
19+
"uuid": "ver-response-uuid-001",
20+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {\n \"current_version\": \"1.2\",\n \"supported_versions\": [\"1.0\", \"1.1\", \"1.2\"]\n }\n}",
21+
"latency": 0,
22+
"statusCode": 200,
23+
"label": "API version response",
24+
"headers": [
25+
{
26+
"key": "Content-Type",
27+
"value": "application/json"
28+
},
29+
{
30+
"key": "Access-Control-Allow-Origin",
31+
"value": "*"
32+
}
33+
],
34+
"bodyType": "INLINE",
35+
"filePath": "",
36+
"databucketID": "",
37+
"sendFileAsBody": false,
38+
"rules": [],
39+
"rulesOperator": "OR",
40+
"disableTemplating": false,
41+
"fallbackTo404": false,
42+
"default": true,
43+
"crudKey": "id",
44+
"callbacks": []
45+
}
46+
],
47+
"responseMode": null,
48+
"streamingMode": null,
49+
"streamingInterval": 0
50+
},
51+
{
52+
"uuid": "reg-endpoint-uuid-001",
53+
"type": "http",
54+
"documentation": "Agent registration endpoint - POST /v1.2/agents/{uuid}",
55+
"method": "post",
56+
"endpoint": "v1.2/agents/:uuid",
57+
"responses": [
58+
{
59+
"uuid": "reg-response-uuid-001",
60+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {\n \"blob\": \"dGVzdC1ibG9iLWRhdGE=\"\n }\n}",
61+
"latency": 0,
62+
"statusCode": 200,
63+
"label": "Successful registration",
64+
"headers": [
65+
{
66+
"key": "Content-Type",
67+
"value": "application/json"
68+
},
69+
{
70+
"key": "Access-Control-Allow-Origin",
71+
"value": "*"
72+
}
73+
],
74+
"bodyType": "INLINE",
75+
"filePath": "",
76+
"databucketID": "",
77+
"sendFileAsBody": false,
78+
"rules": [],
79+
"rulesOperator": "OR",
80+
"disableTemplating": false,
81+
"fallbackTo404": false,
82+
"default": true,
83+
"crudKey": "id",
84+
"callbacks": []
85+
}
86+
],
87+
"responseMode": null,
88+
"streamingMode": null,
89+
"streamingInterval": 0
90+
},
91+
{
92+
"uuid": "act-endpoint-uuid-001",
93+
"type": "http",
94+
"documentation": "Agent activation endpoint - PUT /v1.2/agents/{uuid}",
95+
"method": "put",
96+
"endpoint": "v1.2/agents/:uuid",
97+
"responses": [
98+
{
99+
"uuid": "act-response-uuid-001",
100+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {}\n}",
101+
"latency": 0,
102+
"statusCode": 200,
103+
"label": "Successful activation",
104+
"headers": [
105+
{
106+
"key": "Content-Type",
107+
"value": "application/json"
108+
},
109+
{
110+
"key": "Access-Control-Allow-Origin",
111+
"value": "*"
112+
}
113+
],
114+
"bodyType": "INLINE",
115+
"filePath": "",
116+
"databucketID": "",
117+
"sendFileAsBody": false,
118+
"rules": [],
119+
"rulesOperator": "OR",
120+
"disableTemplating": false,
121+
"fallbackTo404": false,
122+
"default": true,
123+
"crudKey": "id",
124+
"callbacks": []
125+
}
126+
],
127+
"responseMode": null,
128+
"streamingMode": null,
129+
"streamingInterval": 0
130+
},
131+
{
132+
"uuid": "reg-tls-endpoint-uuid-001",
133+
"type": "http",
134+
"documentation": "TLS-secured agent registration endpoint - POST /v1.2/agents/{uuid}",
135+
"method": "post",
136+
"endpoint": "tls/v1.2/agents/:uuid",
137+
"responses": [
138+
{
139+
"uuid": "reg-tls-response-uuid-001",
140+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {\n \"blob\": \"dGxzLWJsb2ItZGF0YQ==\"\n }\n}",
141+
"latency": 0,
142+
"statusCode": 200,
143+
"label": "Successful TLS registration",
144+
"headers": [
145+
{
146+
"key": "Content-Type",
147+
"value": "application/json"
148+
},
149+
{
150+
"key": "Access-Control-Allow-Origin",
151+
"value": "*"
152+
}
153+
],
154+
"bodyType": "INLINE",
155+
"filePath": "",
156+
"databucketID": "",
157+
"sendFileAsBody": false,
158+
"rules": [],
159+
"rulesOperator": "OR",
160+
"disableTemplating": false,
161+
"fallbackTo404": false,
162+
"default": true,
163+
"crudKey": "id",
164+
"callbacks": []
165+
}
166+
],
167+
"responseMode": null,
168+
"streamingMode": null,
169+
"streamingInterval": 0
170+
},
171+
{
172+
"uuid": "act-tls-endpoint-uuid-001",
173+
"type": "http",
174+
"documentation": "TLS-secured agent activation endpoint - PUT /v1.2/agents/{uuid}",
175+
"method": "put",
176+
"endpoint": "tls/v1.2/agents/:uuid",
177+
"responses": [
178+
{
179+
"uuid": "act-tls-response-uuid-001",
180+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {}\n}",
181+
"latency": 0,
182+
"statusCode": 200,
183+
"label": "Successful TLS activation",
184+
"headers": [
185+
{
186+
"key": "Content-Type",
187+
"value": "application/json"
188+
},
189+
{
190+
"key": "Access-Control-Allow-Origin",
191+
"value": "*"
192+
}
193+
],
194+
"bodyType": "INLINE",
195+
"filePath": "",
196+
"databucketID": "",
197+
"sendFileAsBody": false,
198+
"rules": [],
199+
"rulesOperator": "OR",
200+
"disableTemplating": false,
201+
"fallbackTo404": false,
202+
"default": true,
203+
"crudKey": "id",
204+
"callbacks": []
205+
}
206+
],
207+
"responseMode": null,
208+
"streamingMode": null,
209+
"streamingInterval": 0
210+
},
211+
{
212+
"uuid": "ver-tls-endpoint-uuid-001",
213+
"type": "http",
214+
"documentation": "TLS-secured Registrar API version endpoint",
215+
"method": "get",
216+
"endpoint": "tls/version",
217+
"responses": [
218+
{
219+
"uuid": "ver-tls-response-uuid-001",
220+
"body": "{\n \"code\": 200,\n \"status\": \"Success\",\n \"results\": {\n \"current_version\": \"1.2\",\n \"supported_versions\": [\"1.0\", \"1.1\", \"1.2\"]\n }\n}",
221+
"latency": 0,
222+
"statusCode": 200,
223+
"label": "TLS API version response",
224+
"headers": [
225+
{
226+
"key": "Content-Type",
227+
"value": "application/json"
228+
},
229+
{
230+
"key": "Access-Control-Allow-Origin",
231+
"value": "*"
232+
}
233+
],
234+
"bodyType": "INLINE",
235+
"filePath": "",
236+
"databucketID": "",
237+
"sendFileAsBody": false,
238+
"rules": [],
239+
"rulesOperator": "OR",
240+
"disableTemplating": false,
241+
"fallbackTo404": false,
242+
"default": true,
243+
"crudKey": "id",
244+
"callbacks": []
245+
}
246+
],
247+
"responseMode": null,
248+
"streamingMode": null,
249+
"streamingInterval": 0
250+
}
251+
],
252+
"rootChildren": [
253+
{
254+
"type": "route",
255+
"uuid": "ver-endpoint-uuid-001"
256+
},
257+
{
258+
"type": "route",
259+
"uuid": "reg-endpoint-uuid-001"
260+
},
261+
{
262+
"type": "route",
263+
"uuid": "act-endpoint-uuid-001"
264+
},
265+
{
266+
"type": "route",
267+
"uuid": "reg-tls-endpoint-uuid-001"
268+
},
269+
{
270+
"type": "route",
271+
"uuid": "act-tls-endpoint-uuid-001"
272+
},
273+
{
274+
"type": "route",
275+
"uuid": "ver-tls-endpoint-uuid-001"
276+
}
277+
],
278+
"proxyMode": false,
279+
"proxyHost": "",
280+
"proxyRemovePrefix": false,
281+
"tlsOptions": {
282+
"enabled": false,
283+
"type": "CERT",
284+
"pfxPath": "",
285+
"certPath": "",
286+
"keyPath": "",
287+
"caPath": "",
288+
"passphrase": ""
289+
},
290+
"cors": true,
291+
"headers": [
292+
{
293+
"key": "Access-Control-Allow-Origin",
294+
"value": "*"
295+
},
296+
{
297+
"key": "Access-Control-Allow-Methods",
298+
"value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"
299+
},
300+
{
301+
"key": "Access-Control-Allow-Headers",
302+
"value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"
303+
}
304+
],
305+
"proxyReqHeaders": [
306+
{
307+
"key": "",
308+
"value": ""
309+
}
310+
],
311+
"proxyResHeaders": [
312+
{
313+
"key": "",
314+
"value": ""
315+
}
316+
],
317+
"data": [],
318+
"callbacks": []
319+
}

0 commit comments

Comments
 (0)