@northern.tech/testing 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/package.json +3 -4
  2. package/dist/baseTestConfig.json +0 -17
  3. package/dist/chunk-4UV4MWUU.js +0 -188
  4. package/dist/chunk-4UV4MWUU.js.map +0 -1
  5. package/dist/chunk-5GIOT4M6.js +0 -161
  6. package/dist/chunk-5GIOT4M6.js.map +0 -1
  7. package/dist/chunk-AQYKNNMJ.js +0 -239
  8. package/dist/chunk-AQYKNNMJ.js.map +0 -1
  9. package/dist/chunk-CT35JRBC.js +0 -893
  10. package/dist/chunk-CT35JRBC.js.map +0 -1
  11. package/dist/chunk-HRGVXWMH.js +0 -17
  12. package/dist/chunk-HRGVXWMH.js.map +0 -1
  13. package/dist/chunk-RG3ICJW5.js +0 -34
  14. package/dist/chunk-RG3ICJW5.js.map +0 -1
  15. package/dist/chunk-ROSMRKMF.js +0 -265
  16. package/dist/chunk-ROSMRKMF.js.map +0 -1
  17. package/dist/chunk-TVJ6K2KG.js +0 -318
  18. package/dist/chunk-TVJ6K2KG.js.map +0 -1
  19. package/dist/chunk-WFNPT672.js +0 -29
  20. package/dist/chunk-WFNPT672.js.map +0 -1
  21. package/dist/mockData.cjs +0 -926
  22. package/dist/mockData.cjs.map +0 -1
  23. package/dist/mockData.d.cts +0 -596
  24. package/dist/mockData.d.ts +0 -596
  25. package/dist/mockData.js +0 -45
  26. package/dist/mockData.js.map +0 -1
  27. package/dist/requestHandlers/deploymentHandlers.cjs +0 -1045
  28. package/dist/requestHandlers/deploymentHandlers.cjs.map +0 -1
  29. package/dist/requestHandlers/deploymentHandlers.d.cts +0 -5
  30. package/dist/requestHandlers/deploymentHandlers.d.ts +0 -5
  31. package/dist/requestHandlers/deploymentHandlers.js +0 -8
  32. package/dist/requestHandlers/deploymentHandlers.js.map +0 -1
  33. package/dist/requestHandlers/deviceHandlers.cjs +0 -1113
  34. package/dist/requestHandlers/deviceHandlers.cjs.map +0 -1
  35. package/dist/requestHandlers/deviceHandlers.d.cts +0 -20
  36. package/dist/requestHandlers/deviceHandlers.d.ts +0 -20
  37. package/dist/requestHandlers/deviceHandlers.js +0 -12
  38. package/dist/requestHandlers/deviceHandlers.js.map +0 -1
  39. package/dist/requestHandlers/monitorHandlers.cjs +0 -835
  40. package/dist/requestHandlers/monitorHandlers.cjs.map +0 -1
  41. package/dist/requestHandlers/monitorHandlers.d.cts +0 -5
  42. package/dist/requestHandlers/monitorHandlers.d.ts +0 -5
  43. package/dist/requestHandlers/monitorHandlers.js +0 -8
  44. package/dist/requestHandlers/monitorHandlers.js.map +0 -1
  45. package/dist/requestHandlers/organizationHandlers.cjs +0 -1086
  46. package/dist/requestHandlers/organizationHandlers.cjs.map +0 -1
  47. package/dist/requestHandlers/organizationHandlers.d.cts +0 -5
  48. package/dist/requestHandlers/organizationHandlers.d.ts +0 -5
  49. package/dist/requestHandlers/organizationHandlers.js +0 -8
  50. package/dist/requestHandlers/organizationHandlers.js.map +0 -1
  51. package/dist/requestHandlers/releaseHandlers.cjs +0 -966
  52. package/dist/requestHandlers/releaseHandlers.cjs.map +0 -1
  53. package/dist/requestHandlers/releaseHandlers.d.cts +0 -5
  54. package/dist/requestHandlers/releaseHandlers.d.ts +0 -5
  55. package/dist/requestHandlers/releaseHandlers.js +0 -8
  56. package/dist/requestHandlers/releaseHandlers.js.map +0 -1
  57. package/dist/requestHandlers/requestHandlers.cjs +0 -1975
  58. package/dist/requestHandlers/requestHandlers.cjs.map +0 -1
  59. package/dist/requestHandlers/requestHandlers.d.cts +0 -5
  60. package/dist/requestHandlers/requestHandlers.d.ts +0 -5
  61. package/dist/requestHandlers/requestHandlers.js +0 -35
  62. package/dist/requestHandlers/requestHandlers.js.map +0 -1
  63. package/dist/requestHandlers/userHandlers.cjs +0 -994
  64. package/dist/requestHandlers/userHandlers.cjs.map +0 -1
  65. package/dist/requestHandlers/userHandlers.d.cts +0 -5
  66. package/dist/requestHandlers/userHandlers.d.ts +0 -5
  67. package/dist/requestHandlers/userHandlers.js +0 -8
  68. package/dist/requestHandlers/userHandlers.js.map +0 -1
  69. package/dist/setupTests.cjs +0 -996
  70. package/dist/setupTests.cjs.map +0 -1
  71. package/dist/setupTests.d.cts +0 -77
  72. package/dist/setupTests.d.ts +0 -77
  73. package/dist/setupTests.js +0 -138
  74. package/dist/setupTests.js.map +0 -1
  75. package/dist/theme/light.cjs +0 -41
  76. package/dist/theme/light.cjs.map +0 -1
  77. package/dist/theme/light.d.cts +0 -12
  78. package/dist/theme/light.d.ts +0 -12
  79. package/dist/theme/light.js +0 -7
  80. package/dist/theme/light.js.map +0 -1
  81. package/dist/utils.cjs +0 -71
  82. package/dist/utils.cjs.map +0 -1
  83. package/dist/utils.d.cts +0 -69
  84. package/dist/utils.d.ts +0 -69
  85. package/dist/utils.js +0 -12
  86. package/dist/utils.js.map +0 -1
