@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,1712 @@
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/requestHandlers.ts
21
+ var requestHandlers_exports = {};
22
+ __export(requestHandlers_exports, {
23
+ default: () => requestHandlers_default
24
+ });
25
+ module.exports = __toCommonJS(requestHandlers_exports);
26
+ var import_msw7 = require("msw");
27
+
28
+ // src/requestHandlers/deploymentHandlers.ts
29
+ var import_constants2 = require("@northern.tech/utils/constants");
30
+ var import_msw = require("msw");
31
+
32
+ // src/mockData.ts
33
+ var import_constants = require("@northern.tech/utils/constants");
34
+ var TEST_SESSION_DATETIME = "2019-01-13T13:00:00.000Z";
35
+ var testDate = new Date(TEST_SESSION_DATETIME);
36
+ var mockDate = new Date(testDate.setMilliseconds(testDate.getMilliseconds() + import_constants.maxSessionAge));
37
+ var defaultPassword = "mysecretpassword!123";
38
+ var defaultCreationDate = "2019-01-13T06:25:00.000Z";
39
+ var defaultMacAddress = "dc:a6:32:12:ad:bf";
40
+ var testSsoId = "sso_id";
41
+ var permissionSetObjectTypes = {
42
+ any: "Any",
43
+ artifacts: "Artifacts",
44
+ empty: "",
45
+ groups: "Device groups",
46
+ releases: "Releases",
47
+ tenantManagement: "Tenant management",
48
+ userManagement: "User management"
49
+ };
50
+ var commonEndpoints = {
51
+ artifacts: "^/api/management/v1/deployments/artifacts",
52
+ artifactDetails: "^/api/management/v1/deployments/artifacts/[^/]+",
53
+ deviceManagement: "^/api/management/(v[1-9])/(devauth|inventory)/"
54
+ };
55
+ var token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjZTNkMGY4Yy1hZWRlLTQwMzAtYjM5MS03ZDUwMjBlYjg3M2UiLCJzdWIiOiJhMzBhNzgwYi1iODQzLTUzNDQtODBlMy0wZmQ5NWE0ZjZmYzMiLCJleHAiOjE2MDY4MTUzNjksImlhdCI6MTYwNjIxMDU2OSwibWVuZGVyLnRlbmFudCI6IjVmODVjMTdiY2U2MmI3ZmE3ZjVmNzA0MCIsIm1lbmRlci51c2VyIjp0cnVlLCJpc3MiOiJNZW5kZXIgVXNlcnMiLCJzY3AiOiJtZW5kZXIuKiIsIm1lbmRlci5wbGFuIjoicHJvZmVzc2lvbmFsIiwibmJmIjoxNjA2MjEwNTY5fQ.qVgYdCzLTf8OdK9uUctqqaY_HWkIiwpekuGvuGQAXCEgOv4bRNDlZRN_ZRSbxQoARG3pquhScbQrjBV9tcF4irTUPlTn3yrsXNO17DpcbTVeKRkb88RDtIKiRw3orVZ_GlIb-ckTQ5dS-Nqlyyf3Fmrhca-gwt6m_xv2UrmJK6eYYTMfggdRRWb-4u7mEkBI_pHPMTQrT8kJ2BeX-vHgazH9AoH0k85LHtFZQXD7pXHlDZRnLxJXukncwMGDmF17374gavYAIyDIzcC8sEBMDnVXgpikeA1sauzirqix6mAVs6XmxdQO7aF0wfXO1_PTYUA3Nk1oQfMYNlEI3U9uLRJRZIq2L8fmrrBryhstKd4y0KlBbGAQrx8NtRkgajjd1ljMfPBUEZrb7uSerVjneiO-aIBO76CuH0zdklphIjpGJeogkBhe8pAYNggp1XsZHgpZfl7IE5faKaDkMGnutaea--Czor6bhqUNCuY4tR0cpQJbNwy6LS9o1CFy4Log";
56
+ var accessTokens = [
57
+ { id: "some-id-1", expiration_date: "2022-06-02T11:11:21.725Z", name: "some-name-1" },
58
+ { id: "some-id-2", expiration_date: "2022-06-02T11:11:21.725Z", last_used: "2022-06-02T11:05:21.725Z", name: "some-name-2" }
59
+ ];
60
+ var webhookEvents = [
61
+ {
62
+ id: "1",
63
+ type: "device-status-changed",
64
+ data: { id: "1", status: "accepted" },
65
+ time: "2020-09-01T12:00:00.000Z",
66
+ delivery_statuses: [{ integration_id: "1", success: true, status_code: 200 }]
67
+ },
68
+ {
69
+ id: "2",
70
+ type: "device-status-changed",
71
+ data: { id: "3", status: "accepted" },
72
+ time: "2020-09-01T12:00:05.000Z",
73
+ delivery_statuses: [{ integration_id: "1", success: true, status_code: 200 }]
74
+ }
75
+ ];
76
+ var userId = "a30a780b-b843-5344-80e3-0fd95a4f6fc3";
77
+ var defaultUser = {
78
+ created_ts: "2019-01-01T10:30:00.000Z",
79
+ email: "a@b.com",
80
+ id: "a1",
81
+ roles: ["RBAC_ROLE_PERMIT_ALL"],
82
+ tfa_status: "enabled",
83
+ verified: true
84
+ };
85
+ var deviceTypes = { qemu: "qemux86-64" };
86
+ var checkInTimeRounded = "2019-01-01T00:00:00.000Z";
87
+ var checkInTimeExact = "2019-01-01T10:25:00.000Z";
88
+ var mockApiResponses = {
89
+ deployments: {
90
+ byId: {
91
+ d1: {
92
+ id: "d1",
93
+ name: "test deployment",
94
+ created: "2019-01-01T12:30:00.000Z",
95
+ devices: {
96
+ a1: {
97
+ id: "a1",
98
+ status: "installing",
99
+ attributes: {},
100
+ image: { size: 123 }
101
+ }
102
+ },
103
+ statistics: {
104
+ status: {
105
+ "already-installed": 0,
106
+ decommissioned: 0,
107
+ downloading: 0,
108
+ failure: 0,
109
+ installing: 1,
110
+ noartifact: 0,
111
+ pending: 0,
112
+ rebooting: 0,
113
+ success: 0
114
+ },
115
+ total_size: 1234
116
+ }
117
+ },
118
+ d2: {
119
+ id: "d2",
120
+ name: "test deployment 2",
121
+ artifact_name: "r1",
122
+ artifacts: ["123"],
123
+ created: "2019-01-01T12:25:00.000Z",
124
+ device_count: 1,
125
+ devices: {
126
+ b1: {
127
+ attributes: {},
128
+ id: "b1",
129
+ status: "pending"
130
+ }
131
+ },
132
+ filter: void 0,
133
+ group: void 0,
134
+ statistics: {
135
+ status: {
136
+ downloading: 0,
137
+ decommissioned: 0,
138
+ failure: 0,
139
+ installing: 0,
140
+ noartifact: 0,
141
+ pending: 1,
142
+ rebooting: 0,
143
+ success: 0,
144
+ "already-installed": 0
145
+ }
146
+ }
147
+ },
148
+ d3: {
149
+ id: "d3",
150
+ name: "Test",
151
+ phases: [
152
+ { id: "0", batch_size: 2, device_count: 2 },
153
+ { id: "1", start_ts: "2019-02-04T11:45:10.002Z", batch_size: 3, device_count: 3 },
154
+ { id: "2", start_ts: "2019-02-05T11:45:10.002Z", batch_size: 5, device_count: 5 },
155
+ { id: "3", start_ts: "2019-02-06T11:45:10.002Z", batch_size: 5, device_count: 5 },
156
+ { id: "4", start_ts: "2019-02-21T11:45:10.002Z", batch_size: 5, device_count: 0 }
157
+ ],
158
+ max_devices: 0,
159
+ created: "2019-01-31T12:59:30.020Z",
160
+ devices: {},
161
+ filter: void 0,
162
+ group: void 0,
163
+ stats: {
164
+ pending: 3,
165
+ decommissioned: 0,
166
+ failure: 23,
167
+ pause_before_committing: 0,
168
+ pause_before_rebooting: 0,
169
+ installing: 0,
170
+ rebooting: 0,
171
+ "already-installed": 0,
172
+ pause_before_installing: 0,
173
+ downloading: 0,
174
+ success: 6,
175
+ aborted: 0,
176
+ noartifact: 0
177
+ },
178
+ statistics: { total_size: "1234" },
179
+ status: "inprogress",
180
+ active: true,
181
+ device_count: 100,
182
+ retries: "0",
183
+ type: "software"
184
+ }
185
+ },
186
+ byStatus: {
187
+ pending: { deploymentIds: ["d2"] },
188
+ inprogress: { deploymentIds: ["d3"] }
189
+ }
190
+ },
191
+ devices: {
192
+ byId: {
193
+ a1: {
194
+ id: "a1",
195
+ auth_sets: [
196
+ {
197
+ id: "auth1",
198
+ identity_data: { mac: defaultMacAddress },
199
+ pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
200
+ status: "accepted",
201
+ ts: defaultCreationDate
202
+ }
203
+ ],
204
+ updated_ts: "2019-01-01T09:25:00.000Z"
205
+ },
206
+ b1: {
207
+ id: "b1",
208
+ attributes: {
209
+ ipv4_wlan0: "192.168.10.141/24",
210
+ device_type: [deviceTypes.qemu]
211
+ },
212
+ system: {
213
+ check_in_time: checkInTimeRounded
214
+ },
215
+ check_in_time: checkInTimeExact,
216
+ check_in_time_exact: checkInTimeExact,
217
+ check_in_time_rounded: checkInTimeRounded,
218
+ identity_data: { mac: defaultMacAddress },
219
+ status: "accepted",
220
+ decommissioning: false,
221
+ created_ts: defaultCreationDate,
222
+ updated_ts: "2019-01-01T09:25:00.000Z",
223
+ auth_sets: [
224
+ {
225
+ id: "auth1",
226
+ identity_data: { mac: defaultMacAddress },
227
+ pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
228
+ ts: defaultCreationDate,
229
+ status: "accepted"
230
+ }
231
+ ]
232
+ }
233
+ },
234
+ groups: {
235
+ byId: {
236
+ testGroup: {
237
+ deviceIds: ["a1", "b1"],
238
+ filters: [],
239
+ total: 2
240
+ },
241
+ testGroupDynamic: {
242
+ id: "filter1",
243
+ name: "filter1",
244
+ filters: [{ scope: "system", key: "group", operator: "$eq", value: "things" }]
245
+ }
246
+ }
247
+ },
248
+ limit: 500,
249
+ byStatus: {
250
+ accepted: { deviceIds: ["a1", "b1"], total: 2 },
251
+ active: { deviceIds: [], total: 0 },
252
+ inactive: { deviceIds: [], total: 0 },
253
+ pending: { deviceIds: ["c1"], total: 1 },
254
+ preauthorized: { deviceIds: [], total: 0 },
255
+ rejected: { deviceIds: [], total: 0 }
256
+ }
257
+ },
258
+ organization: {
259
+ organization: {
260
+ id: "1",
261
+ addons: [],
262
+ name: "test",
263
+ plan: "os",
264
+ trial: false
265
+ },
266
+ intentId: "testIntent",
267
+ auditlog: {
268
+ events: [
269
+ {
270
+ actor: {
271
+ id: "string",
272
+ type: "user",
273
+ email: "string@example.com"
274
+ },
275
+ time: "2019-01-01T12:10:22.667Z",
276
+ action: "create",
277
+ object: {
278
+ id: "string",
279
+ type: "user",
280
+ user: {
281
+ email: "user@acme.com"
282
+ }
283
+ },
284
+ change: "change1"
285
+ },
286
+ {
287
+ actor: {
288
+ id: "string",
289
+ type: "user",
290
+ email: "string",
291
+ identity_data: "string"
292
+ },
293
+ time: "2019-01-01T12:16:22.667Z",
294
+ action: "create",
295
+ object: {
296
+ id: "string",
297
+ type: "deployment",
298
+ deployment: {
299
+ name: "production",
300
+ artifact_name: "Application 0.0.1"
301
+ }
302
+ },
303
+ change: "change2"
304
+ },
305
+ {
306
+ actor: {
307
+ id: "string",
308
+ type: "user",
309
+ email: "string@example.com"
310
+ },
311
+ time: "2019-01-01T12:10:22.669Z",
312
+ action: "open_terminal",
313
+ meta: {
314
+ session_id: ["abd313a8-ee88-48ab-9c99-fbcd80048e6e"]
315
+ },
316
+ object: {
317
+ id: "a1",
318
+ type: "device"
319
+ },
320
+ change: "change3"
321
+ }
322
+ ]
323
+ }
324
+ },
325
+ releases: {
326
+ byId: {
327
+ r1: {
328
+ name: "r1",
329
+ artifacts: [
330
+ {
331
+ id: "art1",
332
+ description: "test description",
333
+ device_types_compatible: [deviceTypes.qemu],
334
+ modified: "2020-09-10T12:16:22.667Z",
335
+ updates: [{ type_info: "testtype" }],
336
+ artifact_depends: {
337
+ device_type: [deviceTypes.qemu]
338
+ },
339
+ artifact_provides: {
340
+ artifact_name: "myapp",
341
+ "data-partition.myapp.version": "v2020.10",
342
+ list_of_fancy: [deviceTypes.qemu, "x172"]
343
+ },
344
+ clears_artifact_provides: ["data-partition.myapp.*"]
345
+ }
346
+ ],
347
+ device_types_compatible: [deviceTypes.qemu],
348
+ modified: "2020-09-10T12:16:22.667Z",
349
+ metaData: {}
350
+ }
351
+ }
352
+ },
353
+ users: {
354
+ byId: {
355
+ a1: defaultUser,
356
+ [userId]: { ...defaultUser, id: userId, email: "a2@b.com", created_ts: "2019-01-01T12:30:00.000Z" }
357
+ },
358
+ rolesById: {
359
+ admin: {
360
+ name: "admin",
361
+ description: "Administrator role",
362
+ permissions: []
363
+ },
364
+ test: { name: "test", description: "test description", permissions: [] }
365
+ },
366
+ globalSettings: {
367
+ "2fa": "enabled",
368
+ id_attribute: void 0,
369
+ previousFilters: []
370
+ },
371
+ userSettings: {
372
+ "2fa": "disabled",
373
+ columnSelection: [],
374
+ onboarding: { something: "here" },
375
+ tooltips: {},
376
+ previousFilters: []
377
+ }
378
+ }
379
+ };
380
+ var releasesList = Array.from({ length: 5e3 }, (x, i) => ({
381
+ artifacts: [
382
+ {
383
+ id: "art1",
384
+ description: "test description",
385
+ device_types_compatible: [deviceTypes.qemu],
386
+ modified: "2020-09-10T12:16:22.667Z",
387
+ updates: [{ type_info: "testtype" }],
388
+ artifact_depends: {
389
+ device_type: [deviceTypes.qemu]
390
+ },
391
+ artifact_provides: {
392
+ artifact_name: "myapp",
393
+ "data-partition.myapp.version": "v2020.10",
394
+ list_of_fancy: [deviceTypes.qemu, "x172"]
395
+ },
396
+ clears_artifact_provides: ["data-partition.myapp.*"]
397
+ }
398
+ ],
399
+ device_types_compatible: [deviceTypes.qemu],
400
+ metaData: {},
401
+ name: `release-${i + 1}`,
402
+ modified: i
403
+ }));
404
+ var permissionSets = [
405
+ {
406
+ ...import_constants.defaultPermissionSets.Basic,
407
+ object: permissionSetObjectTypes.empty,
408
+ description: "Set containing basic permissions.",
409
+ permissions: [
410
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/settings$" } },
411
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/users/me$" } },
412
+ { action: "http", object: { type: "any", value: "^/api/management/1.0/auth/verify$" } },
413
+ { action: "http", object: { type: "PUT", value: "^/api/management/v1/useradm/2faverify$" } },
414
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/useradm/users/me/2fa/(enable|disable)$" } },
415
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/roles" } },
416
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/user/tenant" } }
417
+ ]
418
+ },
419
+ {
420
+ ...import_constants.defaultPermissionSets.ManageReleases,
421
+ action: import_constants.uiPermissionsById.manage.title,
422
+ object: permissionSetObjectTypes.releases,
423
+ description: "Set of permissions which allows user to manage releases",
424
+ permissions: [
425
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
426
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
427
+ { action: "http", object: { type: "PUT", value: commonEndpoints.artifactDetails } },
428
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.artifactDetails } },
429
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
430
+ ]
431
+ },
432
+ {
433
+ ...import_constants.defaultPermissionSets.ReadUsers,
434
+ action: import_constants.uiPermissionsById.read.title,
435
+ object: permissionSetObjectTypes.userManagement,
436
+ description: "Set of permissions which allows user to view other users",
437
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/" } }]
438
+ },
439
+ {
440
+ ...import_constants.defaultPermissionSets.ManageUsers,
441
+ action: import_constants.uiPermissionsById.manage.title,
442
+ object: permissionSetObjectTypes.userManagement,
443
+ description: "Set of permissions which allows user manage other user accounts",
444
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/" } }]
445
+ },
446
+ {
447
+ ...import_constants.defaultPermissionSets.ReadTenants,
448
+ action: import_constants.uiPermissionsById.read.title,
449
+ object: permissionSetObjectTypes.tenantManagement,
450
+ description: "Set of permissions which allows user to list other tenants and their config",
451
+ permissions: [
452
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
453
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } }
454
+ ]
455
+ },
456
+ {
457
+ ...import_constants.defaultPermissionSets.ManageTenants,
458
+ action: import_constants.uiPermissionsById.manage.title,
459
+ object: permissionSetObjectTypes.tenantManagement,
460
+ description: "Set of permissions which allows user to manage other tenants and their config",
461
+ permissions: [
462
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
463
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } },
464
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9])/tenantadm/" } }
465
+ ]
466
+ },
467
+ {
468
+ ...import_constants.defaultPermissionSets.ReadAuditLogs,
469
+ action: import_constants.uiPermissionsById.read.title,
470
+ object: "System Audit Log",
471
+ description: "Set of permissions which allows user to view system audit log",
472
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/auditlogs/logs" } }]
473
+ },
474
+ {
475
+ ...import_constants.defaultPermissionSets.DeployToDevices,
476
+ action: "Deploy",
477
+ object: permissionSetObjectTypes.groups,
478
+ description: "Set of permissions which allows user to deploy to devices",
479
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/(deployments|deviceconfig)/" } }],
480
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
481
+ },
482
+ {
483
+ ...import_constants.defaultPermissionSets.ConfigureDevices,
484
+ action: "Configure",
485
+ object: permissionSetObjectTypes.groups,
486
+ description: "Set of permissions which allows user to manage configuration of the devices",
487
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/" } }],
488
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
489
+ },
490
+ {
491
+ ...import_constants.defaultPermissionSets.ConnectToDevices,
492
+ action: "Connect",
493
+ object: permissionSetObjectTypes.groups,
494
+ description: "Set of permissions which allows user to use remote terminal and file transfer",
495
+ permissions: [
496
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/connect$" } },
497
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/download\\?path=[^&]+$" } },
498
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/upload$" } }
499
+ ],
500
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
501
+ },
502
+ {
503
+ ...import_constants.defaultPermissionSets.SuperUser,
504
+ action: "Any",
505
+ object: permissionSetObjectTypes.any,
506
+ description: "Set of permissions which allows user to do anything",
507
+ permissions: [{ action: "any", object: { type: "any", value: "any" } }]
508
+ },
509
+ {
510
+ ...import_constants.defaultPermissionSets.UploadArtifacts,
511
+ action: "Upload",
512
+ object: permissionSetObjectTypes.artifacts,
513
+ description: "Set of permissions which allows user to upload artifacts",
514
+ permissions: [
515
+ { action: "http", object: { type: "POST", value: commonEndpoints.artifacts } },
516
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/deployments/artifacts/generate" } }
517
+ ]
518
+ },
519
+ {
520
+ ...import_constants.defaultPermissionSets.ReadDevices,
521
+ action: import_constants.uiPermissionsById.read.title,
522
+ object: permissionSetObjectTypes.groups,
523
+ description: "Set of permissions which allows user to view devices",
524
+ permissions: [
525
+ { action: "http", object: { type: "POST", value: "^/api/management/v2/inventory/filters/search" } },
526
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/reporting/devices/search" } },
527
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/(deployments|devauth|inventory|deviceconfig|devicemonitor)/" } },
528
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+$" } }
529
+ ],
530
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
531
+ },
532
+ {
533
+ ...import_constants.defaultPermissionSets.ManageDevices,
534
+ action: import_constants.uiPermissionsById.manage.title,
535
+ object: permissionSetObjectTypes.groups,
536
+ description: "Set of permissions which allows user to manage devices",
537
+ permissions: [
538
+ { action: "http", object: { type: "POST", value: commonEndpoints.deviceManagement } },
539
+ { action: "http", object: { type: "PUT", value: commonEndpoints.deviceManagement } },
540
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.deviceManagement } }
541
+ ],
542
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
543
+ },
544
+ {
545
+ ...import_constants.defaultPermissionSets.ReadReleases,
546
+ action: import_constants.uiPermissionsById.read.title,
547
+ object: permissionSetObjectTypes.releases,
548
+ description: "Set of permissions which allows user to view releases",
549
+ permissions: [
550
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
551
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
552
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
553
+ ]
554
+ },
555
+ {
556
+ name: "almostAdmin",
557
+ object: permissionSetObjectTypes.empty,
558
+ description: "Set containing all the permissions.",
559
+ permissions: [
560
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/auditlogs/.*" } },
561
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/.*" } },
562
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/config/.*" } },
563
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/.*" } },
564
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/releases/.*" } },
565
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/devauth/.*" } },
566
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/.*" } },
567
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/.*" } },
568
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/devices" } },
569
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/inventory/.*" } },
570
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/iot-manager/.*" } },
571
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/monitor/.*" } },
572
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/.*" } }
573
+ ]
574
+ }
575
+ ];
576
+ var rbacRoles = [
577
+ {
578
+ name: "dyn",
579
+ description: "",
580
+ permissions: [
581
+ { action: "CREATE_DEPLOYMENT", object: { type: "DEVICE_GROUP", value: "dyn" } },
582
+ { action: "VIEW_DEVICE", object: { type: "DEVICE_GROUP", value: "dyn" } }
583
+ ]
584
+ },
585
+ { name: "asdasd", description: "123", permissions: [{ action: "http", object: { type: "any", value: "/api/management/v1/useradm/.*" } }] },
586
+ {
587
+ name: "141sasd",
588
+ description: "1313adg",
589
+ permission_sets_with_scope: [
590
+ { ...import_constants.defaultPermissionSets.ReadDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
591
+ { ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
592
+ { ...import_constants.defaultPermissionSets.ManageUsers }
593
+ ]
594
+ },
595
+ {
596
+ name: "kljlkk",
597
+ description: "lkl",
598
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } }]
599
+ },
600
+ {
601
+ name: "yyyyy",
602
+ description: "asd",
603
+ permission_sets_with_scope: [
604
+ { ...import_constants.defaultPermissionSets.ManageDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["dockerclient"] } },
605
+ { ...import_constants.defaultPermissionSets.ManageReleases }
606
+ ]
607
+ },
608
+ {
609
+ name: "RBAC_ROLE_DEPLOYMENTS_MANAGER",
610
+ description: "Intended for users responsible for managing deployments, this role can create and abort deployments",
611
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.DeployToDevices }]
612
+ },
613
+ {
614
+ name: "RBAC_ROLE_REMOTE_TERMINAL",
615
+ description: `Intended for tech support accounts, this role can access the devices' Remote Terminal.`,
616
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices }]
617
+ },
618
+ { name: "RBAC_ROLE_PERMIT_ALL", description: "", permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.SuperUser }] },
619
+ {
620
+ name: "RBAC_ROLE_OBSERVER",
621
+ 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.",
622
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ReadReleases }, { ...import_constants.defaultPermissionSets.ReadDevices }]
623
+ },
624
+ {
625
+ name: "RBAC_ROLE_CI",
626
+ 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.",
627
+ permission_sets_with_scope: [
628
+ { ...import_constants.defaultPermissionSets.ReadReleases },
629
+ { ...import_constants.defaultPermissionSets.ManageReleases },
630
+ { ...import_constants.defaultPermissionSets.UploadArtifacts }
631
+ ]
632
+ },
633
+ {
634
+ name: "almostAdmin",
635
+ description: "almost admin rights",
636
+ permissions: permissionSets.find((item) => item.name === "almostAdmin")?.permissions
637
+ },
638
+ {
639
+ name: "almostAdminNew",
640
+ description: "almost admin rights",
641
+ permission_sets_with_scope: Object.values(import_constants.defaultPermissionSets)
642
+ }
643
+ ];
644
+ var expectedParsedRoles = {
645
+ "141sasd": {
646
+ editable: true,
647
+ isCustom: void 0,
648
+ uiPermissions: {
649
+ ...import_constants.emptyUiPermissions,
650
+ groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] },
651
+ userManagement: [import_constants.uiPermissionsById.manage.value]
652
+ }
653
+ },
654
+ asdasd: {
655
+ editable: false,
656
+ isCustom: true,
657
+ uiPermissions: { ...import_constants.emptyUiPermissions, userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] }
658
+ },
659
+ dyn: {
660
+ editable: false,
661
+ isCustom: true,
662
+ uiPermissions: {
663
+ ...import_constants.emptyUiPermissions,
664
+ deployments: [import_constants.uiPermissionsById.deploy.value],
665
+ groups: { dyn: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value] }
666
+ }
667
+ },
668
+ kljlkk: {
669
+ editable: true,
670
+ isCustom: false,
671
+ uiPermissions: { ...import_constants.emptyUiPermissions, groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] } }
672
+ },
673
+ yyyyy: {
674
+ editable: true,
675
+ isCustom: void 0,
676
+ uiPermissions: {
677
+ ...import_constants.emptyUiPermissions,
678
+ groups: { dockerclient: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] },
679
+ releases: { [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value] }
680
+ }
681
+ },
682
+ almostAdmin: {
683
+ editable: false,
684
+ isCustom: true,
685
+ uiPermissions: {
686
+ ...import_constants.emptyUiPermissions,
687
+ auditlog: [import_constants.uiPermissionsById.read.value],
688
+ deployments: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.read.value],
689
+ groups: {
690
+ [import_constants.ALL_DEVICES]: [
691
+ import_constants.uiPermissionsById.read.value,
692
+ // we can't assign deployment permissions to devices here, since the old path based rbac controls don't allow the scoped permissions
693
+ // uiPermissionsById.deploy.value,
694
+ import_constants.uiPermissionsById.manage.value,
695
+ import_constants.uiPermissionsById.connect.value,
696
+ import_constants.uiPermissionsById.configure.value
697
+ ]
698
+ },
699
+ releases: {
700
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.manage.value]
701
+ },
702
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
703
+ }
704
+ },
705
+ almostAdminNew: {
706
+ editable: true,
707
+ isCustom: void 0,
708
+ uiPermissions: {
709
+ ...import_constants.emptyUiPermissions,
710
+ auditlog: [import_constants.uiPermissionsById.read.value],
711
+ deployments: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.manage.value],
712
+ groups: {
713
+ [import_constants.ALL_DEVICES]: [
714
+ import_constants.uiPermissionsById.read.value,
715
+ import_constants.uiPermissionsById.manage.value,
716
+ import_constants.uiPermissionsById.deploy.value,
717
+ import_constants.uiPermissionsById.connect.value,
718
+ import_constants.uiPermissionsById.configure.value
719
+ ]
720
+ },
721
+ releases: {
722
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.read.value]
723
+ },
724
+ tenantManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value],
725
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
726
+ }
727
+ }
728
+ };
729
+ var defaultRolesById = {
730
+ ...import_constants.rolesById,
731
+ test: {
732
+ ...import_constants.emptyRole,
733
+ name: "test",
734
+ description: "test description",
735
+ editable: true,
736
+ uiPermissions: {
737
+ ...import_constants.emptyUiPermissions,
738
+ groups: { testGroup: [import_constants.uiPermissionsById.read.value] },
739
+ releases: { bar: [import_constants.uiPermissionsById.read.value] }
740
+ }
741
+ }
742
+ };
743
+ var receivedRoles = rbacRoles.reduce(
744
+ (accu, role) => {
745
+ const { name, description, ...roleRemainder } = role;
746
+ if (name.startsWith("RBAC")) {
747
+ accu[name] = {
748
+ ...defaultRolesById[name],
749
+ ...roleRemainder,
750
+ editable: false,
751
+ isCustom: false,
752
+ description: defaultRolesById[name].description ? defaultRolesById[name].description : description
753
+ };
754
+ } else {
755
+ const result = expectedParsedRoles[name] ?? {};
756
+ accu[name] = {
757
+ ...import_constants.emptyRole,
758
+ ...role,
759
+ ...result,
760
+ name
761
+ };
762
+ }
763
+ return accu;
764
+ },
765
+ { ...defaultRolesById }
766
+ );
767
+ var receivedPermissionSets = permissionSets.reduce((accu, set) => {
768
+ const result = import_constants.defaultPermissionSets[set.name]?.result ?? {};
769
+ accu[set.name] = {
770
+ ...set,
771
+ result: {
772
+ ...import_constants.emptyUiPermissions,
773
+ ...result
774
+ }
775
+ };
776
+ return accu;
777
+ }, {});
778
+
779
+ // src/requestHandlers/deploymentHandlers.ts
780
+ var createdDeployment = {
781
+ id: "created-123",
782
+ name: "test deployment",
783
+ artifact_name: "r1",
784
+ artifacts: ["123"],
785
+ created: "2019-01-01T12:30:00.000Z",
786
+ device_count: 1,
787
+ devices: {
788
+ a1: {
789
+ attributes: {},
790
+ id: "a1",
791
+ image: { size: 123 },
792
+ status: "installing"
793
+ }
794
+ },
795
+ filter: void 0,
796
+ group: void 0,
797
+ statistics: {
798
+ status: {
799
+ downloading: 0,
800
+ decommissioned: 0,
801
+ failure: 0,
802
+ installing: 1,
803
+ noartifact: 0,
804
+ pending: 0,
805
+ rebooting: 0,
806
+ success: 0,
807
+ "already-installed": 0
808
+ },
809
+ total_size: 1234
810
+ }
811
+ };
812
+ var defaultDeploymentConfig = {
813
+ delta: {
814
+ enabled: true,
815
+ binary_delta: {
816
+ xdelta_args: {
817
+ disable_checksum: false,
818
+ disable_external_decompression: false,
819
+ compression_level: 6,
820
+ source_window_size: 0,
821
+ input_window_size: 0,
822
+ compression_duplicates_window: 0,
823
+ instruction_buffer_size: 0
824
+ },
825
+ timeout: 0
826
+ },
827
+ binary_delta_limits: {
828
+ xdelta_args_limits: {
829
+ source_window_size: import_constants2.limitDefault,
830
+ input_window_size: import_constants2.limitDefault,
831
+ compression_duplicates_window: import_constants2.limitDefault,
832
+ instruction_buffer_size: import_constants2.limitDefault
833
+ },
834
+ timeout: { min: 60, max: 3600, default: 60 },
835
+ jobs_in_parallel: import_constants2.limitDefault,
836
+ queue_length: import_constants2.limitDefault
837
+ }
838
+ }
839
+ };
840
+ var deploymentHandlers = [
841
+ import_msw.http.get(
842
+ `${import_constants2.deploymentsApiUrl}/deployments`,
843
+ () => new import_msw.HttpResponse(JSON.stringify(Object.values(mockApiResponses.deployments.byId).reverse()), {
844
+ headers: { [import_constants2.headerNames.total]: Object.keys(mockApiResponses.deployments.byId).length }
845
+ })
846
+ ),
847
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/releases`, ({ request }) => {
848
+ const { searchParams } = new URL(request.url);
849
+ const releaseName = searchParams.get("name");
850
+ const release = mockApiResponses.releases.byId[releaseName] || {};
851
+ if (releaseName) {
852
+ const { device_types_compatible, ...remainder } = release;
853
+ return Object.keys(remainder).length || releaseName === "createdRelease" ? import_msw.HttpResponse.json([remainder]) : new import_msw.HttpResponse(null, { status: 520 });
854
+ }
855
+ const releases = Object.values(mockApiResponses.releases.byId).map((stateRelease) => {
856
+ const { device_types_compatible, ...remainder } = stateRelease;
857
+ return remainder;
858
+ });
859
+ return import_msw.HttpResponse.json(releases);
860
+ }),
861
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId`, ({ params: { deploymentId } }) => {
862
+ if (deploymentId === createdDeployment.id) {
863
+ return import_msw.HttpResponse.json(createdDeployment);
864
+ } else if (deploymentId === "config1") {
865
+ return import_msw.HttpResponse.json({
866
+ ...createdDeployment,
867
+ id: "config1",
868
+ created: "2019-01-01T09:25:01.000Z",
869
+ finished: "2019-01-01T09:25:03.000Z",
870
+ status: "finished"
871
+ });
872
+ }
873
+ return import_msw.HttpResponse.json(mockApiResponses.deployments.byId[deploymentId]);
874
+ }),
875
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId/devices`, ({ params: { deploymentId } }) => {
876
+ if (deploymentId === createdDeployment.id) {
877
+ return import_msw.HttpResponse.json(Object.values(createdDeployment.devices));
878
+ } else if (mockApiResponses.deployments.byId[deploymentId]) {
879
+ return import_msw.HttpResponse.json(Object.values(mockApiResponses.deployments.byId[deploymentId].devices));
880
+ }
881
+ return new import_msw.HttpResponse(null, { status: 521 });
882
+ }),
883
+ import_msw.http.post(`${import_constants2.deploymentsApiUrl}/deployments/statistics/list`, async ({ request }) => {
884
+ const { deployment_ids = [] } = await request.json();
885
+ if (deployment_ids.includes(createdDeployment.id)) {
886
+ return import_msw.HttpResponse.json([]);
887
+ } else if (deployment_ids.every((id) => mockApiResponses.deployments.byId[id])) {
888
+ const stats = deployment_ids.map((id) => ({ id, stats: mockApiResponses.deployments.byId[id].statistics.status }));
889
+ return import_msw.HttpResponse.json(stats);
890
+ }
891
+ return new import_msw.HttpResponse(null, { status: 522 });
892
+ }),
893
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId/devices/:deviceId/log`, ({ params: { deploymentId, deviceId } }) => {
894
+ if (mockApiResponses.deployments.byId[deploymentId] && mockApiResponses.deployments.byId[deploymentId].devices[deviceId]) {
895
+ return import_msw.HttpResponse.text("test");
896
+ }
897
+ return new import_msw.HttpResponse(null, { status: 523 });
898
+ }),
899
+ import_msw.http.post(`${import_constants2.deploymentsApiUrl}/deployments`, async ({ request }) => {
900
+ const body = await request.json();
901
+ if (!Object.keys(body).length) {
902
+ return new import_msw.HttpResponse(JSON.stringify({}), { status: 524 });
903
+ }
904
+ return new import_msw.HttpResponse(JSON.stringify({}), { headers: { location: `find/me/here/${createdDeployment.id}` } });
905
+ }),
906
+ import_msw.http.post(`${import_constants2.deploymentsApiUrlV2}/deployments`, async ({ request }) => {
907
+ const { filter_id, devices = [] } = await request.json();
908
+ if (!filter_id || !!devices.length) {
909
+ return new import_msw.HttpResponse(JSON.stringify({}), { status: 525 });
910
+ }
911
+ return new import_msw.HttpResponse(JSON.stringify({}), { headers: { location: `find/me/here/${createdDeployment.id}` } });
912
+ }),
913
+ import_msw.http.post(`${import_constants2.deploymentsApiUrl}/deployments/group/:deploymentGroup`, async ({ params: { deploymentGroup }, request }) => {
914
+ const { filter_id, devices = [] } = await request.json();
915
+ if (filter_id || !!devices.length || deploymentGroup !== Object.keys(mockApiResponses.devices.groups.byId)[0]) {
916
+ return new import_msw.HttpResponse(JSON.stringify({}), { status: 526 });
917
+ }
918
+ return new import_msw.HttpResponse(JSON.stringify({}), { headers: { location: `find/me/here/${createdDeployment.id}` } });
919
+ }),
920
+ import_msw.http.patch(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId`, async ({ params: { deploymentId }, request }) => {
921
+ const { update_control_map } = await request.json();
922
+ if (deploymentId === createdDeployment.id && Object.keys(update_control_map).length) {
923
+ return new import_msw.HttpResponse(null, { status: 204 });
924
+ }
925
+ return new import_msw.HttpResponse(null, { status: 581 });
926
+ }),
927
+ import_msw.http.put(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId/status`, async ({ params: { deploymentId }, request }) => {
928
+ const { status } = await request.json();
929
+ return new import_msw.HttpResponse(JSON.stringify({}), {
930
+ status: status === "aborted" && [...mockApiResponses.deployments.byStatus.pending.deploymentIds, ...mockApiResponses.deployments.byStatus.inprogress.deploymentIds].includes(
931
+ deploymentId
932
+ ) ? 200 : 528
933
+ });
934
+ }),
935
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/:deploymentId/devices/list`, ({ params: { deploymentId } }) => {
936
+ if (deploymentId === createdDeployment.id) {
937
+ return new import_msw.HttpResponse(JSON.stringify(Object.values(createdDeployment.devices)), {
938
+ headers: { [import_constants2.headerNames.total]: Object.keys(createdDeployment.devices).length }
939
+ });
940
+ } else if (mockApiResponses.deployments.byId[deploymentId]) {
941
+ return new import_msw.HttpResponse(JSON.stringify(Object.values(mockApiResponses.deployments.byId[deploymentId].devices)), {
942
+ headers: { [import_constants2.headerNames.total]: Object.keys(mockApiResponses.deployments.byId[deploymentId].devices).length }
943
+ });
944
+ }
945
+ return new import_msw.HttpResponse(null, { status: 529 });
946
+ }),
947
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/config`, () => import_msw.HttpResponse.json(defaultDeploymentConfig)),
948
+ import_msw.http.put(`${import_constants2.deploymentsApiUrl}/config/binary_delta`, () => new import_msw.HttpResponse(null, { status: 200 })),
949
+ import_msw.http.get(`${import_constants2.deploymentsApiUrl}/deployments/devices/:deviceId`, ({ params: { deviceId } }) => {
950
+ if (deviceId === mockApiResponses.devices.byId.a1.id) {
951
+ return new import_msw.HttpResponse(
952
+ JSON.stringify([
953
+ {
954
+ id: createdDeployment.id + "something",
955
+ deployment: { ...createdDeployment, id: mockApiResponses.deployments.byId.d1.id, status: "inprogress" },
956
+ device: {
957
+ created: "2019-01-01T12:35:00.000Z",
958
+ finished: "2019-01-01T12:40:00.000Z",
959
+ status: "noartifact",
960
+ id: "something",
961
+ image: { ...mockApiResponses.releases.byId.r1 }
962
+ },
963
+ log: true,
964
+ attempts: 1,
965
+ delta_job_id: ""
966
+ }
967
+ ]),
968
+ {
969
+ headers: { [import_constants2.headerNames.total]: 34 }
970
+ }
971
+ );
972
+ }
973
+ return new import_msw.HttpResponse(null, { status: 529 });
974
+ }),
975
+ import_msw.http.delete(`${import_constants2.deploymentsApiUrl}/deployments/devices/:deviceId/history`, () => new import_msw.HttpResponse(null, { status: 204 }))
976
+ ];
977
+
978
+ // src/requestHandlers/deviceHandlers.ts
979
+ var import_constants3 = require("@northern.tech/utils/constants");
980
+ var import_msw2 = require("msw");
981
+ var defaultDeviceId = "a1";
982
+ var deviceAuthDevice = {
983
+ id: defaultDeviceId,
984
+ identity_data: { mac: defaultMacAddress },
985
+ status: "accepted",
986
+ decommissioning: false,
987
+ created_ts: defaultCreationDate,
988
+ updated_ts: "2019-01-01T09:25:00.000Z",
989
+ auth_sets: [
990
+ {
991
+ id: "auth1",
992
+ identity_data: { mac: defaultMacAddress },
993
+ pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
994
+ ts: defaultCreationDate,
995
+ status: "accepted"
996
+ }
997
+ ]
998
+ };
999
+ var checkInTimeExact2 = "2019-01-01T10:25:00.000Z";
1000
+ var updatedTime = "2019-01-01T09:25:00.000Z";
1001
+ var inventoryDevice = {
1002
+ id: defaultDeviceId,
1003
+ attributes: [
1004
+ { name: "network_interfaces", value: ["eth0", "wlan0"], scope: "inventory" },
1005
+ { name: "kernel", value: "Linux version 4.19.75-v7l+", scope: "inventory" },
1006
+ { name: "artifact_name", value: "raspotifyInstaller", scope: "inventory" },
1007
+ { name: "ipv6_wlan0", value: "fe80::68d9:8453:3e9c:7c80/64", scope: "inventory" },
1008
+ { name: "mac_eth0", value: defaultMacAddress, scope: "inventory" },
1009
+ { name: "rootfs_type", value: "ext4", scope: "inventory" },
1010
+ { name: "mender_bootloader_integration", value: "unknown", scope: "inventory" },
1011
+ { name: "cpu_model", value: "ARMv7 Processor rev 3 (v7l)", scope: "inventory" },
1012
+ { name: "hostname", value: "raspberrypi", scope: "inventory" },
1013
+ { name: "mender_client_version", value: "2.1.0", scope: "inventory" },
1014
+ { name: "ipv4_wlan0", value: "192.168.10.141/24", scope: "inventory" },
1015
+ { name: "device_type", value: "raspberrypi4", scope: "inventory" },
1016
+ { name: "mem_total_kB", value: "1986024", scope: "inventory" },
1017
+ { name: "mac_wlan0", value: "dc:a6:32:12:ad:c0", scope: "inventory" },
1018
+ { name: "os", value: "Raspbian GNU/Linux 10 (buster)", scope: "inventory" },
1019
+ { name: "created_ts", value: defaultCreationDate, scope: "system" },
1020
+ { name: "updated_ts", value: updatedTime, scope: "system" },
1021
+ { name: "status", value: "accepted", scope: "identity" },
1022
+ { name: "mac", value: defaultMacAddress, scope: "identity" },
1023
+ { name: "group", value: "test", scope: "system" }
1024
+ ],
1025
+ check_in_time: checkInTimeExact2,
1026
+ updated_ts: updatedTime
1027
+ };
1028
+ var deviceAttributes = [
1029
+ { name: "status", scope: "identity", count: 5 },
1030
+ { name: "created_ts", scope: "system", count: 5 },
1031
+ { name: "updated_ts", scope: "system", count: 5 },
1032
+ { name: "mac", scope: "identity", count: 1 },
1033
+ { name: "artifact_name", scope: "inventory", count: 1 },
1034
+ { name: "cpu_model", scope: "inventory", count: 1 },
1035
+ { name: "device_type", scope: "inventory", count: 1 },
1036
+ { name: "hostname", scope: "inventory", count: 1 },
1037
+ { name: "ipv4_wlan0", scope: "inventory", count: 1 },
1038
+ { name: "ipv6_wlan0", scope: "inventory", count: 1 },
1039
+ { name: "kernel", scope: "inventory", count: 1 },
1040
+ { name: "mac_eth0", scope: "inventory", count: 1 },
1041
+ { name: "mac_wlan0", scope: "inventory", count: 1 },
1042
+ { name: "mem_total_kB", scope: "inventory", count: 1 },
1043
+ { name: "mender_bootloader_integration", scope: "inventory", count: 1 },
1044
+ { name: "mender_client_version", scope: "inventory", count: 1 },
1045
+ { name: "network_interfaces", scope: "inventory", count: 1 },
1046
+ { name: "os", scope: "inventory", count: 1 },
1047
+ { name: "rootfs_type", scope: "inventory", count: 1 },
1048
+ { name: "group", scope: "system", count: 1 }
1049
+ ];
1050
+ var searchHandler = async ({ request }) => {
1051
+ const { page, per_page, filters } = await request.json();
1052
+ if ([page, per_page, filters].some((item) => !item)) {
1053
+ return new import_msw2.HttpResponse(null, { status: 509 });
1054
+ }
1055
+ const filter = filters.find((filter2) => filter2.scope === "identity" && filter2.attribute === "status" && Object.values(import_constants3.DEVICE_STATES).includes(filter2.value));
1056
+ const status = filter?.value || "";
1057
+ if (!status || filters.length > 1) {
1058
+ if (filters.find((filter2) => filter2.attribute === "group" && filter2.value.includes(Object.keys(mockApiResponses.devices.groups.byId)[0]))) {
1059
+ return new import_msw2.HttpResponse(JSON.stringify([inventoryDevice, { ...inventoryDevice, id: "b1" }]), {
1060
+ headers: { [import_constants3.headerNames.total]: 2 }
1061
+ });
1062
+ }
1063
+ if (filters.find((filter2) => filter2.scope === "monitor" && ["failed_last_update", "alerts", "auth_request"].includes(filter2.attribute))) {
1064
+ return new import_msw2.HttpResponse(JSON.stringify([inventoryDevice]), { headers: { [import_constants3.headerNames.total]: 4 } });
1065
+ }
1066
+ return new import_msw2.HttpResponse(JSON.stringify([]), { headers: { [import_constants3.headerNames.total]: 0 } });
1067
+ }
1068
+ let deviceList = Array.from({ length: mockApiResponses.devices.byStatus[status].total }, (_, index) => ({
1069
+ ...inventoryDevice,
1070
+ attributes: [...inventoryDevice.attributes, { name: "test-count", value: index, scope: "system" }],
1071
+ id: `${String.fromCharCode("a".charCodeAt(0) + index)}1`
1072
+ }));
1073
+ deviceList = deviceList.slice((page - 1) * per_page, page * per_page);
1074
+ return new import_msw2.HttpResponse(JSON.stringify(deviceList), { headers: { [import_constants3.headerNames.total]: mockApiResponses.devices.byStatus[status].total } });
1075
+ };
1076
+ var deviceHandlers = [
1077
+ import_msw2.http.delete(`${import_constants3.deviceAuthV2}/devices/:deviceId/auth/:authId`, ({ params: { authId, deviceId } }) => {
1078
+ if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId)) {
1079
+ return new import_msw2.HttpResponse(null, { status: 200 });
1080
+ }
1081
+ return new import_msw2.HttpResponse(null, { status: 501 });
1082
+ }),
1083
+ import_msw2.http.delete(`${import_constants3.deviceAuthV2}/devices/:deviceId`, ({ params: { deviceId } }) => {
1084
+ if (mockApiResponses.devices.byId[deviceId]) {
1085
+ return new import_msw2.HttpResponse(null, { status: 200 });
1086
+ }
1087
+ return new import_msw2.HttpResponse(null, { status: 502 });
1088
+ }),
1089
+ import_msw2.http.delete(`${import_constants3.inventoryApiUrl}/groups/:group`, ({ params: { group } }) => {
1090
+ if (mockApiResponses.devices.groups.byId[group]) {
1091
+ return new import_msw2.HttpResponse(null, { status: 200 });
1092
+ }
1093
+ return new import_msw2.HttpResponse(null, { status: 515 });
1094
+ }),
1095
+ import_msw2.http.delete(`${import_constants3.inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
1096
+ const deviceIds = await request.json();
1097
+ if (mockApiResponses.devices.groups.byId[group] && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
1098
+ return new import_msw2.HttpResponse(null, { status: 200 });
1099
+ }
1100
+ return new import_msw2.HttpResponse(null, { status: 503 });
1101
+ }),
1102
+ import_msw2.http.delete(`${import_constants3.inventoryApiUrlV2}/filters/:filterId`, ({ params: { filterId } }) => {
1103
+ if (Object.values(mockApiResponses.devices.groups.byId).find((group) => group.id === filterId)) {
1104
+ return new import_msw2.HttpResponse(null, { status: 200 });
1105
+ }
1106
+ return new import_msw2.HttpResponse(null, { status: 504 });
1107
+ }),
1108
+ import_msw2.http.get(`${import_constants3.deviceAuthV2}/devices`, ({ request }) => {
1109
+ const { searchParams } = new URL(request.url);
1110
+ const deviceIds = searchParams.getAll("id");
1111
+ if (deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
1112
+ return import_msw2.HttpResponse.json(deviceIds.map((id) => ({ ...deviceAuthDevice, id })));
1113
+ }
1114
+ return new import_msw2.HttpResponse(null, { status: 505 });
1115
+ }),
1116
+ import_msw2.http.get(`${import_constants3.deviceAuthV2}/limits/max_devices`, () => import_msw2.HttpResponse.json({ limit: mockApiResponses.devices.limit })),
1117
+ import_msw2.http.get(`${import_constants3.inventoryApiUrl}/devices/:deviceId`, ({ params: { deviceId } }) => {
1118
+ if (mockApiResponses.devices.byId[deviceId]) {
1119
+ return import_msw2.HttpResponse.json(inventoryDevice);
1120
+ }
1121
+ return new import_msw2.HttpResponse(null, { status: 506 });
1122
+ }),
1123
+ import_msw2.http.put(`${import_constants3.inventoryApiUrl}/devices/:deviceId/tags`, async ({ params: { deviceId }, request }) => {
1124
+ const tags = await request.json();
1125
+ if (!mockApiResponses.devices.byId[deviceId] && !Array.isArray(tags) && !tags.every((item) => item.name && item.value)) {
1126
+ return new import_msw2.HttpResponse(null, { status: 506 });
1127
+ }
1128
+ return import_msw2.HttpResponse.json(tags);
1129
+ }),
1130
+ import_msw2.http.get(`${import_constants3.inventoryApiUrl}/groups`, () => {
1131
+ const groups = Object.entries(mockApiResponses.devices.groups.byId).reduce((accu, [groupName, group]) => {
1132
+ if (!group.id) {
1133
+ accu.push(groupName);
1134
+ }
1135
+ return accu;
1136
+ }, []);
1137
+ return import_msw2.HttpResponse.json(groups);
1138
+ }),
1139
+ import_msw2.http.get(`${import_constants3.inventoryApiUrlV2}/filters/attributes`, () => import_msw2.HttpResponse.json(deviceAttributes)),
1140
+ import_msw2.http.get(`${import_constants3.reportingApiUrl}/devices/attributes`, () => import_msw2.HttpResponse.json({ attributes: deviceAttributes, count: deviceAttributes.length, limit: 100 })),
1141
+ import_msw2.http.get(`${import_constants3.reportingApiUrl}/devices/search/attributes`, () => import_msw2.HttpResponse.json(deviceAttributes)),
1142
+ import_msw2.http.post(
1143
+ `${import_constants3.reportingApiUrl}/devices/aggregate`,
1144
+ () => import_msw2.HttpResponse.json([
1145
+ {
1146
+ name: "*",
1147
+ items: [
1148
+ { key: "test", count: 6 },
1149
+ { key: "original", count: 1 }
1150
+ ],
1151
+ other_count: 42
1152
+ }
1153
+ ])
1154
+ ),
1155
+ import_msw2.http.get(
1156
+ `${import_constants3.inventoryApiUrlV2}/filters`,
1157
+ () => import_msw2.HttpResponse.json([
1158
+ {
1159
+ id: "filter1",
1160
+ name: "testGroupDynamic",
1161
+ terms: [
1162
+ { scope: "identity", attribute: "id", type: "$in", value: [defaultDeviceId] },
1163
+ { scope: "identity", attribute: "mac", type: "$exists", value: false },
1164
+ { scope: "identity", attribute: "kernel", type: "$exists", value: true }
1165
+ ]
1166
+ }
1167
+ ])
1168
+ ),
1169
+ import_msw2.http.patch(`${import_constants3.inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
1170
+ const deviceIds = await request.json();
1171
+ if (!!group && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
1172
+ return new import_msw2.HttpResponse(null, { status: 200 });
1173
+ }
1174
+ return new import_msw2.HttpResponse(null, { status: 508 });
1175
+ }),
1176
+ import_msw2.http.post(`${import_constants3.deviceAuthV2}/devices`, async ({ request }) => {
1177
+ const authset = await request.json();
1178
+ if (Object.values(mockApiResponses.devices.byId).some(
1179
+ (device) => device.auth_sets.some((deviceAuthSet) => deviceAuthSet.pubkey == authset.pubkey || deviceAuthSet.identity_data == authset.identity_data)
1180
+ )) {
1181
+ return new import_msw2.HttpResponse(null, { status: 409 });
1182
+ }
1183
+ return new import_msw2.HttpResponse(null, { status: 200 });
1184
+ }),
1185
+ import_msw2.http.post(`${import_constants3.inventoryApiUrlV2}/filters/search`, searchHandler),
1186
+ import_msw2.http.post(`${import_constants3.reportingApiUrl}/filters/search`, searchHandler),
1187
+ import_msw2.http.post(`${import_constants3.inventoryApiUrlV2}/filters`, async ({ request }) => {
1188
+ const { name, terms } = await request.json();
1189
+ if ([name, terms].some((item) => !item) || mockApiResponses.devices.groups[name] || !terms.every((term) => import_constants3.DEVICE_FILTERING_OPTIONS[term.type] && ["identity", "inventory", "system"].includes(term.scope) && !!term.value && !!term.attribute)) {
1190
+ return new import_msw2.HttpResponse(null, { status: 510 });
1191
+ }
1192
+ return new import_msw2.HttpResponse(JSON.stringify({}), { headers: { location: "find/me/here/createdFilterId" } });
1193
+ }),
1194
+ import_msw2.http.put(`${import_constants3.deviceAuthV2}/devices/:deviceId/auth/:authId/status`, async ({ params: { authId, deviceId }, request }) => {
1195
+ const { status } = await request.json();
1196
+ if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId) && import_constants3.DEVICE_STATES[status]) {
1197
+ return new import_msw2.HttpResponse(null, { status: 200 });
1198
+ }
1199
+ return new import_msw2.HttpResponse(null, { status: 511 });
1200
+ }),
1201
+ import_msw2.http.get(`${import_constants3.deviceConfig}/:deviceId`, ({ params: { deviceId } }) => {
1202
+ if (deviceId === "testId") {
1203
+ return new import_msw2.HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
1204
+ }
1205
+ if (mockApiResponses.devices.byId[deviceId]) {
1206
+ return import_msw2.HttpResponse.json({
1207
+ configured: { test: true, something: "else", aNumber: 42 },
1208
+ deployment_id: "config1",
1209
+ reported: { test: true, something: "else", aNumber: 42 },
1210
+ updated_ts: updatedTime,
1211
+ reported_ts: "2019-01-01T09:25:01.000Z"
1212
+ });
1213
+ }
1214
+ return new import_msw2.HttpResponse(null, { status: 512 });
1215
+ }),
1216
+ import_msw2.http.put(`${import_constants3.deviceConfig}/:deviceId`, async ({ params: { deviceId }, request }) => {
1217
+ const body = await request.text();
1218
+ if (body.includes("evilValue")) {
1219
+ return new import_msw2.HttpResponse(null, { status: 418 });
1220
+ }
1221
+ return new import_msw2.HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 201 : 513 });
1222
+ }),
1223
+ import_msw2.http.post(`${import_constants3.deviceConfig}/:deviceId/deploy`, ({ params: { deviceId } }) => {
1224
+ if (mockApiResponses.devices.byId[deviceId]) {
1225
+ return import_msw2.HttpResponse.json({ deployment_id: "config1" });
1226
+ }
1227
+ return new import_msw2.HttpResponse(null, { status: 514 });
1228
+ }),
1229
+ import_msw2.http.get(`${import_constants3.deviceConnect}/devices/:deviceId`, ({ params: { deviceId } }) => {
1230
+ if (deviceId === "testId") {
1231
+ return new import_msw2.HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
1232
+ }
1233
+ if (mockApiResponses.devices.byId[deviceId]) {
1234
+ return import_msw2.HttpResponse.json({ status: "connected", updated_ts: mockApiResponses.devices.byId[deviceId].updated_ts });
1235
+ }
1236
+ return new import_msw2.HttpResponse(null, { status: 512 });
1237
+ }),
1238
+ import_msw2.http.post(`${import_constants3.deviceConnect}/devices/:deviceId/:action`, ({ params: { deviceId, action } }) => {
1239
+ if (["check-update", "send-inventory"].includes(action) && mockApiResponses.devices.byId[deviceId]) {
1240
+ return new import_msw2.HttpResponse(null, { status: 202 });
1241
+ }
1242
+ return new import_msw2.HttpResponse(null, { status: 518 });
1243
+ }),
1244
+ import_msw2.http.get(`${import_constants3.iotManagerBaseURL}/devices/:deviceId/state`, ({ params: { deviceId } }) => {
1245
+ if (mockApiResponses.devices.byId[deviceId]) {
1246
+ return import_msw2.HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
1247
+ }
1248
+ return new import_msw2.HttpResponse(null, { status: 515 });
1249
+ }),
1250
+ import_msw2.http.put(`${import_constants3.iotManagerBaseURL}/devices/:deviceId/state/:integrationId`, async ({ params: { deviceId }, request }) => {
1251
+ const body = await request.json();
1252
+ if (mockApiResponses.devices.byId[deviceId] && body) {
1253
+ return import_msw2.HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
1254
+ }
1255
+ return new import_msw2.HttpResponse(null, { status: 516 });
1256
+ }),
1257
+ import_msw2.http.put(
1258
+ `${import_constants3.deviceConnect}/devices/:deviceId/upload`,
1259
+ ({ params: { deviceId } }) => new import_msw2.HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 200 : 517 })
1260
+ ),
1261
+ import_msw2.http.get(`${import_constants3.deviceAuthV2}/reports/devices`, () => import_msw2.HttpResponse.text("test,report"))
1262
+ ];
1263
+
1264
+ // src/requestHandlers/monitorHandlers.ts
1265
+ var import_constants4 = require("@northern.tech/utils/constants");
1266
+ var import_msw3 = require("msw");
1267
+ var monitorHandlers = [
1268
+ import_msw3.http.get(`${import_constants4.monitorApiUrlv1}/devices/:id/alerts`, () => new import_msw3.HttpResponse(JSON.stringify([]), { headers: { [import_constants4.headerNames.total]: 1 } })),
1269
+ import_msw3.http.get(`${import_constants4.monitorApiUrlv1}/devices/:id/alerts/latest`, () => import_msw3.HttpResponse.json([])),
1270
+ import_msw3.http.get(`${import_constants4.monitorApiUrlv1}/devices/:id/config`, ({ params: { id } }) => {
1271
+ if (id === mockApiResponses.devices.byId.a1.id) {
1272
+ return import_msw3.HttpResponse.json([{ something: "here" }]);
1273
+ }
1274
+ return import_msw3.HttpResponse.json([]);
1275
+ }),
1276
+ import_msw3.http.put(`${import_constants4.monitorApiUrlv1}/settings/global/channel/alerts/:channel/status`, async ({ params: { channel }, request }) => {
1277
+ const { enabled } = await request.json();
1278
+ if (Object.keys(import_constants4.alertChannels).includes(channel) && enabled !== void 0) {
1279
+ return new import_msw3.HttpResponse(null, { status: 200 });
1280
+ }
1281
+ return new import_msw3.HttpResponse(null, { status: 590 });
1282
+ })
1283
+ ];
1284
+
1285
+ // src/requestHandlers/organizationHandlers.ts
1286
+ var import_constants5 = require("@northern.tech/utils/constants");
1287
+ var import_msw4 = require("msw");
1288
+ var PLANS = {
1289
+ os: { id: "os", name: "Basic" },
1290
+ professional: { id: "professional", name: "Professional" },
1291
+ enterprise: { id: "enterprise", name: "Enterprise" }
1292
+ };
1293
+ var releasesSample = {
1294
+ lts: ["3.3"],
1295
+ releases: {
1296
+ "3.2": {
1297
+ "3.2.1": {
1298
+ release_date: "2022-02-02",
1299
+ release: "3.2.1",
1300
+ repos: [
1301
+ { name: "integration", version: "1.2.3" },
1302
+ { name: "mender", version: "3.2.1" },
1303
+ { name: "mender-artifact", version: "1.3.7" },
1304
+ { name: "service", version: "3.0.0" },
1305
+ { name: "other-service", version: "1.1.0" }
1306
+ ]
1307
+ },
1308
+ "3.2.0": {
1309
+ release_date: "2022-01-24",
1310
+ release: "3.2.0",
1311
+ repos: [
1312
+ { name: "service", version: "3.0.0" },
1313
+ { name: "another-service", version: "4.1.0" }
1314
+ ]
1315
+ }
1316
+ },
1317
+ "2.7": {
1318
+ "2.7.2": {
1319
+ release_date: "2021-11-04",
1320
+ release: "2.7.2",
1321
+ repos: [
1322
+ { name: "service", version: "1.1.0" },
1323
+ { name: "more-service", version: "1.0.2" }
1324
+ ]
1325
+ }
1326
+ },
1327
+ "1.0": {
1328
+ supported_until: "2018-02",
1329
+ "1.0.1": {
1330
+ release_date: "2017-04-03",
1331
+ release: "1.0.1",
1332
+ repos: [{ name: "service", version: "1.0.1" }]
1333
+ },
1334
+ "1.0.0": {
1335
+ release_date: "2017-02-16",
1336
+ release: "1.0.0",
1337
+ repos: [{ name: "mono-service", version: "1.0.0" }]
1338
+ }
1339
+ }
1340
+ },
1341
+ saas: [
1342
+ { tag: "saas-v2022.03.10", date: "2022-03-09" },
1343
+ { tag: "saas-v2020.09.25", date: "2020-09-24" },
1344
+ { tag: "saas-v2020.07.09", date: "2020-07-09" }
1345
+ ]
1346
+ };
1347
+ var tagsSample = [{ name: "saas-v2023.05.02", more: "here" }];
1348
+ var signupHandler = async ({ request }) => {
1349
+ const signup = await request.json();
1350
+ if (["email", "organization", "plan", "tos"].every((item) => !!signup[item])) {
1351
+ return import_msw4.HttpResponse.text("test");
1352
+ }
1353
+ return new import_msw4.HttpResponse(null, { status: 400 });
1354
+ };
1355
+ var organizationHandlers = [
1356
+ import_msw4.http.get("/tags.json", () => import_msw4.HttpResponse.json(tagsSample)),
1357
+ import_msw4.http.get("/versions.json", () => import_msw4.HttpResponse.json(releasesSample)),
1358
+ import_msw4.http.get(`${import_constants5.tenantadmApiUrlv1}/user/tenant`, () => import_msw4.HttpResponse.json(mockApiResponses.organization.organization)),
1359
+ import_msw4.http.put(`${import_constants5.tenantadmApiUrlv2}/tenants/:tenantId/child`, () => new import_msw4.HttpResponse(null, { status: 200 })),
1360
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/tenants/:tenantId/cancel`, () => new import_msw4.HttpResponse(null, { status: 200 })),
1361
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
1362
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/tenants`, () => new import_msw4.HttpResponse(null, { status: 200 })),
1363
+ import_msw4.http.post(`https://hosted.mender.io${import_constants5.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
1364
+ import_msw4.http.get(`${import_constants5.tenantadmApiUrlv2}/tenants`, () => new import_msw4.HttpResponse([])),
1365
+ import_msw4.http.get(`${import_constants5.tenantadmApiUrlv2}/billing`, () => import_msw4.HttpResponse.json({ card: { last4: "7890", exp_month: 1, exp_year: 2024, brand: "testCorp" } })),
1366
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/billing/card`, () => import_msw4.HttpResponse.json({ intent_id: mockApiResponses.organization.intentId, secret: "testSecret" })),
1367
+ import_msw4.http.post(
1368
+ `${import_constants5.tenantadmApiUrlv2}/billing/card/:intentId/confirm`,
1369
+ ({ params: { intentId } }) => new import_msw4.HttpResponse(null, { status: intentId == mockApiResponses.organization.intentId ? 200 : 540 })
1370
+ ),
1371
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/tenants/:tenantId/upgrade/:status`, async ({ params: { status, tenantId }, request }) => {
1372
+ if (tenantId != mockApiResponses.organization.organization.id || !["cancel", "complete", "start"].includes(status)) {
1373
+ return new import_msw4.HttpResponse(null, { status: 541 });
1374
+ }
1375
+ if (status === "start") {
1376
+ return import_msw4.HttpResponse.json({ secret: "testSecret" });
1377
+ }
1378
+ let plan;
1379
+ try {
1380
+ const body = await request.json();
1381
+ plan = body.plan;
1382
+ } catch {
1383
+ }
1384
+ if (plan && !Object.keys(PLANS).includes(plan)) {
1385
+ return new import_msw4.HttpResponse(null, { status: 542 });
1386
+ }
1387
+ return new import_msw4.HttpResponse(null, { status: 200 });
1388
+ }),
1389
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/tenants/:tenantId/plan`, async ({ params: { tenantId }, request }) => {
1390
+ const body = await request.json();
1391
+ const expectedKeys = ["current_plan", "requested_plan", "current_addons", "requested_addons", "user_message"];
1392
+ if (tenantId != mockApiResponses.organization.organization.id || !Object.keys(body).every((key) => expectedKeys.includes(key))) {
1393
+ return new import_msw4.HttpResponse(null, { status: 544 });
1394
+ }
1395
+ if (body.requested_plan && !Object.values(PLANS).some((item) => item.name === body.requested_plan)) {
1396
+ return new import_msw4.HttpResponse(null, { status: 545 });
1397
+ }
1398
+ return new import_msw4.HttpResponse(null, { status: 200 });
1399
+ }),
1400
+ import_msw4.http.post(`${import_constants5.tenantadmApiUrlv2}/contact/support`, async ({ request }) => {
1401
+ const { subject, body } = await request.json();
1402
+ if (!(subject && body)) {
1403
+ return new import_msw4.HttpResponse(null, { status: 543 });
1404
+ }
1405
+ return new import_msw4.HttpResponse(null, { status: 200 });
1406
+ }),
1407
+ import_msw4.http.get(`${import_constants5.auditLogsApiUrl}/logs`, ({ request }) => {
1408
+ const { searchParams } = new URL(request.url);
1409
+ const perPage = Number(searchParams.get("per_page"));
1410
+ if (perPage === 500) {
1411
+ return import_msw4.HttpResponse.json([
1412
+ { meta: mockApiResponses.organization.auditlog.events[2].meta, time: mockApiResponses.organization.auditlog.events[1].time, action: "close_terminal" }
1413
+ ]);
1414
+ }
1415
+ return new import_msw4.HttpResponse(JSON.stringify(mockApiResponses.organization.auditlog.events), {
1416
+ headers: { [import_constants5.headerNames.total]: mockApiResponses.organization.auditlog.events.length }
1417
+ });
1418
+ }),
1419
+ import_msw4.http.get(
1420
+ `${import_constants5.auditLogsApiUrl}/logs/export`,
1421
+ () => import_msw4.HttpResponse.text(`action,actor.id,actor.type,actor.email,actor.identity_data,object.id,object.type,object.user.email,object.deployment.name,object.deployment.artifact_name,change
1422
+ update,5c56c2ed-2a9a-5de9-bb86-cf38b3d4a5e1,user,test@example.coim,,067f23a9-76a5-5585-b119-32402a120978,user,test@example.com,,,"Update user 067f23a9-76a5-5585-b119-32402a120978 (test@example.com).
1423
+ Diff:
1424
+ --- Original
1425
+ +++ Current
1426
+ @@ -9 +9,2 @@
1427
+ - ""RBAC_ROLE_OBSERVER""
1428
+ + ""RBAC_ROLE_OBSERVER"",
1429
+ + ""RBAC_ROLE_PERMIT_ALL""
1430
+ "
1431
+ `)
1432
+ ),
1433
+ import_msw4.http.get(
1434
+ `${import_constants5.iotManagerBaseURL}/integrations`,
1435
+ () => import_msw4.HttpResponse.json([
1436
+ { connection_string: "something_else", id: 1, provider: "iot-hub" },
1437
+ { id: 2, provider: "iot-core", something: "new" }
1438
+ ])
1439
+ ),
1440
+ import_msw4.http.post(`${import_constants5.iotManagerBaseURL}/integrations`, () => import_msw4.HttpResponse.json([{ connection_string: "something_else", provider: "iot-hub" }])),
1441
+ import_msw4.http.put(`${import_constants5.iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
1442
+ if (!integrationId) {
1443
+ return new import_msw4.HttpResponse(null, { status: 547 });
1444
+ }
1445
+ return new import_msw4.HttpResponse(null, { status: 200 });
1446
+ }),
1447
+ import_msw4.http.put(`${import_constants5.iotManagerBaseURL}/integrations/:integrationId/credentials`, ({ params: { integrationId } }) => {
1448
+ if (!integrationId) {
1449
+ return new import_msw4.HttpResponse(null, { status: 548 });
1450
+ }
1451
+ return new import_msw4.HttpResponse(null, { status: 200 });
1452
+ }),
1453
+ import_msw4.http.delete(`${import_constants5.iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
1454
+ if (!integrationId) {
1455
+ return new import_msw4.HttpResponse(null, { status: 549 });
1456
+ }
1457
+ return new import_msw4.HttpResponse(null, { status: 200 });
1458
+ }),
1459
+ import_msw4.http.get(`${import_constants5.iotManagerBaseURL}/events`, ({ request }) => {
1460
+ const { searchParams } = new URL(request.url);
1461
+ const page = Number(searchParams.get("page"));
1462
+ const perPage = Number(searchParams.get("per_page"));
1463
+ return import_msw4.HttpResponse.json(webhookEvents.slice(page - 1, page * perPage));
1464
+ }),
1465
+ import_msw4.http.get(
1466
+ import_constants5.ssoIdpApiUrlv1,
1467
+ () => import_msw4.HttpResponse.json([
1468
+ { id: "1", issuer: "https://samltest.id/saml/idp", valid_until: "2038-08-24T21:14:09Z" },
1469
+ { id: "2", issuer: "https://samltest2.id/saml/idp", valid_until: "2030-10-24T21:14:09Z" }
1470
+ ])
1471
+ ),
1472
+ import_msw4.http.post(import_constants5.ssoIdpApiUrlv1, () => new import_msw4.HttpResponse(null, { status: 200 })),
1473
+ import_msw4.http.get(`${import_constants5.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => {
1474
+ if (!configId) {
1475
+ return new import_msw4.HttpResponse(null, { status: 550 });
1476
+ }
1477
+ return import_msw4.HttpResponse.json({ email: "user@acme.com", password: "mypass1234", login: { google: "bob@gmail.com" }, config: "<div>not quite right</div>" });
1478
+ }),
1479
+ import_msw4.http.put(`${import_constants5.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new import_msw4.HttpResponse(null, { status: configId ? 200 : 551 })),
1480
+ import_msw4.http.delete(`${import_constants5.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new import_msw4.HttpResponse(null, { status: configId ? 200 : 552 }))
1481
+ ];
1482
+
1483
+ // src/requestHandlers/releaseHandlers.ts
1484
+ var import_constants6 = require("@northern.tech/utils/constants");
1485
+ var import_helpers = require("@northern.tech/utils/helpers");
1486
+ var import_msw5 = require("msw");
1487
+ var releaseHandlers = [
1488
+ import_msw5.http.get(`${import_constants6.deploymentsApiUrl}/artifacts/:id/download`, () => import_msw5.HttpResponse.json({ uri: "https://testlocation.com/artifact.mender" })),
1489
+ import_msw5.http.delete(
1490
+ `${import_constants6.deploymentsApiUrl}/artifacts/:id`,
1491
+ ({ params: { id } }) => new import_msw5.HttpResponse(null, { status: id === mockApiResponses.releases.byId.r1.artifacts[0].id ? 200 : 591 })
1492
+ ),
1493
+ import_msw5.http.put(`${import_constants6.deploymentsApiUrl}/artifacts/:id`, async ({ params: { id }, request }) => {
1494
+ const { description } = await request.json();
1495
+ return new import_msw5.HttpResponse(null, { status: id === mockApiResponses.releases.byId.r1.artifacts[0].id && description ? 200 : 592 });
1496
+ }),
1497
+ import_msw5.http.post(`${import_constants6.deploymentsApiUrl}/artifacts/generate`, () => new import_msw5.HttpResponse(null, { status: 200 })),
1498
+ import_msw5.http.post(`${import_constants6.deploymentsApiUrl}/artifacts`, () => new import_msw5.HttpResponse(null, { status: 200 })),
1499
+ import_msw5.http.get(`${import_constants6.deploymentsApiUrlV2}/deployments/releases`, async ({ request }) => {
1500
+ const { searchParams } = new URL(request.url);
1501
+ const page = Number(searchParams.get("page"));
1502
+ const perPage = Number(searchParams.get("per_page"));
1503
+ if (!page || ![1, 10, 20, 50, 100, 250, 500].includes(perPage)) {
1504
+ return new import_msw5.HttpResponse(null, { status: 593 });
1505
+ }
1506
+ if (searchParams.get("device_type")) {
1507
+ return import_msw5.HttpResponse.json([]);
1508
+ }
1509
+ if (page == 42) {
1510
+ return new import_msw5.HttpResponse(JSON.stringify([mockApiResponses.releases.byId.r1]), { headers: { [import_constants6.headerNames.total]: 1 } });
1511
+ }
1512
+ const sort = searchParams.get("sort");
1513
+ const releaseListSection = releasesList.sort((0, import_helpers.customSort)(sort.includes(import_constants6.SORTING_OPTIONS.desc), "name")).slice((page - 1) * perPage, page * perPage);
1514
+ if (page === 1 && perPage === 1 && searchParams.get("name")) {
1515
+ return import_msw5.HttpResponse.json([mockApiResponses.releases.byId.r1]);
1516
+ }
1517
+ if (searchParams.get("name")) {
1518
+ return new import_msw5.HttpResponse(JSON.stringify(releaseListSection), { headers: { [import_constants6.headerNames.total]: 1234 } });
1519
+ }
1520
+ return new import_msw5.HttpResponse(JSON.stringify(releaseListSection), { headers: { [import_constants6.headerNames.total]: releasesList.length } });
1521
+ }),
1522
+ import_msw5.http.get(`${import_constants6.deploymentsApiUrlV2}/deployments/releases/:name`, () => import_msw5.HttpResponse.json(mockApiResponses.releases.byId.r1)),
1523
+ import_msw5.http.get(`${import_constants6.deploymentsApiUrlV2}/releases/all/tags`, () => import_msw5.HttpResponse.json(["foo", "bar"])),
1524
+ import_msw5.http.get(`${import_constants6.deploymentsApiUrlV2}/releases/all/types`, () => import_msw5.HttpResponse.json(["single-file", "not-this"])),
1525
+ import_msw5.http.put(`${import_constants6.deploymentsApiUrlV2}/deployments/releases/:name/tags`, async ({ params: { name }, request }) => {
1526
+ const tags = await request.json();
1527
+ if (name && tags.every((i) => i && i.toString() === i)) {
1528
+ return new import_msw5.HttpResponse(null, { status: 200 });
1529
+ }
1530
+ return new import_msw5.HttpResponse(null, { status: 593 });
1531
+ }),
1532
+ import_msw5.http.patch(`${import_constants6.deploymentsApiUrlV2}/deployments/releases/:name`, async ({ params: { name }, request }) => {
1533
+ const { notes } = await request.json();
1534
+ return new import_msw5.HttpResponse(null, { status: name && notes.length ? 200 : 594 });
1535
+ })
1536
+ ];
1537
+
1538
+ // src/requestHandlers/userHandlers.ts
1539
+ var import_constants7 = require("@northern.tech/utils/constants");
1540
+ var import_msw6 = require("msw");
1541
+ var userHandlers = [
1542
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/auth/login`, ({ request }) => {
1543
+ const authHeader = request.headers.get("authorization");
1544
+ const authInfo = atob(authHeader?.split(" ")[1]);
1545
+ const [user, password] = authInfo.split(":");
1546
+ if (!password) {
1547
+ return import_msw6.HttpResponse.json({ id: testSsoId, kind: "sso/saml" });
1548
+ } else if (password !== defaultPassword) {
1549
+ return new import_msw6.HttpResponse(null, { status: 401 });
1550
+ } else if (user.includes("limited")) {
1551
+ return new import_msw6.HttpResponse("limitedToken", { headers: { "Content-Type": import_constants7.APPLICATION_JWT_CONTENT_TYPE } });
1552
+ } else if (user.includes("2fa")) {
1553
+ return new import_msw6.HttpResponse(JSON.stringify({ error: "2fa needed" }), { status: 401 });
1554
+ }
1555
+ return new import_msw6.HttpResponse(token, { headers: { "Content-Type": import_constants7.APPLICATION_JWT_CONTENT_TYPE } });
1556
+ }),
1557
+ import_msw6.http.get(`https://hosted.mender.io${import_constants7.useradmApiUrl}/auth/magic/:id`, ({ params: { id } }) => {
1558
+ if (id) {
1559
+ return new import_msw6.HttpResponse("test", { headers: { "Set-Cookie": "JWT=test" } });
1560
+ }
1561
+ return new import_msw6.HttpResponse(null, { status: 400 });
1562
+ }),
1563
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/auth/logout`, () => new import_msw6.HttpResponse(null, { status: 200 })),
1564
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/auth/password-reset/:status`, async ({ params: { status }, request }) => {
1565
+ const { email, secret_hash, password } = await request.json();
1566
+ if (!["start", "complete"].includes(status) && ![email, secret_hash, password].some((item) => item)) {
1567
+ return new import_msw6.HttpResponse(null, { status: 560 });
1568
+ }
1569
+ if (status === "start" && email) {
1570
+ return new import_msw6.HttpResponse(null, { status: 200 });
1571
+ }
1572
+ if (status === "complete" && secret_hash && password) {
1573
+ return new import_msw6.HttpResponse(null, { status: 200 });
1574
+ }
1575
+ return new import_msw6.HttpResponse(null, { status: 561 });
1576
+ }),
1577
+ import_msw6.http.put(`${import_constants7.useradmApiUrl}/2faverify`, async ({ request }) => {
1578
+ const { token2fa } = await request.json();
1579
+ if (!token2fa) {
1580
+ return new import_msw6.HttpResponse(null, { status: 562 });
1581
+ }
1582
+ return new import_msw6.HttpResponse(null, { status: 200 });
1583
+ }),
1584
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/users`, () => import_msw6.HttpResponse.json(Object.values(mockApiResponses.users.byId))),
1585
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/users/me`, ({ request }) => {
1586
+ const authHeader = request.headers.get("authorization");
1587
+ if (authHeader?.includes("limited")) {
1588
+ return new import_msw6.HttpResponse(JSON.stringify({ error: "forbidden by role-based access control" }), { status: 403 });
1589
+ }
1590
+ return import_msw6.HttpResponse.json(mockApiResponses.users.byId[userId]);
1591
+ }),
1592
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/users/:userId`, ({ params: { userId: userId2 } }) => {
1593
+ if (userId2 === "me" || mockApiResponses.users.byId[userId2]) {
1594
+ const user = userId2 === "me" ? userId : userId2;
1595
+ return import_msw6.HttpResponse.json(mockApiResponses.users.byId[user]);
1596
+ }
1597
+ return new import_msw6.HttpResponse(null, { status: 563 });
1598
+ }),
1599
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/users`, async ({ request }) => {
1600
+ const { email, password } = await request.json();
1601
+ if (email === "test@test.com" || [email, password].every((value) => value)) {
1602
+ return import_msw6.HttpResponse.json(mockApiResponses.users.byId.a1);
1603
+ }
1604
+ return new import_msw6.HttpResponse(null, { status: 564 });
1605
+ }),
1606
+ import_msw6.http.put(`${import_constants7.useradmApiUrl}/users/:userId`, async ({ params: { userId: userId2 }, request }) => {
1607
+ const { email, password, current_password } = await request.json();
1608
+ if (current_password === "bad_password") {
1609
+ return new import_msw6.HttpResponse(null, { status: 401 });
1610
+ }
1611
+ if (mockApiResponses.users.byId[userId2] && [email, password].some((value) => Object.values(mockApiResponses.users.byId[userId2]).includes(value)) || email === "test@test.com") {
1612
+ return new import_msw6.HttpResponse(null, { status: 200 });
1613
+ }
1614
+ return new import_msw6.HttpResponse(null, { status: 565 });
1615
+ }),
1616
+ import_msw6.http.delete(
1617
+ `${import_constants7.useradmApiUrl}/users/:userId`,
1618
+ ({ params: { userId: userId2 } }) => new import_msw6.HttpResponse(null, { status: mockApiResponses.users.byId[userId2] ? 200 : 566 })
1619
+ ),
1620
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/roles`, () => import_msw6.HttpResponse.json(rbacRoles)),
1621
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/roles`, async ({ request }) => {
1622
+ const { name, permissions } = await request.json();
1623
+ if ([name, permissions].every((value) => value) && permissions.every((permission) => permission.action && permission.object && permission.object.type && permission.object.value)) {
1624
+ return new import_msw6.HttpResponse(null, { status: 200 });
1625
+ }
1626
+ return new import_msw6.HttpResponse(null, { status: 567 });
1627
+ }),
1628
+ import_msw6.http.put(`${import_constants7.useradmApiUrl}/roles/:roleId`, async ({ params: { roleId }, request }) => {
1629
+ const { description, name, permissions } = await request.json();
1630
+ if (mockApiResponses.users.rolesById[roleId] && [description, name, permissions].some((value) => value)) {
1631
+ return new import_msw6.HttpResponse(null, { status: 200 });
1632
+ }
1633
+ return new import_msw6.HttpResponse(null, { status: 568 });
1634
+ }),
1635
+ import_msw6.http.delete(
1636
+ `${import_constants7.useradmApiUrl}/roles/:roleId`,
1637
+ ({ params: { roleId } }) => new import_msw6.HttpResponse(null, { status: mockApiResponses.users.rolesById[roleId] ? 200 : 569 })
1638
+ ),
1639
+ import_msw6.http.get(`${import_constants7.useradmApiUrlv2}/roles`, () => import_msw6.HttpResponse.json(rbacRoles)),
1640
+ import_msw6.http.get(`${import_constants7.useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId } }) => {
1641
+ if (mockApiResponses.users.rolesById[roleId]) {
1642
+ return import_msw6.HttpResponse.json(mockApiResponses.users.rolesById[roleId]);
1643
+ }
1644
+ return new import_msw6.HttpResponse(null, { status: 571 });
1645
+ }),
1646
+ import_msw6.http.post(`${import_constants7.useradmApiUrlv2}/roles`, async ({ request }) => {
1647
+ const { name, permission_sets_with_scope } = await request.json();
1648
+ if (!!name && permission_sets_with_scope.every((permission) => permission.name && permissionSets.find((permissionSet) => permissionSet.name === permission.name))) {
1649
+ return new import_msw6.HttpResponse(null, { status: 200 });
1650
+ }
1651
+ return new import_msw6.HttpResponse(null, { status: 572 });
1652
+ }),
1653
+ import_msw6.http.put(`${import_constants7.useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId }, request }) => {
1654
+ const { description, name, permission_sets_with_scope } = await request.json();
1655
+ if (mockApiResponses.users.rolesById[roleId] && [description, name, permission_sets_with_scope].some((value) => value)) {
1656
+ return new import_msw6.HttpResponse(null, { status: 200 });
1657
+ }
1658
+ return new import_msw6.HttpResponse(null, { status: 573 });
1659
+ }),
1660
+ import_msw6.http.delete(`${import_constants7.useradmApiUrlv2}/roles/:roleId`, ({ params: { roleId } }) => {
1661
+ if (mockApiResponses.users.rolesById[roleId]) {
1662
+ return new import_msw6.HttpResponse(null, { status: 200 });
1663
+ }
1664
+ return new import_msw6.HttpResponse(null, { status: 574 });
1665
+ }),
1666
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/settings`, () => import_msw6.HttpResponse.json(mockApiResponses.users.globalSettings)),
1667
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/settings`, () => new import_msw6.HttpResponse(null, { status: 200 })),
1668
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/settings/me`, () => import_msw6.HttpResponse.json(mockApiResponses.users.userSettings)),
1669
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/settings/me`, () => new import_msw6.HttpResponse(null, { status: 200 })),
1670
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/settings/tokens`, () => import_msw6.HttpResponse.json(accessTokens)),
1671
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/settings/tokens`, () => import_msw6.HttpResponse.json("aNewToken")),
1672
+ import_msw6.http.delete(
1673
+ `${import_constants7.useradmApiUrl}/settings/tokens/:tokenId`,
1674
+ ({ params: { tokenId } }) => new import_msw6.HttpResponse(null, { status: tokenId === "some-id-1" ? 200 : 577 })
1675
+ ),
1676
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/2faqr`, () => import_msw6.HttpResponse.json({ qr: btoa("test") })),
1677
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/users/:userId/2fa/enable`, ({ params: { userId: userId2 } }) => {
1678
+ if (mockApiResponses.users.byId[userId2] || userId2 === "me") {
1679
+ return new import_msw6.HttpResponse(null, { status: 200 });
1680
+ }
1681
+ return new import_msw6.HttpResponse(null, { status: 570 });
1682
+ }),
1683
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/users/:userId/2fa/disable`, ({ params: { userId: userId2 } }) => {
1684
+ if (mockApiResponses.users.byId[userId2] || userId2 === "me") {
1685
+ return new import_msw6.HttpResponse(null, { status: 200 });
1686
+ }
1687
+ return new import_msw6.HttpResponse(null, { status: 571 });
1688
+ }),
1689
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/auth/verify-email/start`, () => new import_msw6.HttpResponse(null, { status: 200 })),
1690
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/auth/verify-email/complete`, async ({ request }) => {
1691
+ const { secret_hash } = await request.json();
1692
+ return new import_msw6.HttpResponse(null, { status: secret_hash === "superSecret" ? 200 : 576 });
1693
+ }),
1694
+ import_msw6.http.get(`${import_constants7.useradmApiUrlv2}/permission_sets`, () => import_msw6.HttpResponse.json(permissionSets)),
1695
+ import_msw6.http.post(`${import_constants7.useradmApiUrl}/users/:userId/assign`, async ({ request }) => {
1696
+ const { tenant_ids } = await request.json();
1697
+ return new import_msw6.HttpResponse(null, { status: tenant_ids.length ? 200 : 577 });
1698
+ }),
1699
+ import_msw6.http.get(`${import_constants7.useradmApiUrl}/users/tenants/:tenantId/token`, () => import_msw6.HttpResponse.text("differentToken"))
1700
+ ];
1701
+
1702
+ // src/requestHandlers/requestHandlers.ts
1703
+ var testLocation = "/test";
1704
+ var baseHandlers = [
1705
+ import_msw7.http.get(testLocation, () => new import_msw7.HttpResponse(null, { status: 200 })),
1706
+ import_msw7.http.post(testLocation, () => import_msw7.HttpResponse.json({})),
1707
+ import_msw7.http.put(testLocation, () => import_msw7.HttpResponse.json({})),
1708
+ import_msw7.http.delete(testLocation, () => import_msw7.HttpResponse.json({}))
1709
+ ];
1710
+ var handlers = [...baseHandlers, ...deploymentHandlers, ...deviceHandlers, ...monitorHandlers, ...organizationHandlers, ...releaseHandlers, ...userHandlers];
1711
+ var requestHandlers_default = handlers;
1712
+ //# sourceMappingURL=requestHandlers.cjs.map