@northern.tech/testing 0.8.3 → 0.8.4

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