@northern.tech/testing 0.1.0

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 (84) hide show
  1. package/dist/baseTestConfig.json +24 -0
  2. package/dist/chunk-3KEPLFEG.js +64 -0
  3. package/dist/chunk-3KEPLFEG.js.map +1 -0
  4. package/dist/chunk-4ZCNCVNV.js +309 -0
  5. package/dist/chunk-4ZCNCVNV.js.map +1 -0
  6. package/dist/chunk-5MREOBVU.js +833 -0
  7. package/dist/chunk-5MREOBVU.js.map +1 -0
  8. package/dist/chunk-A7LWVKMZ.js +209 -0
  9. package/dist/chunk-A7LWVKMZ.js.map +1 -0
  10. package/dist/chunk-ERCKCRE4.js +179 -0
  11. package/dist/chunk-ERCKCRE4.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-MH5OGHNU.js +29 -0
  15. package/dist/chunk-MH5OGHNU.js.map +1 -0
  16. package/dist/chunk-QSR5PAZ3.js +207 -0
  17. package/dist/chunk-QSR5PAZ3.js.map +1 -0
  18. package/dist/mockData.cjs +866 -0
  19. package/dist/mockData.cjs.map +1 -0
  20. package/dist/mockData.d.cts +558 -0
  21. package/dist/mockData.d.ts +558 -0
  22. package/dist/mockData.js +45 -0
  23. package/dist/mockData.js.map +1 -0
  24. package/dist/requestHandlers/deploymentHandlers.cjs +955 -0
  25. package/dist/requestHandlers/deploymentHandlers.cjs.map +1 -0
  26. package/dist/requestHandlers/deploymentHandlers.d.cts +5 -0
  27. package/dist/requestHandlers/deploymentHandlers.d.ts +5 -0
  28. package/dist/requestHandlers/deploymentHandlers.js +8 -0
  29. package/dist/requestHandlers/deploymentHandlers.js.map +1 -0
  30. package/dist/requestHandlers/deviceHandlers.cjs +1044 -0
  31. package/dist/requestHandlers/deviceHandlers.cjs.map +1 -0
  32. package/dist/requestHandlers/deviceHandlers.d.cts +20 -0
  33. package/dist/requestHandlers/deviceHandlers.d.ts +20 -0
  34. package/dist/requestHandlers/deviceHandlers.js +12 -0
  35. package/dist/requestHandlers/deviceHandlers.js.map +1 -0
  36. package/dist/requestHandlers/monitorHandlers.cjs +775 -0
  37. package/dist/requestHandlers/monitorHandlers.cjs.map +1 -0
  38. package/dist/requestHandlers/monitorHandlers.d.cts +5 -0
  39. package/dist/requestHandlers/monitorHandlers.d.ts +5 -0
  40. package/dist/requestHandlers/monitorHandlers.js +8 -0
  41. package/dist/requestHandlers/monitorHandlers.js.map +1 -0
  42. package/dist/requestHandlers/organizationHandlers.cjs +968 -0
  43. package/dist/requestHandlers/organizationHandlers.cjs.map +1 -0
  44. package/dist/requestHandlers/organizationHandlers.d.cts +5 -0
  45. package/dist/requestHandlers/organizationHandlers.d.ts +5 -0
  46. package/dist/requestHandlers/organizationHandlers.js +8 -0
  47. package/dist/requestHandlers/organizationHandlers.js.map +1 -0
  48. package/dist/requestHandlers/releaseHandlers.cjs +809 -0
  49. package/dist/requestHandlers/releaseHandlers.cjs.map +1 -0
  50. package/dist/requestHandlers/releaseHandlers.d.cts +5 -0
  51. package/dist/requestHandlers/releaseHandlers.d.ts +5 -0
  52. package/dist/requestHandlers/releaseHandlers.js +8 -0
  53. package/dist/requestHandlers/releaseHandlers.js.map +1 -0
  54. package/dist/requestHandlers/requestHandlers.cjs +1712 -0
  55. package/dist/requestHandlers/requestHandlers.cjs.map +1 -0
  56. package/dist/requestHandlers/requestHandlers.d.cts +5 -0
  57. package/dist/requestHandlers/requestHandlers.d.ts +5 -0
  58. package/dist/requestHandlers/requestHandlers.js +35 -0
  59. package/dist/requestHandlers/requestHandlers.js.map +1 -0
  60. package/dist/requestHandlers/userHandlers.cjs +925 -0
  61. package/dist/requestHandlers/userHandlers.cjs.map +1 -0
  62. package/dist/requestHandlers/userHandlers.d.cts +5 -0
  63. package/dist/requestHandlers/userHandlers.d.ts +5 -0
  64. package/dist/requestHandlers/userHandlers.js +8 -0
  65. package/dist/requestHandlers/userHandlers.js.map +1 -0
  66. package/dist/setupTests.cjs +905 -0
  67. package/dist/setupTests.cjs.map +1 -0
  68. package/dist/setupTests.d.cts +75 -0
  69. package/dist/setupTests.d.ts +75 -0
  70. package/dist/setupTests.js +119 -0
  71. package/dist/setupTests.js.map +1 -0
  72. package/dist/theme/light.cjs +41 -0
  73. package/dist/theme/light.cjs.map +1 -0
  74. package/dist/theme/light.d.cts +12 -0
  75. package/dist/theme/light.d.ts +12 -0
  76. package/dist/theme/light.js +7 -0
  77. package/dist/theme/light.js.map +1 -0
  78. package/dist/utils.cjs +41 -0
  79. package/dist/utils.cjs.map +1 -0
  80. package/dist/utils.d.cts +3 -0
  81. package/dist/utils.d.ts +3 -0
  82. package/dist/utils.js +16 -0
  83. package/dist/utils.js.map +1 -0
  84. package/package.json +55 -0