@@ -1,318 +0,0 @@
1
- import {
2
- defaultCreationDate,
3
- defaultMacAddress,
4
- mockApiResponses
5
- } from "./chunk-CT35JRBC.js";
6
-
7
- // src/requestHandlers/deviceHandlers.ts
8
- import {
9
- DEVICE_FILTERING_OPTIONS,
10
- DEVICE_STATES,
11
- deviceAuthV2,
12
- deviceConfig,
13
- deviceConnect,
14
- headerNames,
15
- inventoryApiUrl,
16
- inventoryApiUrlV2,
17
- iotManagerBaseURL,
18
- reportingApiUrl
19
- } from "@northern.tech/utils/constants";
20
- import { HttpResponse, http } from "msw";
21
- var defaultDeviceId = "a1";
22
- var deviceAuthDevice = {
23
- id: defaultDeviceId,
24
- identity_data: { mac: defaultMacAddress },
25
- status: "accepted",
26
- decommissioning: false,
27
- created_ts: defaultCreationDate,
28
- updated_ts: "2019-01-01T09:25:00.000Z",
29
- auth_sets: [
30
- {
31
- id: "auth1",
32
- identity_data: { mac: defaultMacAddress },
33
- pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
34
- ts: defaultCreationDate,
35
- status: "accepted"
36
- }
37
- ]
38
- };
39
- var checkInTimeExact = "2019-01-01T10:25:00.000Z";
40
- var updatedTime = "2019-01-01T09:25:00.000Z";
41
- var inventoryDevice = {
42
- id: defaultDeviceId,
43
- attributes: [
44
- { name: "network_interfaces", value: ["eth0", "wlan0"], scope: "inventory" },
45
- { name: "kernel", value: "Linux version 4.19.75-v7l+", scope: "inventory" },
46
- { name: "artifact_name", value: "raspotifyInstaller", scope: "inventory" },
47
- { name: "ipv6_wlan0", value: "fe80::68d9:8453:3e9c:7c80/64", scope: "inventory" },
48
- { name: "mac_eth0", value: defaultMacAddress, scope: "inventory" },
49
- { name: "rootfs_type", value: "ext4", scope: "inventory" },
50
- { name: "mender_bootloader_integration", value: "unknown", scope: "inventory" },
51
- { name: "cpu_model", value: "ARMv7 Processor rev 3 (v7l)", scope: "inventory" },
52
- { name: "hostname", value: "raspberrypi", scope: "inventory" },
53
- { name: "mender_client_version", value: "2.1.0", scope: "inventory" },
54
- { name: "ipv4_wlan0", value: "192.168.10.141/24", scope: "inventory" },
55
- { name: "device_type", value: "raspberrypi4", scope: "inventory" },
56
- { name: "mem_total_kB", value: "1986024", scope: "inventory" },
57
- { name: "mac_wlan0", value: "dc:a6:32:12:ad:c0", scope: "inventory" },
58
- { name: "os", value: "Raspbian GNU/Linux 10 (buster)", scope: "inventory" },
59
- { name: "created_ts", value: defaultCreationDate, scope: "system" },
60
- { name: "updated_ts", value: updatedTime, scope: "system" },
61
- { name: "status", value: "accepted", scope: "identity" },
62
- { name: "mac", value: defaultMacAddress, scope: "identity" },
63
- { name: "group", value: "test", scope: "system" }
64
- ],
65
- check_in_time: checkInTimeExact,
66
- updated_ts: updatedTime
67
- };
68
- var deviceAttributes = [
69
- { name: "status", scope: "identity", count: 5 },
70
- { name: "created_ts", scope: "system", count: 5 },
71
- { name: "updated_ts", scope: "system", count: 5 },
72
- { name: "mac", scope: "identity", count: 1 },
73
- { name: "artifact_name", scope: "inventory", count: 1 },
74
- { name: "cpu_model", scope: "inventory", count: 1 },
75
- { name: "device_type", scope: "inventory", count: 1 },
76
- { name: "hostname", scope: "inventory", count: 1 },
77
- { name: "ipv4_wlan0", scope: "inventory", count: 1 },
78
- { name: "ipv6_wlan0", scope: "inventory", count: 1 },
79
- { name: "kernel", scope: "inventory", count: 1 },
80
- { name: "mac_eth0", scope: "inventory", count: 1 },
81
- { name: "mac_wlan0", scope: "inventory", count: 1 },
82
- { name: "mem_total_kB", scope: "inventory", count: 1 },
83
- { name: "mender_bootloader_integration", scope: "inventory", count: 1 },
84
- { name: "mender_client_version", scope: "inventory", count: 1 },
85
- { name: "network_interfaces", scope: "inventory", count: 1 },
86
- { name: "os", scope: "inventory", count: 1 },
87
- { name: "rootfs_type", scope: "inventory", count: 1 },
88
- { name: "group", scope: "system", count: 1 }
89
- ];
90
- var searchHandler = async ({ request }) => {
91
- const { page, per_page, filters } = await request.json();
92
- if ([page, per_page, filters].some((item) => !item)) {
93
- return new HttpResponse(null, { status: 509 });
94
- }
95
- const filter = filters.find((filter2) => filter2.scope === "identity" && filter2.attribute === "status" && Object.values(DEVICE_STATES).includes(filter2.value));
96
- const status = filter?.value || "";
97
- if (!status || filters.length > 1) {
98
- if (filters.find((filter2) => filter2.attribute === "group" && filter2.value.includes(Object.keys(mockApiResponses.devices.groups.byId)[0]))) {
99
- return new HttpResponse(JSON.stringify([inventoryDevice, { ...inventoryDevice, id: "b1" }]), {
100
- headers: { [headerNames.total]: 2 }
101
- });
102
- }
103
- if (filters.find((filter2) => filter2.scope === "monitor" && ["failed_last_update", "alerts", "auth_request"].includes(filter2.attribute))) {
104
- return new HttpResponse(JSON.stringify([inventoryDevice]), { headers: { [headerNames.total]: 4 } });
105
- }
106
- return new HttpResponse(JSON.stringify([]), { headers: { [headerNames.total]: 0 } });
107
- }
108
- let deviceList = Array.from({ length: mockApiResponses.devices.byStatus[status].total }, (_, index) => ({
109
- ...inventoryDevice,
110
- attributes: [...inventoryDevice.attributes, { name: "test-count", value: index, scope: "system" }],
111
- id: `${String.fromCharCode("a".charCodeAt(0) + index)}1`
112
- }));
113
- deviceList = deviceList.slice((page - 1) * per_page, page * per_page);
114
- return new HttpResponse(JSON.stringify(deviceList), { headers: { [headerNames.total]: mockApiResponses.devices.byStatus[status].total } });
115
- };
116
- var deviceHandlers = [
117
- http.delete(`${deviceAuthV2}/devices/:deviceId/auth/:authId`, ({ params: { authId, deviceId } }) => {
118
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId)) {
119
- return new HttpResponse(null, { status: 200 });
120
- }
121
- return new HttpResponse(null, { status: 501 });
122
- }),
123
- http.delete(`${deviceAuthV2}/devices/:deviceId`, ({ params: { deviceId } }) => {
124
- if (mockApiResponses.devices.byId[deviceId]) {
125
- return new HttpResponse(null, { status: 200 });
126
- }
127
- return new HttpResponse(null, { status: 502 });
128
- }),
129
- http.delete(`${inventoryApiUrl}/groups/:group`, ({ params: { group } }) => {
130
- if (mockApiResponses.devices.groups.byId[group]) {
131
- return new HttpResponse(null, { status: 200 });
132
- }
133
- return new HttpResponse(null, { status: 515 });
134
- }),
135
- http.delete(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
136
- const deviceIds = await request.json();
137
- if (mockApiResponses.devices.groups.byId[group] && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
138
- return new HttpResponse(null, { status: 200 });
139
- }
140
- return new HttpResponse(null, { status: 503 });
141
- }),
142
- http.delete(`${inventoryApiUrlV2}/filters/:filterId`, ({ params: { filterId } }) => {
143
- if (Object.values(mockApiResponses.devices.groups.byId).find((group) => group.id === filterId)) {
144
- return new HttpResponse(null, { status: 200 });
145
- }
146
- return new HttpResponse(null, { status: 504 });
147
- }),
148
- http.get(`${deviceAuthV2}/devices`, ({ request }) => {
149
- const { searchParams } = new URL(request.url);
150
- const deviceIds = searchParams.getAll("id");
151
- if (deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
152
- return HttpResponse.json(deviceIds.map((id) => ({ ...deviceAuthDevice, id })));
153
- }
154
- return new HttpResponse(null, { status: 505 });
155
- }),
156
- http.get(`${deviceAuthV2}/limits/devices`, () => HttpResponse.json(mockApiResponses.devices.limits)),
157
- http.get(`${inventoryApiUrl}/devices/:deviceId`, ({ params: { deviceId } }) => {
158
- if (mockApiResponses.devices.byId[deviceId]) {
159
- return HttpResponse.json(inventoryDevice);
160
- }
161
- return new HttpResponse(null, { status: 506 });
162
- }),
163
- http.put(`${inventoryApiUrl}/devices/:deviceId/tags`, async ({ params: { deviceId }, request }) => {
164
- const tags = await request.json();
165
- if (!mockApiResponses.devices.byId[deviceId] && !Array.isArray(tags) && !tags.every((item) => item.name && item.value)) {
166
- return new HttpResponse(null, { status: 506 });
167
- }
168
- return HttpResponse.json(tags);
169
- }),
170
- http.get(`${inventoryApiUrl}/groups`, () => {
171
- const groups = Object.entries(mockApiResponses.devices.groups.byId).reduce((accu, [groupName, group]) => {
172
- if (!group.id) {
173
- accu.push(groupName);
174
- }
175
- return accu;
176
- }, []);
177
- return HttpResponse.json(groups);
178
- }),
179
- http.get(`${inventoryApiUrlV2}/filters/attributes`, () => HttpResponse.json(deviceAttributes)),
180
- http.get(`${reportingApiUrl}/devices/attributes`, () => HttpResponse.json({ attributes: deviceAttributes, count: deviceAttributes.length, limit: 100 })),
181
- http.get(`${reportingApiUrl}/devices/search/attributes`, () => HttpResponse.json(deviceAttributes)),
182
- http.post(
183
- `${reportingApiUrl}/devices/aggregate`,
184
- () => HttpResponse.json([
185
- {
186
- name: "*",
187
- items: [
188
- { key: "test", count: 6 },
189
- { key: "original", count: 1 }
190
- ],
191
- other_count: 42
192
- }
193
- ])
194
- ),
195
- http.get(
196
- `${inventoryApiUrlV2}/filters`,
197
- () => HttpResponse.json([
198
- {
199
- id: "filter1",
200
- name: "testGroupDynamic",
201
- terms: [
202
- { scope: "identity", attribute: "id", type: "$in", value: [defaultDeviceId] },
203
- { scope: "identity", attribute: "mac", type: "$exists", value: false },
204
- { scope: "identity", attribute: "kernel", type: "$exists", value: true }
205
- ]
206
- }
207
- ])
208
- ),
209
- http.patch(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
210
- const deviceIds = await request.json();
211
- if (!!group && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
212
- return new HttpResponse(null, { status: 200 });
213
- }
214
- return new HttpResponse(null, { status: 508 });
215
- }),
216
- http.post(`${deviceAuthV2}/devices`, async ({ request }) => {
217
- const authset = await request.json();
218
- if (Object.values(mockApiResponses.devices.byId).some(
219
- (device) => device.auth_sets.some((deviceAuthSet) => deviceAuthSet.pubkey == authset.pubkey || deviceAuthSet.identity_data == authset.identity_data)
220
- )) {
221
- return new HttpResponse(null, { status: 409 });
222
- }
223
- return new HttpResponse(null, { status: 200 });
224
- }),
225
- http.post(`${inventoryApiUrlV2}/filters/search`, searchHandler),
226
- http.post(`${reportingApiUrl}/filters/search`, searchHandler),
227
- http.post(`${inventoryApiUrlV2}/filters`, async ({ request }) => {
228
- const { name, terms } = await request.json();
229
- if ([name, terms].some((item) => !item) || mockApiResponses.devices.groups[name] || !terms.every((term) => DEVICE_FILTERING_OPTIONS[term.type] && ["identity", "inventory", "system"].includes(term.scope) && !!term.value && !!term.attribute)) {
230
- return new HttpResponse(null, { status: 510 });
231
- }
232
- return new HttpResponse(JSON.stringify({}), { headers: { location: "find/me/here/createdFilterId" } });
233
- }),
234
- http.get(
235
- `${inventoryApiUrlV2}/statistics`,
236
- async () => HttpResponse.json({
237
- devices_by_status: {
238
- accepted: { standard: mockApiResponses.devices.byStatus.accepted.total, micro: 0, system: 0 },
239
- pending: { standard: mockApiResponses.devices.byStatus.pending.total, micro: 0, system: 0 }
240
- }
241
- })
242
- ),
243
- http.put(`${deviceAuthV2}/devices/:deviceId/auth/:authId/status`, async ({ params: { authId, deviceId }, request }) => {
244
- const { status } = await request.json();
245
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId) && DEVICE_STATES[status]) {
246
- return new HttpResponse(null, { status: 200 });
247
- }
248
- return new HttpResponse(null, { status: 511 });
249
- }),
250
- http.get(`${deviceConfig}/:deviceId`, ({ params: { deviceId } }) => {
251
- if (deviceId === "testId") {
252
- return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
253
- }
254
- if (mockApiResponses.devices.byId[deviceId]) {
255
- return HttpResponse.json({
256
- configured: { test: true, something: "else", aNumber: 42 },
257
- deployment_id: "config1",
258
- reported: { test: true, something: "else", aNumber: 42 },
259
- updated_ts: updatedTime,
260
- reported_ts: "2019-01-01T09:25:01.000Z"
261
- });
262
- }
263
- return new HttpResponse(null, { status: 512 });
264
- }),
265
- http.put(`${deviceConfig}/:deviceId`, async ({ params: { deviceId }, request }) => {
266
- const body = await request.text();
267
- if (body.includes("evilValue")) {
268
- return new HttpResponse(null, { status: 418 });
269
- }
270
- return new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 201 : 513 });
271
- }),
272
- http.post(`${deviceConfig}/:deviceId/deploy`, ({ params: { deviceId } }) => {
273
- if (mockApiResponses.devices.byId[deviceId]) {
274
- return HttpResponse.json({ deployment_id: "config1" });
275
- }
276
- return new HttpResponse(null, { status: 514 });
277
- }),
278
- http.get(`${deviceConnect}/devices/:deviceId`, ({ params: { deviceId } }) => {
279
- if (deviceId === "testId") {
280
- return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
281
- }
282
- if (mockApiResponses.devices.byId[deviceId]) {
283
- return HttpResponse.json({ status: "connected", updated_ts: mockApiResponses.devices.byId[deviceId].updated_ts });
284
- }
285
- return new HttpResponse(null, { status: 512 });
286
- }),
287
- http.post(`${deviceConnect}/devices/:deviceId/:action`, ({ params: { deviceId, action } }) => {
288
- if (["check-update", "send-inventory"].includes(action) && mockApiResponses.devices.byId[deviceId]) {
289
- return new HttpResponse(null, { status: 202 });
290
- }
291
- return new HttpResponse(null, { status: 518 });
292
- }),
293
- http.get(`${iotManagerBaseURL}/devices/:deviceId/state`, ({ params: { deviceId } }) => {
294
- if (mockApiResponses.devices.byId[deviceId]) {
295
- return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
296
- }
297
- return new HttpResponse(null, { status: 515 });
298
- }),
299
- http.put(`${iotManagerBaseURL}/devices/:deviceId/state/:integrationId`, async ({ params: { deviceId }, request }) => {
300
- const body = await request.json();
301
- if (mockApiResponses.devices.byId[deviceId] && body) {
302
- return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
303
- }
304
- return new HttpResponse(null, { status: 516 });
305
- }),
306
- http.put(
307
- `${deviceConnect}/devices/:deviceId/upload`,
308
- ({ params: { deviceId } }) => new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 200 : 517 })
309
- ),
310
- http.get(`${deviceAuthV2}/license`, () => HttpResponse.text("test,report"))
311
- ];
312
-
313
- export {
314
- defaultDeviceId,
315
- inventoryDevice,
316
- deviceHandlers
317
- };
318
- //# sourceMappingURL=chunk-TVJ6K2KG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/requestHandlers/deviceHandlers.ts"],"sourcesContent":["// Copyright 2020 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport {\n DEVICE_FILTERING_OPTIONS,\n DEVICE_STATES,\n deviceAuthV2,\n deviceConfig,\n deviceConnect,\n headerNames,\n inventoryApiUrl,\n inventoryApiUrlV2,\n iotManagerBaseURL,\n reportingApiUrl\n} from '@northern.tech/utils/constants';\nimport { HttpResponse, http } from 'msw';\n\nimport { defaultCreationDate, defaultMacAddress, mockApiResponses } from '../mockData';\n\nexport const defaultDeviceId = 'a1';\n\nconst deviceAuthDevice = {\n id: defaultDeviceId,\n identity_data: { mac: defaultMacAddress },\n status: 'accepted',\n decommissioning: false,\n created_ts: defaultCreationDate,\n updated_ts: '2019-01-01T09:25:00.000Z',\n auth_sets: [\n {\n id: 'auth1',\n identity_data: { mac: defaultMacAddress },\n pubkey: '-----BEGIN PUBLIC KEY-----\\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\\n-----END PUBLIC KEY-----\\n',\n ts: defaultCreationDate,\n status: 'accepted'\n }\n ]\n};\n\nconst checkInTimeExact = '2019-01-01T10:25:00.000Z';\nconst updatedTime = '2019-01-01T09:25:00.000Z';\n\nexport const inventoryDevice = {\n id: defaultDeviceId,\n attributes: [\n { name: 'network_interfaces', value: ['eth0', 'wlan0'], scope: 'inventory' },\n { name: 'kernel', value: 'Linux version 4.19.75-v7l+', scope: 'inventory' },\n { name: 'artifact_name', value: 'raspotifyInstaller', scope: 'inventory' },\n { name: 'ipv6_wlan0', value: 'fe80::68d9:8453:3e9c:7c80/64', scope: 'inventory' },\n { name: 'mac_eth0', value: defaultMacAddress, scope: 'inventory' },\n { name: 'rootfs_type', value: 'ext4', scope: 'inventory' },\n { name: 'mender_bootloader_integration', value: 'unknown', scope: 'inventory' },\n { name: 'cpu_model', value: 'ARMv7 Processor rev 3 (v7l)', scope: 'inventory' },\n { name: 'hostname', value: 'raspberrypi', scope: 'inventory' },\n { name: 'mender_client_version', value: '2.1.0', scope: 'inventory' },\n { name: 'ipv4_wlan0', value: '192.168.10.141/24', scope: 'inventory' },\n { name: 'device_type', value: 'raspberrypi4', scope: 'inventory' },\n { name: 'mem_total_kB', value: '1986024', scope: 'inventory' },\n { name: 'mac_wlan0', value: 'dc:a6:32:12:ad:c0', scope: 'inventory' },\n { name: 'os', value: 'Raspbian GNU/Linux 10 (buster)', scope: 'inventory' },\n { name: 'created_ts', value: defaultCreationDate, scope: 'system' },\n { name: 'updated_ts', value: updatedTime, scope: 'system' },\n { name: 'status', value: 'accepted', scope: 'identity' },\n { name: 'mac', value: defaultMacAddress, scope: 'identity' },\n { name: 'group', value: 'test', scope: 'system' }\n ],\n check_in_time: checkInTimeExact,\n updated_ts: updatedTime\n};\n\nconst deviceAttributes = [\n { name: 'status', scope: 'identity', count: 5 },\n { name: 'created_ts', scope: 'system', count: 5 },\n { name: 'updated_ts', scope: 'system', count: 5 },\n { name: 'mac', scope: 'identity', count: 1 },\n { name: 'artifact_name', scope: 'inventory', count: 1 },\n { name: 'cpu_model', scope: 'inventory', count: 1 },\n { name: 'device_type', scope: 'inventory', count: 1 },\n { name: 'hostname', scope: 'inventory', count: 1 },\n { name: 'ipv4_wlan0', scope: 'inventory', count: 1 },\n { name: 'ipv6_wlan0', scope: 'inventory', count: 1 },\n { name: 'kernel', scope: 'inventory', count: 1 },\n { name: 'mac_eth0', scope: 'inventory', count: 1 },\n { name: 'mac_wlan0', scope: 'inventory', count: 1 },\n { name: 'mem_total_kB', scope: 'inventory', count: 1 },\n { name: 'mender_bootloader_integration', scope: 'inventory', count: 1 },\n { name: 'mender_client_version', scope: 'inventory', count: 1 },\n { name: 'network_interfaces', scope: 'inventory', count: 1 },\n { name: 'os', scope: 'inventory', count: 1 },\n { name: 'rootfs_type', scope: 'inventory', count: 1 },\n { name: 'group', scope: 'system', count: 1 }\n];\n\nconst searchHandler = async ({ request }) => {\n const { page, per_page, filters } = await request.json();\n if ([page, per_page, filters].some(item => !item)) {\n return new HttpResponse(null, { status: 509 });\n }\n const filter = filters.find(filter => filter.scope === 'identity' && filter.attribute === 'status' && Object.values(DEVICE_STATES).includes(filter.value));\n const status = filter?.value || '';\n if (!status || filters.length > 1) {\n if (filters.find(filter => filter.attribute === 'group' && filter.value.includes(Object.keys(mockApiResponses.devices.groups.byId)[0]))) {\n return new HttpResponse(JSON.stringify([inventoryDevice, { ...inventoryDevice, id: 'b1' }]), {\n headers: { [headerNames.total]: 2 }\n });\n }\n if (filters.find(filter => filter.scope === 'monitor' && ['failed_last_update', 'alerts', 'auth_request'].includes(filter.attribute))) {\n return new HttpResponse(JSON.stringify([inventoryDevice]), { headers: { [headerNames.total]: 4 } });\n }\n return new HttpResponse(JSON.stringify([]), { headers: { [headerNames.total]: 0 } });\n }\n let deviceList = Array.from({ length: mockApiResponses.devices.byStatus[status].total }, (_, index) => ({\n ...inventoryDevice,\n attributes: [...inventoryDevice.attributes, { name: 'test-count', value: index, scope: 'system' }],\n id: `${String.fromCharCode('a'.charCodeAt(0) + index)}1`\n }));\n deviceList = deviceList.slice((page - 1) * per_page, page * per_page);\n return new HttpResponse(JSON.stringify(deviceList), { headers: { [headerNames.total]: mockApiResponses.devices.byStatus[status].total } });\n};\n\nexport const deviceHandlers = [\n http.delete(`${deviceAuthV2}/devices/:deviceId/auth/:authId`, ({ params: { authId, deviceId } }) => {\n if (mockApiResponses.devices.byId[deviceId].auth_sets.find(authSet => authSet.id === authId)) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 501 });\n }),\n http.delete(`${deviceAuthV2}/devices/:deviceId`, ({ params: { deviceId } }) => {\n if (mockApiResponses.devices.byId[deviceId]) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 502 });\n }),\n http.delete(`${inventoryApiUrl}/groups/:group`, ({ params: { group } }) => {\n if (mockApiResponses.devices.groups.byId[group]) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 515 });\n }),\n http.delete(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {\n const deviceIds = await request.json();\n if (mockApiResponses.devices.groups.byId[group] && deviceIds.every(id => !!mockApiResponses.devices.byId[id])) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 503 });\n }),\n http.delete(`${inventoryApiUrlV2}/filters/:filterId`, ({ params: { filterId } }) => {\n if (Object.values(mockApiResponses.devices.groups.byId).find(group => group.id === filterId)) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 504 });\n }),\n http.get(`${deviceAuthV2}/devices`, ({ request }) => {\n const { searchParams } = new URL(request.url);\n const deviceIds = searchParams.getAll('id');\n if (deviceIds.every(id => !!mockApiResponses.devices.byId[id])) {\n return HttpResponse.json(deviceIds.map(id => ({ ...deviceAuthDevice, id })));\n }\n return new HttpResponse(null, { status: 505 });\n }),\n http.get(`${deviceAuthV2}/limits/devices`, () => HttpResponse.json(mockApiResponses.devices.limits)),\n http.get(`${inventoryApiUrl}/devices/:deviceId`, ({ params: { deviceId } }) => {\n if (mockApiResponses.devices.byId[deviceId]) {\n return HttpResponse.json(inventoryDevice);\n }\n return new HttpResponse(null, { status: 506 });\n }),\n http.put(`${inventoryApiUrl}/devices/:deviceId/tags`, async ({ params: { deviceId }, request }) => {\n const tags = await request.json();\n if (!mockApiResponses.devices.byId[deviceId] && !Array.isArray(tags) && !tags.every(item => item.name && item.value)) {\n return new HttpResponse(null, { status: 506 });\n }\n return HttpResponse.json(tags);\n }),\n http.get(`${inventoryApiUrl}/groups`, () => {\n const groups = Object.entries(mockApiResponses.devices.groups.byId).reduce((accu, [groupName, group]) => {\n if (!group.id) {\n accu.push(groupName);\n }\n return accu;\n }, []);\n return HttpResponse.json(groups);\n }),\n http.get(`${inventoryApiUrlV2}/filters/attributes`, () => HttpResponse.json(deviceAttributes)),\n http.get(`${reportingApiUrl}/devices/attributes`, () => HttpResponse.json({ attributes: deviceAttributes, count: deviceAttributes.length, limit: 100 })),\n http.get(`${reportingApiUrl}/devices/search/attributes`, () => HttpResponse.json(deviceAttributes)),\n http.post(`${reportingApiUrl}/devices/aggregate`, () =>\n HttpResponse.json([\n {\n name: '*',\n items: [\n { key: 'test', count: 6 },\n { key: 'original', count: 1 }\n ],\n other_count: 42\n }\n ])\n ),\n http.get(`${inventoryApiUrlV2}/filters`, () =>\n HttpResponse.json([\n {\n id: 'filter1',\n name: 'testGroupDynamic',\n terms: [\n { scope: 'identity', attribute: 'id', type: '$in', value: [defaultDeviceId] },\n { scope: 'identity', attribute: 'mac', type: '$exists', value: false },\n { scope: 'identity', attribute: 'kernel', type: '$exists', value: true }\n ]\n }\n ])\n ),\n http.patch(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {\n const deviceIds = await request.json();\n if (!!group && deviceIds.every(id => !!mockApiResponses.devices.byId[id])) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 508 });\n }),\n http.post(`${deviceAuthV2}/devices`, async ({ request }) => {\n const authset = await request.json();\n if (\n Object.values(mockApiResponses.devices.byId).some(device =>\n device.auth_sets.some(deviceAuthSet => deviceAuthSet.pubkey == authset.pubkey || deviceAuthSet.identity_data == authset.identity_data)\n )\n ) {\n return new HttpResponse(null, { status: 409 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.post(`${inventoryApiUrlV2}/filters/search`, searchHandler),\n http.post(`${reportingApiUrl}/filters/search`, searchHandler),\n http.post(`${inventoryApiUrlV2}/filters`, async ({ request }) => {\n const { name, terms } = await request.json();\n if (\n [name, terms].some(item => !item) ||\n mockApiResponses.devices.groups[name] ||\n !terms.every(term => DEVICE_FILTERING_OPTIONS[term.type] && ['identity', 'inventory', 'system'].includes(term.scope) && !!term.value && !!term.attribute)\n ) {\n return new HttpResponse(null, { status: 510 });\n }\n return new HttpResponse(JSON.stringify({}), { headers: { location: 'find/me/here/createdFilterId' } });\n }),\n http.get(`${inventoryApiUrlV2}/statistics`, async () =>\n HttpResponse.json({\n devices_by_status: {\n accepted: { standard: mockApiResponses.devices.byStatus.accepted.total, micro: 0, system: 0 },\n pending: { standard: mockApiResponses.devices.byStatus.pending.total, micro: 0, system: 0 }\n }\n })\n ),\n http.put(`${deviceAuthV2}/devices/:deviceId/auth/:authId/status`, async ({ params: { authId, deviceId }, request }) => {\n const { status } = await request.json();\n if (mockApiResponses.devices.byId[deviceId].auth_sets.find(authSet => authSet.id === authId) && DEVICE_STATES[status]) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 511 });\n }),\n http.get(`${deviceConfig}/:deviceId`, ({ params: { deviceId } }) => {\n if (deviceId === 'testId') {\n return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });\n }\n if (mockApiResponses.devices.byId[deviceId]) {\n return HttpResponse.json({\n configured: { test: true, something: 'else', aNumber: 42 },\n deployment_id: 'config1',\n reported: { test: true, something: 'else', aNumber: 42 },\n updated_ts: updatedTime,\n reported_ts: '2019-01-01T09:25:01.000Z'\n });\n }\n return new HttpResponse(null, { status: 512 });\n }),\n http.put(`${deviceConfig}/:deviceId`, async ({ params: { deviceId }, request }) => {\n const body = await request.text();\n if (body.includes('evilValue')) {\n return new HttpResponse(null, { status: 418 });\n }\n return new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 201 : 513 });\n }),\n http.post(`${deviceConfig}/:deviceId/deploy`, ({ params: { deviceId } }) => {\n if (mockApiResponses.devices.byId[deviceId]) {\n return HttpResponse.json({ deployment_id: 'config1' });\n }\n return new HttpResponse(null, { status: 514 });\n }),\n http.get(`${deviceConnect}/devices/:deviceId`, ({ params: { deviceId } }) => {\n if (deviceId === 'testId') {\n return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });\n }\n if (mockApiResponses.devices.byId[deviceId]) {\n return HttpResponse.json({ status: 'connected', updated_ts: mockApiResponses.devices.byId[deviceId].updated_ts });\n }\n return new HttpResponse(null, { status: 512 });\n }),\n http.post(`${deviceConnect}/devices/:deviceId/:action`, ({ params: { deviceId, action } }) => {\n if (['check-update', 'send-inventory'].includes(action) && mockApiResponses.devices.byId[deviceId]) {\n return new HttpResponse(null, { status: 202 });\n }\n return new HttpResponse(null, { status: 518 });\n }),\n http.get(`${iotManagerBaseURL}/devices/:deviceId/state`, ({ params: { deviceId } }) => {\n if (mockApiResponses.devices.byId[deviceId]) {\n return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });\n }\n return new HttpResponse(null, { status: 515 });\n }),\n http.put(`${iotManagerBaseURL}/devices/:deviceId/state/:integrationId`, async ({ params: { deviceId }, request }) => {\n const body = await request.json();\n if (mockApiResponses.devices.byId[deviceId] && body) {\n return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });\n }\n return new HttpResponse(null, { status: 516 });\n }),\n http.put(\n `${deviceConnect}/devices/:deviceId/upload`,\n ({ params: { deviceId } }) => new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 200 : 517 })\n ),\n http.get(`${deviceAuthV2}/license`, () => HttpResponse.text('test,report'))\n];\n"],"mappings":";;;;;;;AAcA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,YAAY;AAI5B,IAAM,kBAAkB;AAE/B,IAAM,mBAAmB;AAAA,EACvB,IAAI;AAAA,EACJ,eAAe,EAAE,KAAK,kBAAkB;AAAA,EACxC,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,IACT;AAAA,MACE,IAAI;AAAA,MACJ,eAAe,EAAE,KAAK,kBAAkB;AAAA,MACxC,QAAQ;AAAA,MACR,IAAI;AAAA,MACJ,QAAQ;AAAA,IACV;AAAA,EACF;AACF;AAEA,IAAM,mBAAmB;AACzB,IAAM,cAAc;AAEb,IAAM,kBAAkB;AAAA,EAC7B,IAAI;AAAA,EACJ,YAAY;AAAA,IACV,EAAE,MAAM,sBAAsB,OAAO,CAAC,QAAQ,OAAO,GAAG,OAAO,YAAY;AAAA,IAC3E,EAAE,MAAM,UAAU,OAAO,8BAA8B,OAAO,YAAY;AAAA,IAC1E,EAAE,MAAM,iBAAiB,OAAO,sBAAsB,OAAO,YAAY;AAAA,I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D,KAAK,IAAI,GAAG,iBAAiB,2CAA2C,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,QAAQ,MAAM;AACnH,UAAM,OAAO,MAAM,QAAQ,KAAK;AAChC,QAAI,iBAAiB,QAAQ,KAAK,QAAQ,KAAK,MAAM;AACnD,aAAO,aAAa,KAAK,EAAE,eAAe,iBAAiB,YAAY,KAAK,GAAG,GAAG,CAAC;AAAA,IACrF;AACA,WAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC/C,CAAC;AAAA,EACD,KAAK;AAAA,IACH,GAAG,aAAa;AAAA,IAChB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,IAAI,aAAa,MAAM,EAAE,QAAQ,iBAAiB,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,CAAC;AAAA,EACtH;AAAA,EACA,KAAK,IAAI,GAAG,YAAY,YAAY,MAAM,aAAa,KAAK,aAAa,CAAC;AAC5E;","names":["filter"]}
@@ -1,29 +0,0 @@
1
- import {
2
- mockApiResponses
3
- } from "./chunk-CT35JRBC.js";
4
-
5
- // src/requestHandlers/monitorHandlers.ts
6
- import { alertChannels, headerNames, monitorApiUrlv1 } from "@northern.tech/utils/constants";
7
- import { HttpResponse, http } from "msw";
8
- var monitorHandlers = [
9
- http.get(`${monitorApiUrlv1}/devices/:id/alerts`, () => new HttpResponse(JSON.stringify([]), { headers: { [headerNames.total]: 1 } })),
10
- http.get(`${monitorApiUrlv1}/devices/:id/alerts/latest`, () => HttpResponse.json([])),
11
- http.get(`${monitorApiUrlv1}/devices/:id/config`, ({ params: { id } }) => {
12
- if (id === mockApiResponses.devices.byId.a1.id) {
13
- return HttpResponse.json([{ something: "here" }]);
14
- }
15
- return HttpResponse.json([]);
16
- }),
17
- http.put(`${monitorApiUrlv1}/settings/global/channel/alerts/:channel/status`, async ({ params: { channel }, request }) => {
18
- const { enabled } = await request.json();
19
- if (Object.keys(alertChannels).includes(channel) && enabled !== void 0) {
20
- return new HttpResponse(null, { status: 200 });
21
- }
22
- return new HttpResponse(null, { status: 590 });
23
- })
24
- ];
25
-
26
- export {
27
- monitorHandlers
28
- };
29
- //# sourceMappingURL=chunk-WFNPT672.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/requestHandlers/monitorHandlers.ts"],"sourcesContent":["// Copyright 2021 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport { alertChannels, headerNames, monitorApiUrlv1 } from '@northern.tech/utils/constants';\nimport { HttpResponse, http } from 'msw';\n\nimport { mockApiResponses } from '../mockData';\n\nexport const monitorHandlers = [\n http.get(`${monitorApiUrlv1}/devices/:id/alerts`, () => new HttpResponse(JSON.stringify([]), { headers: { [headerNames.total]: 1 } })),\n http.get(`${monitorApiUrlv1}/devices/:id/alerts/latest`, () => HttpResponse.json([])),\n http.get(`${monitorApiUrlv1}/devices/:id/config`, ({ params: { id } }) => {\n if (id === mockApiResponses.devices.byId.a1.id) {\n return HttpResponse.json([{ something: 'here' }]);\n }\n return HttpResponse.json([]);\n }),\n http.put(`${monitorApiUrlv1}/settings/global/channel/alerts/:channel/status`, async ({ params: { channel }, request }) => {\n const { enabled } = await request.json();\n if (Object.keys(alertChannels).includes(channel) && enabled !== undefined) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 590 });\n })\n];\n"],"mappings":";;;;;AAcA,SAAS,eAAe,aAAa,uBAAuB;AAC5D,SAAS,cAAc,YAAY;AAI5B,IAAM,kBAAkB;AAAA,EAC7B,KAAK,IAAI,GAAG,eAAe,uBAAuB,MAAM,IAAI,aAAa,KAAK,UAAU,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,YAAY,KAAK,GAAG,EAAE,EAAE,CAAC,CAAC;AAAA,EACrI,KAAK,IAAI,GAAG,eAAe,8BAA8B,MAAM,aAAa,KAAK,CAAC,CAAC,CAAC;AAAA,EACpF,KAAK,IAAI,GAAG,eAAe,uBAAuB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM;AACxE,QAAI,OAAO,iBAAiB,QAAQ,KAAK,GAAG,IAAI;AAC9C,aAAO,aAAa,KAAK,CAAC,EAAE,WAAW,OAAO,CAAC,CAAC;AAAA,IAClD;AACA,WAAO,aAAa,KAAK,CAAC,CAAC;AAAA,EAC7B,CAAC;AAAA,EACD,KAAK,IAAI,GAAG,eAAe,mDAAmD,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,MAAM;AACxH,UAAM,EAAE,QAAQ,IAAI,MAAM,QAAQ,KAAK;AACvC,QAAI,OAAO,KAAK,aAAa,EAAE,SAAS,OAAO,KAAK,YAAY,QAAW;AACzE,aAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC/C;AACA,WAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC/C,CAAC;AACH;","names":[]}