@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,1113 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/requestHandlers/deviceHandlers.ts
21
- var deviceHandlers_exports = {};
22
- __export(deviceHandlers_exports, {
23
- defaultDeviceId: () => defaultDeviceId,
24
- deviceHandlers: () => deviceHandlers,
25
- inventoryDevice: () => inventoryDevice
26
- });
27
- module.exports = __toCommonJS(deviceHandlers_exports);
28
- var import_constants2 = require("@northern.tech/utils/constants");
29
- var import_msw = require("msw");
30
-
31
- // src/mockData.ts
32
- var import_constants = require("@northern.tech/utils/constants");
33
- var TEST_SESSION_DATETIME = "2019-01-13T13:00:00.000Z";
34
- var testDate = new Date(TEST_SESSION_DATETIME);
35
- var mockDate = new Date(testDate.setMilliseconds(testDate.getMilliseconds() + import_constants.maxSessionAge));
36
- var defaultCreationDate = "2019-01-13T06:25:00.000Z";
37
- var defaultMacAddress = "dc:a6:32:12:ad:bf";
38
- var permissionSetObjectTypes = {
39
- any: "Any",
40
- artifacts: "Artifacts",
41
- empty: "",
42
- groups: "Device groups",
43
- releases: "Releases",
44
- tenantManagement: "Tenant management",
45
- userManagement: "User management"
46
- };
47
- var commonEndpoints = {
48
- artifacts: "^/api/management/v1/deployments/artifacts",
49
- artifactDetails: "^/api/management/v1/deployments/artifacts/[^/]+",
50
- deviceManagement: "^/api/management/(v[1-9])/(devauth|inventory)/"
51
- };
52
- var userId = "a30a780b-b843-5344-80e3-0fd95a4f6fc3";
53
- var defaultUser = {
54
- created_ts: "2019-01-01T10:30:00.000Z",
55
- email: "a@b.com",
56
- id: "a1",
57
- roles: ["RBAC_ROLE_PERMIT_ALL"],
58
- tfa_status: "enabled",
59
- verified: true
60
- };
61
- var deviceTypes = { qemu: "qemux86-64" };
62
- var checkInTimeRounded = "2019-01-01T00:00:00.000Z";
63
- var checkInTimeExact = "2019-01-01T10:25:00.000Z";
64
- var mockApiResponses = {
65
- deployments: {
66
- byId: {
67
- d1: {
68
- id: "d1",
69
- name: "test deployment",
70
- created: "2019-01-01T12:30:00.000Z",
71
- devices: {
72
- a1: {
73
- id: "a1",
74
- status: "installing",
75
- attributes: {},
76
- image: { size: 123 }
77
- }
78
- },
79
- statistics: {
80
- status: {
81
- "already-installed": 0,
82
- decommissioned: 0,
83
- downloading: 0,
84
- failure: 0,
85
- installing: 1,
86
- noartifact: 0,
87
- pending: 0,
88
- rebooting: 0,
89
- success: 0
90
- },
91
- total_size: 1234
92
- }
93
- },
94
- d2: {
95
- id: "d2",
96
- name: "test deployment 2",
97
- artifact_name: "r1",
98
- artifacts: ["123"],
99
- created: "2019-01-01T12:25:00.000Z",
100
- device_count: 1,
101
- devices: {
102
- b1: {
103
- attributes: {},
104
- id: "b1",
105
- status: "pending"
106
- }
107
- },
108
- filter: void 0,
109
- group: void 0,
110
- statistics: {
111
- status: {
112
- downloading: 0,
113
- decommissioned: 0,
114
- failure: 0,
115
- installing: 0,
116
- noartifact: 0,
117
- pending: 1,
118
- rebooting: 0,
119
- success: 0,
120
- "already-installed": 0
121
- }
122
- }
123
- },
124
- d3: {
125
- id: "d3",
126
- name: "Test",
127
- phases: [
128
- { id: "0", batch_size: 2, device_count: 2 },
129
- { id: "1", start_ts: "2019-02-04T11:45:10.002Z", batch_size: 3, device_count: 3 },
130
- { id: "2", start_ts: "2019-02-05T11:45:10.002Z", batch_size: 5, device_count: 5 },
131
- { id: "3", start_ts: "2019-02-06T11:45:10.002Z", batch_size: 5, device_count: 5 },
132
- { id: "4", start_ts: "2019-02-21T11:45:10.002Z", batch_size: 5, device_count: 0 }
133
- ],
134
- max_devices: 0,
135
- created: "2019-01-31T12:59:30.020Z",
136
- devices: {},
137
- filter: void 0,
138
- group: void 0,
139
- stats: {
140
- pending: 3,
141
- decommissioned: 0,
142
- failure: 23,
143
- pause_before_committing: 0,
144
- pause_before_rebooting: 0,
145
- installing: 0,
146
- rebooting: 0,
147
- "already-installed": 0,
148
- pause_before_installing: 0,
149
- downloading: 0,
150
- success: 6,
151
- aborted: 0,
152
- noartifact: 0
153
- },
154
- statistics: { total_size: "1234" },
155
- status: "inprogress",
156
- active: true,
157
- device_count: 100,
158
- retries: "0",
159
- type: "software"
160
- }
161
- },
162
- byStatus: {
163
- pending: { deploymentIds: ["d2"] },
164
- inprogress: { deploymentIds: ["d3"] }
165
- }
166
- },
167
- devices: {
168
- byId: {
169
- a1: {
170
- id: "a1",
171
- auth_sets: [
172
- {
173
- id: "auth1",
174
- identity_data: { mac: defaultMacAddress },
175
- pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
176
- status: "accepted",
177
- ts: defaultCreationDate
178
- }
179
- ],
180
- updated_ts: "2019-01-01T09:25:00.000Z"
181
- },
182
- b1: {
183
- id: "b1",
184
- attributes: {
185
- ipv4_wlan0: "192.168.10.141/24",
186
- device_type: [deviceTypes.qemu]
187
- },
188
- system: {
189
- check_in_time: checkInTimeRounded
190
- },
191
- check_in_time: checkInTimeExact,
192
- check_in_time_exact: checkInTimeExact,
193
- check_in_time_rounded: checkInTimeRounded,
194
- identity_data: { mac: defaultMacAddress },
195
- status: "accepted",
196
- decommissioning: false,
197
- created_ts: defaultCreationDate,
198
- updated_ts: "2019-01-01T09:25:00.000Z",
199
- auth_sets: [
200
- {
201
- id: "auth1",
202
- identity_data: { mac: defaultMacAddress },
203
- pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
204
- ts: defaultCreationDate,
205
- status: "accepted"
206
- }
207
- ]
208
- }
209
- },
210
- groups: {
211
- byId: {
212
- testGroup: {
213
- deviceIds: ["a1", "b1"],
214
- filters: [],
215
- total: 2
216
- },
217
- testGroupDynamic: {
218
- id: "filter1",
219
- name: "filter1",
220
- filters: [{ scope: "system", key: "group", operator: "$eq", value: "things" }]
221
- }
222
- }
223
- },
224
- limits: { standard: 500, micro: 0, system: 0 },
225
- byStatus: {
226
- accepted: { deviceIds: ["a1", "b1"], total: 2 },
227
- active: { deviceIds: [], total: 0 },
228
- inactive: { deviceIds: [], total: 0 },
229
- pending: { deviceIds: ["c1"], total: 1 },
230
- preauthorized: { deviceIds: [], total: 0 },
231
- rejected: { deviceIds: [], total: 0 }
232
- }
233
- },
234
- organization: {
235
- organization: {
236
- id: "1",
237
- addons: [],
238
- name: "test",
239
- plan: "os",
240
- trial: false
241
- },
242
- products: [
243
- {
244
- name: "mender_standard",
245
- billing_unit: "devices",
246
- prices: [
247
- {
248
- plan: "os",
249
- constraints: {
250
- min: 50,
251
- max: 1e3,
252
- div: 50
253
- }
254
- },
255
- {
256
- plan: "professional",
257
- constraints: {
258
- min: 250,
259
- max: 1e4,
260
- div: 50
261
- }
262
- }
263
- ],
264
- addons: [
265
- {
266
- name: "troubleshoot",
267
- prices: [{ plan: "os" }, { plan: "professional" }]
268
- },
269
- {
270
- name: "configure",
271
- prices: [{ plan: "os" }, { plan: "professional" }]
272
- },
273
- {
274
- name: "monitor",
275
- prices: [{ plan: "professional" }]
276
- }
277
- ]
278
- },
279
- {
280
- name: "mender_micro",
281
- billing_unit: "devices",
282
- prices: [
283
- {
284
- plan: "os",
285
- constraints: {
286
- min: 50,
287
- max: 5e3,
288
- div: 50
289
- }
290
- },
291
- {
292
- plan: "professional",
293
- constraints: {
294
- min: 500,
295
- max: 1e5,
296
- div: 50
297
- }
298
- }
299
- ]
300
- }
301
- ],
302
- intentId: "testIntent",
303
- auditlog: {
304
- events: [
305
- {
306
- actor: {
307
- id: "string",
308
- type: "user",
309
- email: "string@example.com"
310
- },
311
- time: "2019-01-01T12:10:22.667Z",
312
- action: "create",
313
- object: {
314
- id: "string",
315
- type: "user",
316
- user: {
317
- email: "user@acme.com"
318
- }
319
- },
320
- change: "change1"
321
- },
322
- {
323
- actor: {
324
- id: "string",
325
- type: "user",
326
- email: "string",
327
- identity_data: "string"
328
- },
329
- time: "2019-01-01T12:16:22.667Z",
330
- action: "create",
331
- object: {
332
- id: "string",
333
- type: "deployment",
334
- deployment: {
335
- name: "production",
336
- artifact_name: "Application 0.0.1"
337
- }
338
- },
339
- change: "change2"
340
- },
341
- {
342
- actor: {
343
- id: "string",
344
- type: "user",
345
- email: "string@example.com"
346
- },
347
- time: "2019-01-01T12:10:22.669Z",
348
- action: "open_terminal",
349
- meta: {
350
- session_id: ["abd313a8-ee88-48ab-9c99-fbcd80048e6e"]
351
- },
352
- object: {
353
- id: "a1",
354
- type: "device"
355
- },
356
- change: "change3"
357
- }
358
- ]
359
- }
360
- },
361
- releases: {
362
- byId: {
363
- r1: {
364
- name: "r1",
365
- artifacts: [
366
- {
367
- id: "art1",
368
- description: "test description",
369
- device_types_compatible: [deviceTypes.qemu],
370
- modified: "2020-09-10T12:16:22.667Z",
371
- updates: [{ type_info: { type: "testtype" } }],
372
- artifact_depends: {
373
- device_type: [deviceTypes.qemu]
374
- },
375
- artifact_provides: {
376
- artifact_name: "myapp",
377
- "data-partition.myapp.version": "v2020.10",
378
- list_of_fancy: [deviceTypes.qemu, "x172"]
379
- },
380
- clears_artifact_provides: ["data-partition.myapp.*"]
381
- }
382
- ],
383
- device_types_compatible: [deviceTypes.qemu],
384
- modified: "2020-09-10T12:16:22.667Z",
385
- metaData: {}
386
- }
387
- }
388
- },
389
- users: {
390
- byId: {
391
- a1: defaultUser,
392
- [userId]: { ...defaultUser, id: userId, email: "a2@b.com", created_ts: "2019-01-01T12:30:00.000Z" }
393
- },
394
- rolesById: {
395
- admin: {
396
- name: "admin",
397
- description: "Administrator role",
398
- permissions: []
399
- },
400
- test: { name: "test", description: "test description", permissions: [] }
401
- },
402
- globalSettings: {
403
- "2fa": "enabled",
404
- id_attribute: void 0,
405
- previousFilters: []
406
- },
407
- userSettings: {
408
- "2fa": "disabled",
409
- columnSelection: [],
410
- onboarding: { something: "here" },
411
- tooltips: {},
412
- previousFilters: []
413
- }
414
- }
415
- };
416
- var releasesList = Array.from({ length: 5e3 }, (x, i) => ({
417
- artifacts: [
418
- {
419
- id: "art1",
420
- description: "test description",
421
- device_types_compatible: [deviceTypes.qemu],
422
- modified: "2020-09-10T12:16:22.667Z",
423
- updates: [{ type_info: { type: "testtype" } }],
424
- artifact_depends: {
425
- device_type: [deviceTypes.qemu]
426
- },
427
- artifact_provides: {
428
- artifact_name: "myapp",
429
- "data-partition.myapp.version": "v2020.10",
430
- list_of_fancy: [deviceTypes.qemu, "x172"]
431
- },
432
- clears_artifact_provides: ["data-partition.myapp.*"]
433
- }
434
- ],
435
- device_types_compatible: [deviceTypes.qemu],
436
- metaData: {},
437
- name: `release-${i + 1}`,
438
- modified: i
439
- }));
440
- var permissionSets = [
441
- {
442
- ...import_constants.defaultPermissionSets.Basic,
443
- object: permissionSetObjectTypes.empty,
444
- description: "Set containing basic permissions.",
445
- permissions: [
446
- { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/settings$" } },
447
- { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/users/me$" } },
448
- { action: "http", object: { type: "any", value: "^/api/management/1.0/auth/verify$" } },
449
- { action: "http", object: { type: "PUT", value: "^/api/management/v1/useradm/2faverify$" } },
450
- { action: "http", object: { type: "POST", value: "^/api/management/v1/useradm/users/me/2fa/(enable|disable)$" } },
451
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/roles" } },
452
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/user/tenant" } }
453
- ]
454
- },
455
- {
456
- ...import_constants.defaultPermissionSets.ManageReleases,
457
- action: import_constants.uiPermissionsById.manage.title,
458
- object: permissionSetObjectTypes.releases,
459
- description: "Set of permissions which allows user to manage releases",
460
- permissions: [
461
- { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
462
- { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
463
- { action: "http", object: { type: "PUT", value: commonEndpoints.artifactDetails } },
464
- { action: "http", object: { type: "DELETE", value: commonEndpoints.artifactDetails } },
465
- { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
466
- ]
467
- },
468
- {
469
- ...import_constants.defaultPermissionSets.ReadUsers,
470
- action: import_constants.uiPermissionsById.read.title,
471
- object: permissionSetObjectTypes.userManagement,
472
- description: "Set of permissions which allows user to view other users",
473
- permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/" } }]
474
- },
475
- {
476
- ...import_constants.defaultPermissionSets.ManageUsers,
477
- action: import_constants.uiPermissionsById.manage.title,
478
- object: permissionSetObjectTypes.userManagement,
479
- description: "Set of permissions which allows user manage other user accounts",
480
- permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/" } }]
481
- },
482
- {
483
- ...import_constants.defaultPermissionSets.ReadTenants,
484
- action: import_constants.uiPermissionsById.read.title,
485
- object: permissionSetObjectTypes.tenantManagement,
486
- description: "Set of permissions which allows user to list other tenants and their config",
487
- permissions: [
488
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
489
- { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } }
490
- ]
491
- },
492
- {
493
- ...import_constants.defaultPermissionSets.ManageTenants,
494
- action: import_constants.uiPermissionsById.manage.title,
495
- object: permissionSetObjectTypes.tenantManagement,
496
- description: "Set of permissions which allows user to manage other tenants and their config",
497
- permissions: [
498
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
499
- { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } },
500
- { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9])/tenantadm/" } }
501
- ]
502
- },
503
- {
504
- ...import_constants.defaultPermissionSets.ReadAuditLogs,
505
- action: import_constants.uiPermissionsById.read.title,
506
- object: "System Audit Log",
507
- description: "Set of permissions which allows user to view system audit log",
508
- permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/auditlogs/logs" } }]
509
- },
510
- {
511
- ...import_constants.defaultPermissionSets.DeployToDevices,
512
- action: "Deploy",
513
- object: permissionSetObjectTypes.groups,
514
- description: "Set of permissions which allows user to deploy to devices",
515
- permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/(deployments|deviceconfig)/" } }],
516
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
517
- },
518
- {
519
- ...import_constants.defaultPermissionSets.ConfigureDevices,
520
- action: "Configure",
521
- object: permissionSetObjectTypes.groups,
522
- description: "Set of permissions which allows user to manage configuration of the devices",
523
- permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/" } }],
524
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
525
- },
526
- {
527
- ...import_constants.defaultPermissionSets.ConnectToDevices,
528
- action: "Connect",
529
- object: permissionSetObjectTypes.groups,
530
- description: "Set of permissions which allows user to use remote terminal and file transfer",
531
- permissions: [
532
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/connect$" } },
533
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/download\\?path=[^&]+$" } },
534
- { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/upload$" } }
535
- ],
536
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
537
- },
538
- {
539
- ...import_constants.defaultPermissionSets.SuperUser,
540
- action: "Any",
541
- object: permissionSetObjectTypes.any,
542
- description: "Set of permissions which allows user to do anything",
543
- permissions: [{ action: "any", object: { type: "any", value: "any" } }]
544
- },
545
- {
546
- ...import_constants.defaultPermissionSets.UploadArtifacts,
547
- action: "Upload",
548
- object: permissionSetObjectTypes.artifacts,
549
- description: "Set of permissions which allows user to upload artifacts",
550
- permissions: [
551
- { action: "http", object: { type: "POST", value: commonEndpoints.artifacts } },
552
- { action: "http", object: { type: "POST", value: "^/api/management/v1/deployments/artifacts/generate" } }
553
- ]
554
- },
555
- {
556
- ...import_constants.defaultPermissionSets.ReadDevices,
557
- action: import_constants.uiPermissionsById.read.title,
558
- object: permissionSetObjectTypes.groups,
559
- description: "Set of permissions which allows user to view devices",
560
- permissions: [
561
- { action: "http", object: { type: "POST", value: "^/api/management/v2/inventory/filters/search" } },
562
- { action: "http", object: { type: "POST", value: "^/api/management/v1/reporting/devices/search" } },
563
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/(deployments|devauth|inventory|deviceconfig|devicemonitor)/" } },
564
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+$" } }
565
- ],
566
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
567
- },
568
- {
569
- ...import_constants.defaultPermissionSets.ManageDevices,
570
- action: import_constants.uiPermissionsById.manage.title,
571
- object: permissionSetObjectTypes.groups,
572
- description: "Set of permissions which allows user to manage devices",
573
- permissions: [
574
- { action: "http", object: { type: "POST", value: commonEndpoints.deviceManagement } },
575
- { action: "http", object: { type: "PUT", value: commonEndpoints.deviceManagement } },
576
- { action: "http", object: { type: "DELETE", value: commonEndpoints.deviceManagement } }
577
- ],
578
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
579
- },
580
- {
581
- ...import_constants.defaultPermissionSets.ReadReleases,
582
- action: import_constants.uiPermissionsById.read.title,
583
- object: permissionSetObjectTypes.releases,
584
- description: "Set of permissions which allows user to view releases",
585
- permissions: [
586
- { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
587
- { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
588
- { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
589
- ]
590
- },
591
- {
592
- name: "almostAdmin",
593
- object: permissionSetObjectTypes.empty,
594
- description: "Set containing all the permissions.",
595
- permissions: [
596
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/auditlogs/.*" } },
597
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/.*" } },
598
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/config/.*" } },
599
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/.*" } },
600
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/releases/.*" } },
601
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/devauth/.*" } },
602
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/.*" } },
603
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/.*" } },
604
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/devices" } },
605
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/inventory/.*" } },
606
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/iot-manager/.*" } },
607
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/monitor/.*" } },
608
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/.*" } }
609
- ]
610
- }
611
- ];
612
- var rbacRoles = [
613
- {
614
- name: "dyn",
615
- description: "",
616
- permissions: [
617
- { action: "CREATE_DEPLOYMENT", object: { type: "DEVICE_GROUP", value: "dyn" } },
618
- { action: "VIEW_DEVICE", object: { type: "DEVICE_GROUP", value: "dyn" } }
619
- ]
620
- },
621
- { name: "asdasd", description: "123", permissions: [{ action: "http", object: { type: "any", value: "/api/management/v1/useradm/.*" } }] },
622
- {
623
- name: "141sasd",
624
- description: "1313adg",
625
- permission_sets_with_scope: [
626
- { ...import_constants.defaultPermissionSets.ReadDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
627
- { ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
628
- { ...import_constants.defaultPermissionSets.ManageUsers }
629
- ]
630
- },
631
- {
632
- name: "kljlkk",
633
- description: "lkl",
634
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } }]
635
- },
636
- {
637
- name: "yyyyy",
638
- description: "asd",
639
- permission_sets_with_scope: [
640
- { ...import_constants.defaultPermissionSets.ManageDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["dockerclient"] } },
641
- { ...import_constants.defaultPermissionSets.ManageReleases }
642
- ]
643
- },
644
- {
645
- name: "RBAC_ROLE_DEPLOYMENTS_MANAGER",
646
- description: "Intended for users responsible for managing deployments, this role can create and abort deployments",
647
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.DeployToDevices }]
648
- },
649
- {
650
- name: "RBAC_ROLE_REMOTE_TERMINAL",
651
- description: `Intended for tech support accounts, this role can access the devices' Remote Terminal.`,
652
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices }]
653
- },
654
- { name: "RBAC_ROLE_PERMIT_ALL", description: "", permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.SuperUser }] },
655
- {
656
- name: "RBAC_ROLE_OBSERVER",
657
- description: "Intended for team leaders or limited tech support accounts, this role can see all Devices, Artifacts and Deployment reports but not make any changes.",
658
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ReadReleases }, { ...import_constants.defaultPermissionSets.ReadDevices }]
659
- },
660
- {
661
- name: "RBAC_ROLE_CI",
662
- description: "Intended for automation accounts building software (e.g. CI/CD systems), this role can only manage Artifacts, including upload new Artifacts and delete Artifacts. It does not have access to Devices or Deployments.",
663
- permission_sets_with_scope: [
664
- { ...import_constants.defaultPermissionSets.ReadReleases },
665
- { ...import_constants.defaultPermissionSets.ManageReleases },
666
- { ...import_constants.defaultPermissionSets.UploadArtifacts }
667
- ]
668
- },
669
- {
670
- name: "almostAdmin",
671
- description: "almost admin rights",
672
- permissions: permissionSets.find((item) => item.name === "almostAdmin")?.permissions
673
- },
674
- {
675
- name: "almostAdminNew",
676
- description: "almost admin rights",
677
- permission_sets_with_scope: Object.values(import_constants.defaultPermissionSets)
678
- }
679
- ];
680
- var expectedParsedRoles = {
681
- "141sasd": {
682
- editable: true,
683
- isCustom: void 0,
684
- uiPermissions: {
685
- ...import_constants.emptyUiPermissions,
686
- groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] },
687
- userManagement: [import_constants.uiPermissionsById.manage.value]
688
- }
689
- },
690
- asdasd: {
691
- editable: false,
692
- isCustom: true,
693
- uiPermissions: { ...import_constants.emptyUiPermissions, userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] }
694
- },
695
- dyn: {
696
- editable: false,
697
- isCustom: true,
698
- uiPermissions: {
699
- ...import_constants.emptyUiPermissions,
700
- deployments: [import_constants.uiPermissionsById.deploy.value],
701
- groups: { dyn: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value] }
702
- }
703
- },
704
- kljlkk: {
705
- editable: true,
706
- isCustom: false,
707
- uiPermissions: { ...import_constants.emptyUiPermissions, groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] } }
708
- },
709
- yyyyy: {
710
- editable: true,
711
- isCustom: void 0,
712
- uiPermissions: {
713
- ...import_constants.emptyUiPermissions,
714
- groups: { dockerclient: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] },
715
- releases: { [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value] }
716
- }
717
- },
718
- almostAdmin: {
719
- editable: false,
720
- isCustom: true,
721
- uiPermissions: {
722
- ...import_constants.emptyUiPermissions,
723
- auditlog: [import_constants.uiPermissionsById.read.value],
724
- deployments: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.read.value],
725
- groups: {
726
- [import_constants.ALL_DEVICES]: [
727
- import_constants.uiPermissionsById.read.value,
728
- // we can't assign deployment permissions to devices here, since the old path based rbac controls don't allow the scoped permissions
729
- // uiPermissionsById.deploy.value,
730
- import_constants.uiPermissionsById.manage.value,
731
- import_constants.uiPermissionsById.connect.value,
732
- import_constants.uiPermissionsById.configure.value
733
- ]
734
- },
735
- releases: {
736
- [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.manage.value]
737
- },
738
- userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
739
- }
740
- },
741
- almostAdminNew: {
742
- editable: true,
743
- isCustom: void 0,
744
- uiPermissions: {
745
- ...import_constants.emptyUiPermissions,
746
- auditlog: [import_constants.uiPermissionsById.read.value],
747
- deployments: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.manage.value],
748
- groups: {
749
- [import_constants.ALL_DEVICES]: [
750
- import_constants.uiPermissionsById.read.value,
751
- import_constants.uiPermissionsById.manage.value,
752
- import_constants.uiPermissionsById.deploy.value,
753
- import_constants.uiPermissionsById.connect.value,
754
- import_constants.uiPermissionsById.configure.value
755
- ]
756
- },
757
- releases: {
758
- [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.read.value]
759
- },
760
- tenantManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value],
761
- userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
762
- }
763
- }
764
- };
765
- var defaultRolesById = {
766
- ...import_constants.rolesById,
767
- test: {
768
- ...import_constants.emptyRole,
769
- name: "test",
770
- description: "test description",
771
- editable: true,
772
- uiPermissions: {
773
- ...import_constants.emptyUiPermissions,
774
- groups: { testGroup: [import_constants.uiPermissionsById.read.value] },
775
- releases: { bar: [import_constants.uiPermissionsById.read.value] }
776
- }
777
- }
778
- };
779
- var receivedRoles = rbacRoles.reduce(
780
- (accu, role) => {
781
- const { name, description, ...roleRemainder } = role;
782
- if (name.startsWith("RBAC")) {
783
- accu[name] = {
784
- ...defaultRolesById[name],
785
- ...roleRemainder,
786
- editable: false,
787
- isCustom: false,
788
- description: defaultRolesById[name].description ? defaultRolesById[name].description : description
789
- };
790
- } else {
791
- const result = expectedParsedRoles[name] ?? {};
792
- accu[name] = {
793
- ...import_constants.emptyRole,
794
- ...role,
795
- ...result,
796
- name
797
- };
798
- }
799
- return accu;
800
- },
801
- { ...defaultRolesById }
802
- );
803
- var receivedPermissionSets = permissionSets.reduce((accu, set) => {
804
- const result = import_constants.defaultPermissionSets[set.name]?.result ?? {};
805
- accu[set.name] = {
806
- ...set,
807
- result: {
808
- ...import_constants.emptyUiPermissions,
809
- ...result
810
- }
811
- };
812
- return accu;
813
- }, {});
814
-
815
- // src/requestHandlers/deviceHandlers.ts
816
- var defaultDeviceId = "a1";
817
- var deviceAuthDevice = {
818
- id: defaultDeviceId,
819
- identity_data: { mac: defaultMacAddress },
820
- status: "accepted",
821
- decommissioning: false,
822
- created_ts: defaultCreationDate,
823
- updated_ts: "2019-01-01T09:25:00.000Z",
824
- auth_sets: [
825
- {
826
- id: "auth1",
827
- identity_data: { mac: defaultMacAddress },
828
- pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
829
- ts: defaultCreationDate,
830
- status: "accepted"
831
- }
832
- ]
833
- };
834
- var checkInTimeExact2 = "2019-01-01T10:25:00.000Z";
835
- var updatedTime = "2019-01-01T09:25:00.000Z";
836
- var inventoryDevice = {
837
- id: defaultDeviceId,
838
- attributes: [
839
- { name: "network_interfaces", value: ["eth0", "wlan0"], scope: "inventory" },
840
- { name: "kernel", value: "Linux version 4.19.75-v7l+", scope: "inventory" },
841
- { name: "artifact_name", value: "raspotifyInstaller", scope: "inventory" },
842
- { name: "ipv6_wlan0", value: "fe80::68d9:8453:3e9c:7c80/64", scope: "inventory" },
843
- { name: "mac_eth0", value: defaultMacAddress, scope: "inventory" },
844
- { name: "rootfs_type", value: "ext4", scope: "inventory" },
845
- { name: "mender_bootloader_integration", value: "unknown", scope: "inventory" },
846
- { name: "cpu_model", value: "ARMv7 Processor rev 3 (v7l)", scope: "inventory" },
847
- { name: "hostname", value: "raspberrypi", scope: "inventory" },
848
- { name: "mender_client_version", value: "2.1.0", scope: "inventory" },
849
- { name: "ipv4_wlan0", value: "192.168.10.141/24", scope: "inventory" },
850
- { name: "device_type", value: "raspberrypi4", scope: "inventory" },
851
- { name: "mem_total_kB", value: "1986024", scope: "inventory" },
852
- { name: "mac_wlan0", value: "dc:a6:32:12:ad:c0", scope: "inventory" },
853
- { name: "os", value: "Raspbian GNU/Linux 10 (buster)", scope: "inventory" },
854
- { name: "created_ts", value: defaultCreationDate, scope: "system" },
855
- { name: "updated_ts", value: updatedTime, scope: "system" },
856
- { name: "status", value: "accepted", scope: "identity" },
857
- { name: "mac", value: defaultMacAddress, scope: "identity" },
858
- { name: "group", value: "test", scope: "system" }
859
- ],
860
- check_in_time: checkInTimeExact2,
861
- updated_ts: updatedTime
862
- };
863
- var deviceAttributes = [
864
- { name: "status", scope: "identity", count: 5 },
865
- { name: "created_ts", scope: "system", count: 5 },
866
- { name: "updated_ts", scope: "system", count: 5 },
867
- { name: "mac", scope: "identity", count: 1 },
868
- { name: "artifact_name", scope: "inventory", count: 1 },
869
- { name: "cpu_model", scope: "inventory", count: 1 },
870
- { name: "device_type", scope: "inventory", count: 1 },
871
- { name: "hostname", scope: "inventory", count: 1 },
872
- { name: "ipv4_wlan0", scope: "inventory", count: 1 },
873
- { name: "ipv6_wlan0", scope: "inventory", count: 1 },
874
- { name: "kernel", scope: "inventory", count: 1 },
875
- { name: "mac_eth0", scope: "inventory", count: 1 },
876
- { name: "mac_wlan0", scope: "inventory", count: 1 },
877
- { name: "mem_total_kB", scope: "inventory", count: 1 },
878
- { name: "mender_bootloader_integration", scope: "inventory", count: 1 },
879
- { name: "mender_client_version", scope: "inventory", count: 1 },
880
- { name: "network_interfaces", scope: "inventory", count: 1 },
881
- { name: "os", scope: "inventory", count: 1 },
882
- { name: "rootfs_type", scope: "inventory", count: 1 },
883
- { name: "group", scope: "system", count: 1 }
884
- ];
885
- var searchHandler = async ({ request }) => {
886
- const { page, per_page, filters } = await request.json();
887
- if ([page, per_page, filters].some((item) => !item)) {
888
- return new import_msw.HttpResponse(null, { status: 509 });
889
- }
890
- const filter = filters.find((filter2) => filter2.scope === "identity" && filter2.attribute === "status" && Object.values(import_constants2.DEVICE_STATES).includes(filter2.value));
891
- const status = filter?.value || "";
892
- if (!status || filters.length > 1) {
893
- if (filters.find((filter2) => filter2.attribute === "group" && filter2.value.includes(Object.keys(mockApiResponses.devices.groups.byId)[0]))) {
894
- return new import_msw.HttpResponse(JSON.stringify([inventoryDevice, { ...inventoryDevice, id: "b1" }]), {
895
- headers: { [import_constants2.headerNames.total]: 2 }
896
- });
897
- }
898
- if (filters.find((filter2) => filter2.scope === "monitor" && ["failed_last_update", "alerts", "auth_request"].includes(filter2.attribute))) {
899
- return new import_msw.HttpResponse(JSON.stringify([inventoryDevice]), { headers: { [import_constants2.headerNames.total]: 4 } });
900
- }
901
- return new import_msw.HttpResponse(JSON.stringify([]), { headers: { [import_constants2.headerNames.total]: 0 } });
902
- }
903
- let deviceList = Array.from({ length: mockApiResponses.devices.byStatus[status].total }, (_, index) => ({
904
- ...inventoryDevice,
905
- attributes: [...inventoryDevice.attributes, { name: "test-count", value: index, scope: "system" }],
906
- id: `${String.fromCharCode("a".charCodeAt(0) + index)}1`
907
- }));
908
- deviceList = deviceList.slice((page - 1) * per_page, page * per_page);
909
- return new import_msw.HttpResponse(JSON.stringify(deviceList), { headers: { [import_constants2.headerNames.total]: mockApiResponses.devices.byStatus[status].total } });
910
- };
911
- var deviceHandlers = [
912
- import_msw.http.delete(`${import_constants2.deviceAuthV2}/devices/:deviceId/auth/:authId`, ({ params: { authId, deviceId } }) => {
913
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId)) {
914
- return new import_msw.HttpResponse(null, { status: 200 });
915
- }
916
- return new import_msw.HttpResponse(null, { status: 501 });
917
- }),
918
- import_msw.http.delete(`${import_constants2.deviceAuthV2}/devices/:deviceId`, ({ params: { deviceId } }) => {
919
- if (mockApiResponses.devices.byId[deviceId]) {
920
- return new import_msw.HttpResponse(null, { status: 200 });
921
- }
922
- return new import_msw.HttpResponse(null, { status: 502 });
923
- }),
924
- import_msw.http.delete(`${import_constants2.inventoryApiUrl}/groups/:group`, ({ params: { group } }) => {
925
- if (mockApiResponses.devices.groups.byId[group]) {
926
- return new import_msw.HttpResponse(null, { status: 200 });
927
- }
928
- return new import_msw.HttpResponse(null, { status: 515 });
929
- }),
930
- import_msw.http.delete(`${import_constants2.inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
931
- const deviceIds = await request.json();
932
- if (mockApiResponses.devices.groups.byId[group] && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
933
- return new import_msw.HttpResponse(null, { status: 200 });
934
- }
935
- return new import_msw.HttpResponse(null, { status: 503 });
936
- }),
937
- import_msw.http.delete(`${import_constants2.inventoryApiUrlV2}/filters/:filterId`, ({ params: { filterId } }) => {
938
- if (Object.values(mockApiResponses.devices.groups.byId).find((group) => group.id === filterId)) {
939
- return new import_msw.HttpResponse(null, { status: 200 });
940
- }
941
- return new import_msw.HttpResponse(null, { status: 504 });
942
- }),
943
- import_msw.http.get(`${import_constants2.deviceAuthV2}/devices`, ({ request }) => {
944
- const { searchParams } = new URL(request.url);
945
- const deviceIds = searchParams.getAll("id");
946
- if (deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
947
- return import_msw.HttpResponse.json(deviceIds.map((id) => ({ ...deviceAuthDevice, id })));
948
- }
949
- return new import_msw.HttpResponse(null, { status: 505 });
950
- }),
951
- import_msw.http.get(`${import_constants2.deviceAuthV2}/limits/devices`, () => import_msw.HttpResponse.json(mockApiResponses.devices.limits)),
952
- import_msw.http.get(`${import_constants2.inventoryApiUrl}/devices/:deviceId`, ({ params: { deviceId } }) => {
953
- if (mockApiResponses.devices.byId[deviceId]) {
954
- return import_msw.HttpResponse.json(inventoryDevice);
955
- }
956
- return new import_msw.HttpResponse(null, { status: 506 });
957
- }),
958
- import_msw.http.put(`${import_constants2.inventoryApiUrl}/devices/:deviceId/tags`, async ({ params: { deviceId }, request }) => {
959
- const tags = await request.json();
960
- if (!mockApiResponses.devices.byId[deviceId] && !Array.isArray(tags) && !tags.every((item) => item.name && item.value)) {
961
- return new import_msw.HttpResponse(null, { status: 506 });
962
- }
963
- return import_msw.HttpResponse.json(tags);
964
- }),
965
- import_msw.http.get(`${import_constants2.inventoryApiUrl}/groups`, () => {
966
- const groups = Object.entries(mockApiResponses.devices.groups.byId).reduce((accu, [groupName, group]) => {
967
- if (!group.id) {
968
- accu.push(groupName);
969
- }
970
- return accu;
971
- }, []);
972
- return import_msw.HttpResponse.json(groups);
973
- }),
974
- import_msw.http.get(`${import_constants2.inventoryApiUrlV2}/filters/attributes`, () => import_msw.HttpResponse.json(deviceAttributes)),
975
- import_msw.http.get(`${import_constants2.reportingApiUrl}/devices/attributes`, () => import_msw.HttpResponse.json({ attributes: deviceAttributes, count: deviceAttributes.length, limit: 100 })),
976
- import_msw.http.get(`${import_constants2.reportingApiUrl}/devices/search/attributes`, () => import_msw.HttpResponse.json(deviceAttributes)),
977
- import_msw.http.post(
978
- `${import_constants2.reportingApiUrl}/devices/aggregate`,
979
- () => import_msw.HttpResponse.json([
980
- {
981
- name: "*",
982
- items: [
983
- { key: "test", count: 6 },
984
- { key: "original", count: 1 }
985
- ],
986
- other_count: 42
987
- }
988
- ])
989
- ),
990
- import_msw.http.get(
991
- `${import_constants2.inventoryApiUrlV2}/filters`,
992
- () => import_msw.HttpResponse.json([
993
- {
994
- id: "filter1",
995
- name: "testGroupDynamic",
996
- terms: [
997
- { scope: "identity", attribute: "id", type: "$in", value: [defaultDeviceId] },
998
- { scope: "identity", attribute: "mac", type: "$exists", value: false },
999
- { scope: "identity", attribute: "kernel", type: "$exists", value: true }
1000
- ]
1001
- }
1002
- ])
1003
- ),
1004
- import_msw.http.patch(`${import_constants2.inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
1005
- const deviceIds = await request.json();
1006
- if (!!group && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
1007
- return new import_msw.HttpResponse(null, { status: 200 });
1008
- }
1009
- return new import_msw.HttpResponse(null, { status: 508 });
1010
- }),
1011
- import_msw.http.post(`${import_constants2.deviceAuthV2}/devices`, async ({ request }) => {
1012
- const authset = await request.json();
1013
- if (Object.values(mockApiResponses.devices.byId).some(
1014
- (device) => device.auth_sets.some((deviceAuthSet) => deviceAuthSet.pubkey == authset.pubkey || deviceAuthSet.identity_data == authset.identity_data)
1015
- )) {
1016
- return new import_msw.HttpResponse(null, { status: 409 });
1017
- }
1018
- return new import_msw.HttpResponse(null, { status: 200 });
1019
- }),
1020
- import_msw.http.post(`${import_constants2.inventoryApiUrlV2}/filters/search`, searchHandler),
1021
- import_msw.http.post(`${import_constants2.reportingApiUrl}/filters/search`, searchHandler),
1022
- import_msw.http.post(`${import_constants2.inventoryApiUrlV2}/filters`, async ({ request }) => {
1023
- const { name, terms } = await request.json();
1024
- if ([name, terms].some((item) => !item) || mockApiResponses.devices.groups[name] || !terms.every((term) => import_constants2.DEVICE_FILTERING_OPTIONS[term.type] && ["identity", "inventory", "system"].includes(term.scope) && !!term.value && !!term.attribute)) {
1025
- return new import_msw.HttpResponse(null, { status: 510 });
1026
- }
1027
- return new import_msw.HttpResponse(JSON.stringify({}), { headers: { location: "find/me/here/createdFilterId" } });
1028
- }),
1029
- import_msw.http.get(
1030
- `${import_constants2.inventoryApiUrlV2}/statistics`,
1031
- async () => import_msw.HttpResponse.json({
1032
- devices_by_status: {
1033
- accepted: { standard: mockApiResponses.devices.byStatus.accepted.total, micro: 0, system: 0 },
1034
- pending: { standard: mockApiResponses.devices.byStatus.pending.total, micro: 0, system: 0 }
1035
- }
1036
- })
1037
- ),
1038
- import_msw.http.put(`${import_constants2.deviceAuthV2}/devices/:deviceId/auth/:authId/status`, async ({ params: { authId, deviceId }, request }) => {
1039
- const { status } = await request.json();
1040
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId) && import_constants2.DEVICE_STATES[status]) {
1041
- return new import_msw.HttpResponse(null, { status: 200 });
1042
- }
1043
- return new import_msw.HttpResponse(null, { status: 511 });
1044
- }),
1045
- import_msw.http.get(`${import_constants2.deviceConfig}/:deviceId`, ({ params: { deviceId } }) => {
1046
- if (deviceId === "testId") {
1047
- return new import_msw.HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
1048
- }
1049
- if (mockApiResponses.devices.byId[deviceId]) {
1050
- return import_msw.HttpResponse.json({
1051
- configured: { test: true, something: "else", aNumber: 42 },
1052
- deployment_id: "config1",
1053
- reported: { test: true, something: "else", aNumber: 42 },
1054
- updated_ts: updatedTime,
1055
- reported_ts: "2019-01-01T09:25:01.000Z"
1056
- });
1057
- }
1058
- return new import_msw.HttpResponse(null, { status: 512 });
1059
- }),
1060
- import_msw.http.put(`${import_constants2.deviceConfig}/:deviceId`, async ({ params: { deviceId }, request }) => {
1061
- const body = await request.text();
1062
- if (body.includes("evilValue")) {
1063
- return new import_msw.HttpResponse(null, { status: 418 });
1064
- }
1065
- return new import_msw.HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 201 : 513 });
1066
- }),
1067
- import_msw.http.post(`${import_constants2.deviceConfig}/:deviceId/deploy`, ({ params: { deviceId } }) => {
1068
- if (mockApiResponses.devices.byId[deviceId]) {
1069
- return import_msw.HttpResponse.json({ deployment_id: "config1" });
1070
- }
1071
- return new import_msw.HttpResponse(null, { status: 514 });
1072
- }),
1073
- import_msw.http.get(`${import_constants2.deviceConnect}/devices/:deviceId`, ({ params: { deviceId } }) => {
1074
- if (deviceId === "testId") {
1075
- return new import_msw.HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
1076
- }
1077
- if (mockApiResponses.devices.byId[deviceId]) {
1078
- return import_msw.HttpResponse.json({ status: "connected", updated_ts: mockApiResponses.devices.byId[deviceId].updated_ts });
1079
- }
1080
- return new import_msw.HttpResponse(null, { status: 512 });
1081
- }),
1082
- import_msw.http.post(`${import_constants2.deviceConnect}/devices/:deviceId/:action`, ({ params: { deviceId, action } }) => {
1083
- if (["check-update", "send-inventory"].includes(action) && mockApiResponses.devices.byId[deviceId]) {
1084
- return new import_msw.HttpResponse(null, { status: 202 });
1085
- }
1086
- return new import_msw.HttpResponse(null, { status: 518 });
1087
- }),
1088
- import_msw.http.get(`${import_constants2.iotManagerBaseURL}/devices/:deviceId/state`, ({ params: { deviceId } }) => {
1089
- if (mockApiResponses.devices.byId[deviceId]) {
1090
- return import_msw.HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
1091
- }
1092
- return new import_msw.HttpResponse(null, { status: 515 });
1093
- }),
1094
- import_msw.http.put(`${import_constants2.iotManagerBaseURL}/devices/:deviceId/state/:integrationId`, async ({ params: { deviceId }, request }) => {
1095
- const body = await request.json();
1096
- if (mockApiResponses.devices.byId[deviceId] && body) {
1097
- return import_msw.HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
1098
- }
1099
- return new import_msw.HttpResponse(null, { status: 516 });
1100
- }),
1101
- import_msw.http.put(
1102
- `${import_constants2.deviceConnect}/devices/:deviceId/upload`,
1103
- ({ params: { deviceId } }) => new import_msw.HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 200 : 517 })
1104
- ),
1105
- import_msw.http.get(`${import_constants2.deviceAuthV2}/license`, () => import_msw.HttpResponse.text("test,report"))
1106
- ];
1107
- // Annotate the CommonJS export names for ESM import in node:
1108
- 0 && (module.exports = {
1109
- defaultDeviceId,
1110
- deviceHandlers,
1111
- inventoryDevice
1112
- });
1113
- //# sourceMappingURL=deviceHandlers.cjs.map