@northern.tech/testing 0.8.1 → 0.8.3

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