@@ -0,0 +1,809 @@
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/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
+ limit: 500,
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
+ intentId: "testIntent",
242
+ auditlog: {
243
+ events: [
244
+ {
245
+ actor: {
246
+ id: "string",
247
+ type: "user",
248
+ email: "string@example.com"
249
+ },
250
+ time: "2019-01-01T12:10:22.667Z",
251
+ action: "create",
252
+ object: {
253
+ id: "string",
254
+ type: "user",
255
+ user: {
256
+ email: "user@acme.com"
257
+ }
258
+ },
259
+ change: "change1"
260
+ },
261
+ {
262
+ actor: {
263
+ id: "string",
264
+ type: "user",
265
+ email: "string",
266
+ identity_data: "string"
267
+ },
268
+ time: "2019-01-01T12:16:22.667Z",
269
+ action: "create",
270
+ object: {
271
+ id: "string",
272
+ type: "deployment",
273
+ deployment: {
274
+ name: "production",
275
+ artifact_name: "Application 0.0.1"
276
+ }
277
+ },
278
+ change: "change2"
279
+ },
280
+ {
281
+ actor: {
282
+ id: "string",
283
+ type: "user",
284
+ email: "string@example.com"
285
+ },
286
+ time: "2019-01-01T12:10:22.669Z",
287
+ action: "open_terminal",
288
+ meta: {
289
+ session_id: ["abd313a8-ee88-48ab-9c99-fbcd80048e6e"]
290
+ },
291
+ object: {
292
+ id: "a1",
293
+ type: "device"
294
+ },
295
+ change: "change3"
296
+ }
297
+ ]
298
+ }
299
+ },
300
+ releases: {
301
+ byId: {
302
+ r1: {
303
+ name: "r1",
304
+ artifacts: [
305
+ {
306
+ id: "art1",
307
+ description: "test description",
308
+ device_types_compatible: [deviceTypes.qemu],
309
+ modified: "2020-09-10T12:16:22.667Z",
310
+ updates: [{ type_info: "testtype" }],
311
+ artifact_depends: {
312
+ device_type: [deviceTypes.qemu]
313
+ },
314
+ artifact_provides: {
315
+ artifact_name: "myapp",
316
+ "data-partition.myapp.version": "v2020.10",
317
+ list_of_fancy: [deviceTypes.qemu, "x172"]
318
+ },
319
+ clears_artifact_provides: ["data-partition.myapp.*"]
320
+ }
321
+ ],
322
+ device_types_compatible: [deviceTypes.qemu],
323
+ modified: "2020-09-10T12:16:22.667Z",
324
+ metaData: {}
325
+ }
326
+ }
327
+ },
328
+ users: {
329
+ byId: {
330
+ a1: defaultUser,
331
+ [userId]: { ...defaultUser, id: userId, email: "a2@b.com", created_ts: "2019-01-01T12:30:00.000Z" }
332
+ },
333
+ rolesById: {
334
+ admin: {
335
+ name: "admin",
336
+ description: "Administrator role",
337
+ permissions: []
338
+ },
339
+ test: { name: "test", description: "test description", permissions: [] }
340
+ },
341
+ globalSettings: {
342
+ "2fa": "enabled",
343
+ id_attribute: void 0,
344
+ previousFilters: []
345
+ },
346
+ userSettings: {
347
+ "2fa": "disabled",
348
+ columnSelection: [],
349
+ onboarding: { something: "here" },
350
+ tooltips: {},
351
+ previousFilters: []
352
+ }
353
+ }
354
+ };
355
+ var releasesList = Array.from({ length: 5e3 }, (x, i) => ({
356
+ artifacts: [
357
+ {
358
+ id: "art1",
359
+ description: "test description",
360
+ device_types_compatible: [deviceTypes.qemu],
361
+ modified: "2020-09-10T12:16:22.667Z",
362
+ updates: [{ type_info: "testtype" }],
363
+ artifact_depends: {
364
+ device_type: [deviceTypes.qemu]
365
+ },
366
+ artifact_provides: {
367
+ artifact_name: "myapp",
368
+ "data-partition.myapp.version": "v2020.10",
369
+ list_of_fancy: [deviceTypes.qemu, "x172"]
370
+ },
371
+ clears_artifact_provides: ["data-partition.myapp.*"]
372
+ }
373
+ ],
374
+ device_types_compatible: [deviceTypes.qemu],
375
+ metaData: {},
376
+ name: `release-${i + 1}`,
377
+ modified: i
378
+ }));
379
+ var permissionSets = [
380
+ {
381
+ ...import_constants.defaultPermissionSets.Basic,
382
+ object: permissionSetObjectTypes.empty,
383
+ description: "Set containing basic permissions.",
384
+ permissions: [
385
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/settings$" } },
386
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/users/me$" } },
387
+ { action: "http", object: { type: "any", value: "^/api/management/1.0/auth/verify$" } },
388
+ { action: "http", object: { type: "PUT", value: "^/api/management/v1/useradm/2faverify$" } },
389
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/useradm/users/me/2fa/(enable|disable)$" } },
390
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/roles" } },
391
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/user/tenant" } }
392
+ ]
393
+ },
394
+ {
395
+ ...import_constants.defaultPermissionSets.ManageReleases,
396
+ action: import_constants.uiPermissionsById.manage.title,
397
+ object: permissionSetObjectTypes.releases,
398
+ description: "Set of permissions which allows user to manage releases",
399
+ permissions: [
400
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
401
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
402
+ { action: "http", object: { type: "PUT", value: commonEndpoints.artifactDetails } },
403
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.artifactDetails } },
404
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
405
+ ]
406
+ },
407
+ {
408
+ ...import_constants.defaultPermissionSets.ReadUsers,
409
+ action: import_constants.uiPermissionsById.read.title,
410
+ object: permissionSetObjectTypes.userManagement,
411
+ description: "Set of permissions which allows user to view other users",
412
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/" } }]
413
+ },
414
+ {
415
+ ...import_constants.defaultPermissionSets.ManageUsers,
416
+ action: import_constants.uiPermissionsById.manage.title,
417
+ object: permissionSetObjectTypes.userManagement,
418
+ description: "Set of permissions which allows user manage other user accounts",
419
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/" } }]
420
+ },
421
+ {
422
+ ...import_constants.defaultPermissionSets.ReadTenants,
423
+ action: import_constants.uiPermissionsById.read.title,
424
+ object: permissionSetObjectTypes.tenantManagement,
425
+ description: "Set of permissions which allows user to list other tenants and their config",
426
+ permissions: [
427
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
428
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } }
429
+ ]
430
+ },
431
+ {
432
+ ...import_constants.defaultPermissionSets.ManageTenants,
433
+ action: import_constants.uiPermissionsById.manage.title,
434
+ object: permissionSetObjectTypes.tenantManagement,
435
+ description: "Set of permissions which allows user to manage other tenants and their config",
436
+ permissions: [
437
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
438
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } },
439
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9])/tenantadm/" } }
440
+ ]
441
+ },
442
+ {
443
+ ...import_constants.defaultPermissionSets.ReadAuditLogs,
444
+ action: import_constants.uiPermissionsById.read.title,
445
+ object: "System Audit Log",
446
+ description: "Set of permissions which allows user to view system audit log",
447
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/auditlogs/logs" } }]
448
+ },
449
+ {
450
+ ...import_constants.defaultPermissionSets.DeployToDevices,
451
+ action: "Deploy",
452
+ object: permissionSetObjectTypes.groups,
453
+ description: "Set of permissions which allows user to deploy to devices",
454
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/(deployments|deviceconfig)/" } }],
455
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
456
+ },
457
+ {
458
+ ...import_constants.defaultPermissionSets.ConfigureDevices,
459
+ action: "Configure",
460
+ object: permissionSetObjectTypes.groups,
461
+ description: "Set of permissions which allows user to manage configuration of the devices",
462
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/" } }],
463
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
464
+ },
465
+ {
466
+ ...import_constants.defaultPermissionSets.ConnectToDevices,
467
+ action: "Connect",
468
+ object: permissionSetObjectTypes.groups,
469
+ description: "Set of permissions which allows user to use remote terminal and file transfer",
470
+ permissions: [
471
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/connect$" } },
472
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/download\\?path=[^&]+$" } },
473
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/upload$" } }
474
+ ],
475
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
476
+ },
477
+ {
478
+ ...import_constants.defaultPermissionSets.SuperUser,
479
+ action: "Any",
480
+ object: permissionSetObjectTypes.any,
481
+ description: "Set of permissions which allows user to do anything",
482
+ permissions: [{ action: "any", object: { type: "any", value: "any" } }]
483
+ },
484
+ {
485
+ ...import_constants.defaultPermissionSets.UploadArtifacts,
486
+ action: "Upload",
487
+ object: permissionSetObjectTypes.artifacts,
488
+ description: "Set of permissions which allows user to upload artifacts",
489
+ permissions: [
490
+ { action: "http", object: { type: "POST", value: commonEndpoints.artifacts } },
491
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/deployments/artifacts/generate" } }
492
+ ]
493
+ },
494
+ {
495
+ ...import_constants.defaultPermissionSets.ReadDevices,
496
+ action: import_constants.uiPermissionsById.read.title,
497
+ object: permissionSetObjectTypes.groups,
498
+ description: "Set of permissions which allows user to view devices",
499
+ permissions: [
500
+ { action: "http", object: { type: "POST", value: "^/api/management/v2/inventory/filters/search" } },
501
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/reporting/devices/search" } },
502
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/(deployments|devauth|inventory|deviceconfig|devicemonitor)/" } },
503
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+$" } }
504
+ ],
505
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
506
+ },
507
+ {
508
+ ...import_constants.defaultPermissionSets.ManageDevices,
509
+ action: import_constants.uiPermissionsById.manage.title,
510
+ object: permissionSetObjectTypes.groups,
511
+ description: "Set of permissions which allows user to manage devices",
512
+ permissions: [
513
+ { action: "http", object: { type: "POST", value: commonEndpoints.deviceManagement } },
514
+ { action: "http", object: { type: "PUT", value: commonEndpoints.deviceManagement } },
515
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.deviceManagement } }
516
+ ],
517
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
518
+ },
519
+ {
520
+ ...import_constants.defaultPermissionSets.ReadReleases,
521
+ action: import_constants.uiPermissionsById.read.title,
522
+ object: permissionSetObjectTypes.releases,
523
+ description: "Set of permissions which allows user to view releases",
524
+ permissions: [
525
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
526
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
527
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
528
+ ]
529
+ },
530
+ {
531
+ name: "almostAdmin",
532
+ object: permissionSetObjectTypes.empty,
533
+ description: "Set containing all the permissions.",
534
+ permissions: [
535
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/auditlogs/.*" } },
536
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/.*" } },
537
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/config/.*" } },
538
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/.*" } },
539
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/releases/.*" } },
540
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/devauth/.*" } },
541
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/.*" } },
542
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/.*" } },
543
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/devices" } },
544
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/inventory/.*" } },
545
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/iot-manager/.*" } },
546
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/monitor/.*" } },
547
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/.*" } }
548
+ ]
549
+ }
550
+ ];
551
+ var rbacRoles = [
552
+ {
553
+ name: "dyn",
554
+ description: "",
555
+ permissions: [
556
+ { action: "CREATE_DEPLOYMENT", object: { type: "DEVICE_GROUP", value: "dyn" } },
557
+ { action: "VIEW_DEVICE", object: { type: "DEVICE_GROUP", value: "dyn" } }
558
+ ]
559
+ },
560
+ { name: "asdasd", description: "123", permissions: [{ action: "http", object: { type: "any", value: "/api/management/v1/useradm/.*" } }] },
561
+ {
562
+ name: "141sasd",
563
+ description: "1313adg",
564
+ permission_sets_with_scope: [
565
+ { ...import_constants.defaultPermissionSets.ReadDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
566
+ { ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
567
+ { ...import_constants.defaultPermissionSets.ManageUsers }
568
+ ]
569
+ },
570
+ {
571
+ name: "kljlkk",
572
+ description: "lkl",
573
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } }]
574
+ },
575
+ {
576
+ name: "yyyyy",
577
+ description: "asd",
578
+ permission_sets_with_scope: [
579
+ { ...import_constants.defaultPermissionSets.ManageDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["dockerclient"] } },
580
+ { ...import_constants.defaultPermissionSets.ManageReleases }
581
+ ]
582
+ },
583
+ {
584
+ name: "RBAC_ROLE_DEPLOYMENTS_MANAGER",
585
+ description: "Intended for users responsible for managing deployments, this role can create and abort deployments",
586
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.DeployToDevices }]
587
+ },
588
+ {
589
+ name: "RBAC_ROLE_REMOTE_TERMINAL",
590
+ description: `Intended for tech support accounts, this role can access the devices' Remote Terminal.`,
591
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices }]
592
+ },
593
+ { name: "RBAC_ROLE_PERMIT_ALL", description: "", permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.SuperUser }] },
594
+ {
595
+ name: "RBAC_ROLE_OBSERVER",
596
+ 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.",
597
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ReadReleases }, { ...import_constants.defaultPermissionSets.ReadDevices }]
598
+ },
599
+ {
600
+ name: "RBAC_ROLE_CI",
601
+ 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.",
602
+ permission_sets_with_scope: [
603
+ { ...import_constants.defaultPermissionSets.ReadReleases },
604
+ { ...import_constants.defaultPermissionSets.ManageReleases },
605
+ { ...import_constants.defaultPermissionSets.UploadArtifacts }
606
+ ]
607
+ },
608
+ {
609
+ name: "almostAdmin",
610
+ description: "almost admin rights",
611
+ permissions: permissionSets.find((item) => item.name === "almostAdmin")?.permissions
612
+ },
613
+ {
614
+ name: "almostAdminNew",
615
+ description: "almost admin rights",
616
+ permission_sets_with_scope: Object.values(import_constants.defaultPermissionSets)
617
+ }
618
+ ];
619
+ var expectedParsedRoles = {
620
+ "141sasd": {
621
+ editable: true,
622
+ isCustom: void 0,
623
+ uiPermissions: {
624
+ ...import_constants.emptyUiPermissions,
625
+ groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] },
626
+ userManagement: [import_constants.uiPermissionsById.manage.value]
627
+ }
628
+ },
629
+ asdasd: {
630
+ editable: false,
631
+ isCustom: true,
632
+ uiPermissions: { ...import_constants.emptyUiPermissions, userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] }
633
+ },
634
+ dyn: {
635
+ editable: false,
636
+ isCustom: true,
637
+ uiPermissions: {
638
+ ...import_constants.emptyUiPermissions,
639
+ deployments: [import_constants.uiPermissionsById.deploy.value],
640
+ groups: { dyn: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value] }
641
+ }
642
+ },
643
+ kljlkk: {
644
+ editable: true,
645
+ isCustom: false,
646
+ uiPermissions: { ...import_constants.emptyUiPermissions, groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] } }
647
+ },
648
+ yyyyy: {
649
+ editable: true,
650
+ isCustom: void 0,
651
+ uiPermissions: {
652
+ ...import_constants.emptyUiPermissions,
653
+ groups: { dockerclient: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] },
654
+ releases: { [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value] }
655
+ }
656
+ },
657
+ almostAdmin: {
658
+ editable: false,
659
+ isCustom: true,
660
+ uiPermissions: {
661
+ ...import_constants.emptyUiPermissions,
662
+ auditlog: [import_constants.uiPermissionsById.read.value],
663
+ deployments: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.read.value],
664
+ groups: {
665
+ [import_constants.ALL_DEVICES]: [
666
+ import_constants.uiPermissionsById.read.value,
667
+ // we can't assign deployment permissions to devices here, since the old path based rbac controls don't allow the scoped permissions
668
+ // uiPermissionsById.deploy.value,
669
+ import_constants.uiPermissionsById.manage.value,
670
+ import_constants.uiPermissionsById.connect.value,
671
+ import_constants.uiPermissionsById.configure.value
672
+ ]
673
+ },
674
+ releases: {
675
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.manage.value]
676
+ },
677
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
678
+ }
679
+ },
680
+ almostAdminNew: {
681
+ editable: true,
682
+ isCustom: void 0,
683
+ uiPermissions: {
684
+ ...import_constants.emptyUiPermissions,
685
+ auditlog: [import_constants.uiPermissionsById.read.value],
686
+ deployments: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.manage.value],
687
+ groups: {
688
+ [import_constants.ALL_DEVICES]: [
689
+ import_constants.uiPermissionsById.read.value,
690
+ import_constants.uiPermissionsById.manage.value,
691
+ import_constants.uiPermissionsById.deploy.value,
692
+ import_constants.uiPermissionsById.connect.value,
693
+ import_constants.uiPermissionsById.configure.value
694
+ ]
695
+ },
696
+ releases: {
697
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.read.value]
698
+ },
699
+ tenantManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value],
700
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
701
+ }
702
+ }
703
+ };
704
+ var defaultRolesById = {
705
+ ...import_constants.rolesById,
706
+ test: {
707
+ ...import_constants.emptyRole,
708
+ name: "test",
709
+ description: "test description",
710
+ editable: true,
711
+ uiPermissions: {
712
+ ...import_constants.emptyUiPermissions,
713
+ groups: { testGroup: [import_constants.uiPermissionsById.read.value] },
714
+ releases: { bar: [import_constants.uiPermissionsById.read.value] }
715
+ }
716
+ }
717
+ };
718
+ var receivedRoles = rbacRoles.reduce(
719
+ (accu, role) => {
720
+ const { name, description, ...roleRemainder } = role;
721
+ if (name.startsWith("RBAC")) {
722
+ accu[name] = {
723
+ ...defaultRolesById[name],
724
+ ...roleRemainder,
725
+ editable: false,
726
+ isCustom: false,
727
+ description: defaultRolesById[name].description ? defaultRolesById[name].description : description
728
+ };
729
+ } else {
730
+ const result = expectedParsedRoles[name] ?? {};
731
+ accu[name] = {
732
+ ...import_constants.emptyRole,
733
+ ...role,
734
+ ...result,
735
+ name
736
+ };
737
+ }
738
+ return accu;
739
+ },
740
+ { ...defaultRolesById }
741
+ );
742
+ var receivedPermissionSets = permissionSets.reduce((accu, set) => {
743
+ const result = import_constants.defaultPermissionSets[set.name]?.result ?? {};
744
+ accu[set.name] = {
745
+ ...set,
746
+ result: {
747
+ ...import_constants.emptyUiPermissions,
748
+ ...result
749
+ }
750
+ };
751
+ return accu;
752
+ }, {});
753
+
754
+ // src/requestHandlers/releaseHandlers.ts
755
+ var releaseHandlers = [
756
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/artifacts/:id/download`, () => import_msw.HttpResponse.json({ uri: "https://testlocation.com/artifact.mender" })),
757
+ import_msw.http.delete(
758
+ `${import_constants2.deploymentsApiUrl}/artifacts/:id`,
759
+ ({ params: { id } }) => new import_msw.HttpResponse(null, { status: id === mockApiResponses.releases.byId.r1.artifacts[0].id ? 200 : 591 })
760
+ ),
761
+ import_msw.http.put(`${import_constants2.deploymentsApiUrl}/artifacts/:id`, async ({ params: { id }, request }) => {
762
+ const { description } = await request.json();
763
+ return new import_msw.HttpResponse(null, { status: id === mockApiResponses.releases.byId.r1.artifacts[0].id && description ? 200 : 592 });
764
+ }),
765
+ import_msw.http.post(`${import_constants2.deploymentsApiUrl}/artifacts/generate`, () => new import_msw.HttpResponse(null, { status: 200 })),
766
+ import_msw.http.post(`${import_constants2.deploymentsApiUrl}/artifacts`, () => new import_msw.HttpResponse(null, { status: 200 })),
767
+ import_msw.http.get(`${import_constants2.deploymentsApiUrlV2}/deployments/releases`, async ({ request }) => {
768
+ const { searchParams } = new URL(request.url);
769
+ const page = Number(searchParams.get("page"));
770
+ const perPage = Number(searchParams.get("per_page"));
771
+ if (!page || ![1, 10, 20, 50, 100, 250, 500].includes(perPage)) {
772
+ return new import_msw.HttpResponse(null, { status: 593 });
773
+ }
774
+ if (searchParams.get("device_type")) {
775
+ return import_msw.HttpResponse.json([]);
776
+ }
777
+ if (page == 42) {
778
+ return new import_msw.HttpResponse(JSON.stringify([mockApiResponses.releases.byId.r1]), { headers: { [import_constants2.headerNames.total]: 1 } });
779
+ }
780
+ const sort = searchParams.get("sort");
781
+ const releaseListSection = releasesList.sort((0, import_helpers.customSort)(sort.includes(import_constants2.SORTING_OPTIONS.desc), "name")).slice((page - 1) * perPage, page * perPage);
782
+ if (page === 1 && perPage === 1 && searchParams.get("name")) {
783
+ return import_msw.HttpResponse.json([mockApiResponses.releases.byId.r1]);
784
+ }
785
+ if (searchParams.get("name")) {
786
+ return new import_msw.HttpResponse(JSON.stringify(releaseListSection), { headers: { [import_constants2.headerNames.total]: 1234 } });
787
+ }
788
+ return new import_msw.HttpResponse(JSON.stringify(releaseListSection), { headers: { [import_constants2.headerNames.total]: releasesList.length } });
789
+ }),
790
+ import_msw.http.get(`${import_constants2.deploymentsApiUrlV2}/deployments/releases/:name`, () => import_msw.HttpResponse.json(mockApiResponses.releases.byId.r1)),
791
+ import_msw.http.get(`${import_constants2.deploymentsApiUrlV2}/releases/all/tags`, () => import_msw.HttpResponse.json(["foo", "bar"])),
792
+ import_msw.http.get(`${import_constants2.deploymentsApiUrlV2}/releases/all/types`, () => import_msw.HttpResponse.json(["single-file", "not-this"])),
793
+ import_msw.http.put(`${import_constants2.deploymentsApiUrlV2}/deployments/releases/:name/tags`, async ({ params: { name }, request }) => {
794
+ const tags = await request.json();
795
+ if (name && tags.every((i) => i && i.toString() === i)) {
796
+ return new import_msw.HttpResponse(null, { status: 200 });
797
+ }
798
+ return new import_msw.HttpResponse(null, { status: 593 });
799
+ }),
800
+ import_msw.http.patch(`${import_constants2.deploymentsApiUrlV2}/deployments/releases/:name`, async ({ params: { name }, request }) => {
801
+ const { notes } = await request.json();
802
+ return new import_msw.HttpResponse(null, { status: name && notes.length ? 200 : 594 });
803
+ })
804
+ ];
805
+ // Annotate the CommonJS export names for ESM import in node:
806
+ 0 && (module.exports = {
807
+ releaseHandlers
808
+ });
809
+ //# sourceMappingURL=releaseHandlers.cjs.map