@northern.tech/testing 0.8.1 → 0.8.3

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