@northern.tech/testing 0.7.1 → 0.8.1

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/package.json +3 -4
  2. package/dist/baseTestConfig.json +0 -17
  3. package/dist/chunk-4UV4MWUU.js +0 -188
  4. package/dist/chunk-4UV4MWUU.js.map +0 -1
  5. package/dist/chunk-5GIOT4M6.js +0 -161
  6. package/dist/chunk-5GIOT4M6.js.map +0 -1
  7. package/dist/chunk-AQYKNNMJ.js +0 -239
  8. package/dist/chunk-AQYKNNMJ.js.map +0 -1
  9. package/dist/chunk-CT35JRBC.js +0 -893
  10. package/dist/chunk-CT35JRBC.js.map +0 -1
  11. package/dist/chunk-HRGVXWMH.js +0 -17
  12. package/dist/chunk-HRGVXWMH.js.map +0 -1
  13. package/dist/chunk-RG3ICJW5.js +0 -34
  14. package/dist/chunk-RG3ICJW5.js.map +0 -1
  15. package/dist/chunk-ROSMRKMF.js +0 -265
  16. package/dist/chunk-ROSMRKMF.js.map +0 -1
  17. package/dist/chunk-TVJ6K2KG.js +0 -318
  18. package/dist/chunk-TVJ6K2KG.js.map +0 -1
  19. package/dist/chunk-WFNPT672.js +0 -29
  20. package/dist/chunk-WFNPT672.js.map +0 -1
  21. package/dist/mockData.cjs +0 -926
  22. package/dist/mockData.cjs.map +0 -1
  23. package/dist/mockData.d.cts +0 -596
  24. package/dist/mockData.d.ts +0 -596
  25. package/dist/mockData.js +0 -45
  26. package/dist/mockData.js.map +0 -1
  27. package/dist/requestHandlers/deploymentHandlers.cjs +0 -1045
  28. package/dist/requestHandlers/deploymentHandlers.cjs.map +0 -1
  29. package/dist/requestHandlers/deploymentHandlers.d.cts +0 -5
  30. package/dist/requestHandlers/deploymentHandlers.d.ts +0 -5
  31. package/dist/requestHandlers/deploymentHandlers.js +0 -8
  32. package/dist/requestHandlers/deploymentHandlers.js.map +0 -1
  33. package/dist/requestHandlers/deviceHandlers.cjs +0 -1113
  34. package/dist/requestHandlers/deviceHandlers.cjs.map +0 -1
  35. package/dist/requestHandlers/deviceHandlers.d.cts +0 -20
  36. package/dist/requestHandlers/deviceHandlers.d.ts +0 -20
  37. package/dist/requestHandlers/deviceHandlers.js +0 -12
  38. package/dist/requestHandlers/deviceHandlers.js.map +0 -1
  39. package/dist/requestHandlers/monitorHandlers.cjs +0 -835
  40. package/dist/requestHandlers/monitorHandlers.cjs.map +0 -1
  41. package/dist/requestHandlers/monitorHandlers.d.cts +0 -5
  42. package/dist/requestHandlers/monitorHandlers.d.ts +0 -5
  43. package/dist/requestHandlers/monitorHandlers.js +0 -8
  44. package/dist/requestHandlers/monitorHandlers.js.map +0 -1
  45. package/dist/requestHandlers/organizationHandlers.cjs +0 -1086
  46. package/dist/requestHandlers/organizationHandlers.cjs.map +0 -1
  47. package/dist/requestHandlers/organizationHandlers.d.cts +0 -5
  48. package/dist/requestHandlers/organizationHandlers.d.ts +0 -5
  49. package/dist/requestHandlers/organizationHandlers.js +0 -8
  50. package/dist/requestHandlers/organizationHandlers.js.map +0 -1
  51. package/dist/requestHandlers/releaseHandlers.cjs +0 -966
  52. package/dist/requestHandlers/releaseHandlers.cjs.map +0 -1
  53. package/dist/requestHandlers/releaseHandlers.d.cts +0 -5
  54. package/dist/requestHandlers/releaseHandlers.d.ts +0 -5
  55. package/dist/requestHandlers/releaseHandlers.js +0 -8
  56. package/dist/requestHandlers/releaseHandlers.js.map +0 -1
  57. package/dist/requestHandlers/requestHandlers.cjs +0 -1975
  58. package/dist/requestHandlers/requestHandlers.cjs.map +0 -1
  59. package/dist/requestHandlers/requestHandlers.d.cts +0 -5
  60. package/dist/requestHandlers/requestHandlers.d.ts +0 -5
  61. package/dist/requestHandlers/requestHandlers.js +0 -35
  62. package/dist/requestHandlers/requestHandlers.js.map +0 -1
  63. package/dist/requestHandlers/userHandlers.cjs +0 -994
  64. package/dist/requestHandlers/userHandlers.cjs.map +0 -1
  65. package/dist/requestHandlers/userHandlers.d.cts +0 -5
  66. package/dist/requestHandlers/userHandlers.d.ts +0 -5
  67. package/dist/requestHandlers/userHandlers.js +0 -8
  68. package/dist/requestHandlers/userHandlers.js.map +0 -1
  69. package/dist/setupTests.cjs +0 -996
  70. package/dist/setupTests.cjs.map +0 -1
  71. package/dist/setupTests.d.cts +0 -77
  72. package/dist/setupTests.d.ts +0 -77
  73. package/dist/setupTests.js +0 -138
  74. package/dist/setupTests.js.map +0 -1
  75. package/dist/theme/light.cjs +0 -41
  76. package/dist/theme/light.cjs.map +0 -1
  77. package/dist/theme/light.d.cts +0 -12
  78. package/dist/theme/light.d.ts +0 -12
  79. package/dist/theme/light.js +0 -7
  80. package/dist/theme/light.js.map +0 -1
  81. package/dist/utils.cjs +0 -71
  82. package/dist/utils.cjs.map +0 -1
  83. package/dist/utils.d.cts +0 -69
  84. package/dist/utils.d.ts +0 -69
  85. package/dist/utils.js +0 -12
  86. package/dist/utils.js.map +0 -1
@@ -1,994 +0,0 @@
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: "POST", value: "^/api/management/v1/reporting/devices/search" } },
568
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/(deployments|devauth|inventory|deviceconfig|devicemonitor)/" } },
569
- { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+$" } }
570
- ],
571
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
572
- },
573
- {
574
- ...import_constants.defaultPermissionSets.ManageDevices,
575
- action: import_constants.uiPermissionsById.manage.title,
576
- object: permissionSetObjectTypes.groups,
577
- description: "Set of permissions which allows user to manage devices",
578
- permissions: [
579
- { action: "http", object: { type: "POST", value: commonEndpoints.deviceManagement } },
580
- { action: "http", object: { type: "PUT", value: commonEndpoints.deviceManagement } },
581
- { action: "http", object: { type: "DELETE", value: commonEndpoints.deviceManagement } }
582
- ],
583
- supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
584
- },
585
- {
586
- ...import_constants.defaultPermissionSets.ReadReleases,
587
- action: import_constants.uiPermissionsById.read.title,
588
- object: permissionSetObjectTypes.releases,
589
- description: "Set of permissions which allows user to view releases",
590
- permissions: [
591
- { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
592
- { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
593
- { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
594
- ]
595
- },
596
- {
597
- name: "almostAdmin",
598
- object: permissionSetObjectTypes.empty,
599
- description: "Set containing all the permissions.",
600
- permissions: [
601
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/auditlogs/.*" } },
602
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/.*" } },
603
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/config/.*" } },
604
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/.*" } },
605
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/releases/.*" } },
606
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/devauth/.*" } },
607
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/.*" } },
608
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/.*" } },
609
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/devices" } },
610
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/inventory/.*" } },
611
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/iot-manager/.*" } },
612
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/monitor/.*" } },
613
- { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/.*" } }
614
- ]
615
- }
616
- ];
617
- var rbacRoles = [
618
- {
619
- name: "dyn",
620
- description: "",
621
- permissions: [
622
- { action: "CREATE_DEPLOYMENT", object: { type: "DEVICE_GROUP", value: "dyn" } },
623
- { action: "VIEW_DEVICE", object: { type: "DEVICE_GROUP", value: "dyn" } }
624
- ]
625
- },
626
- { name: "asdasd", description: "123", permissions: [{ action: "http", object: { type: "any", value: "/api/management/v1/useradm/.*" } }] },
627
- {
628
- name: "141sasd",
629
- description: "1313adg",
630
- permission_sets_with_scope: [
631
- { ...import_constants.defaultPermissionSets.ReadDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
632
- { ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
633
- { ...import_constants.defaultPermissionSets.ManageUsers }
634
- ]
635
- },
636
- {
637
- name: "kljlkk",
638
- description: "lkl",
639
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } }]
640
- },
641
- {
642
- name: "yyyyy",
643
- description: "asd",
644
- permission_sets_with_scope: [
645
- { ...import_constants.defaultPermissionSets.ManageDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["dockerclient"] } },
646
- { ...import_constants.defaultPermissionSets.ManageReleases }
647
- ]
648
- },
649
- {
650
- name: "RBAC_ROLE_DEPLOYMENTS_MANAGER",
651
- description: "Intended for users responsible for managing deployments, this role can create and abort deployments",
652
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.DeployToDevices }]
653
- },
654
- {
655
- name: "RBAC_ROLE_REMOTE_TERMINAL",
656
- description: `Intended for tech support accounts, this role can access the devices' Remote Terminal.`,
657
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices }]
658
- },
659
- { name: "RBAC_ROLE_PERMIT_ALL", description: "", permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.SuperUser }] },
660
- {
661
- name: "RBAC_ROLE_OBSERVER",
662
- 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.",
663
- permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ReadReleases }, { ...import_constants.defaultPermissionSets.ReadDevices }]
664
- },
665
- {
666
- name: "RBAC_ROLE_CI",
667
- 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.",
668
- permission_sets_with_scope: [
669
- { ...import_constants.defaultPermissionSets.ReadReleases },
670
- { ...import_constants.defaultPermissionSets.ManageReleases },
671
- { ...import_constants.defaultPermissionSets.UploadArtifacts }
672
- ]
673
- },
674
- {
675
- name: "almostAdmin",
676
- description: "almost admin rights",
677
- permissions: permissionSets.find((item) => item.name === "almostAdmin")?.permissions
678
- },
679
- {
680
- name: "almostAdminNew",
681
- description: "almost admin rights",
682
- permission_sets_with_scope: Object.values(import_constants.defaultPermissionSets)
683
- }
684
- ];
685
- var expectedParsedRoles = {
686
- "141sasd": {
687
- editable: true,
688
- isCustom: void 0,
689
- uiPermissions: {
690
- ...import_constants.emptyUiPermissions,
691
- groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] },
692
- userManagement: [import_constants.uiPermissionsById.manage.value]
693
- }
694
- },
695
- asdasd: {
696
- editable: false,
697
- isCustom: true,
698
- uiPermissions: { ...import_constants.emptyUiPermissions, userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] }
699
- },
700
- dyn: {
701
- editable: false,
702
- isCustom: true,
703
- uiPermissions: {
704
- ...import_constants.emptyUiPermissions,
705
- deployments: [import_constants.uiPermissionsById.deploy.value],
706
- groups: { dyn: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value] }
707
- }
708
- },
709
- kljlkk: {
710
- editable: true,
711
- isCustom: false,
712
- uiPermissions: { ...import_constants.emptyUiPermissions, groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] } }
713
- },
714
- yyyyy: {
715
- editable: true,
716
- isCustom: void 0,
717
- uiPermissions: {
718
- ...import_constants.emptyUiPermissions,
719
- groups: { dockerclient: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] },
720
- releases: { [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value] }
721
- }
722
- },
723
- almostAdmin: {
724
- editable: false,
725
- isCustom: true,
726
- uiPermissions: {
727
- ...import_constants.emptyUiPermissions,
728
- auditlog: [import_constants.uiPermissionsById.read.value],
729
- deployments: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.read.value],
730
- groups: {
731
- [import_constants.ALL_DEVICES]: [
732
- import_constants.uiPermissionsById.read.value,
733
- // we can't assign deployment permissions to devices here, since the old path based rbac controls don't allow the scoped permissions
734
- // uiPermissionsById.deploy.value,
735
- import_constants.uiPermissionsById.manage.value,
736
- import_constants.uiPermissionsById.connect.value,
737
- import_constants.uiPermissionsById.configure.value
738
- ]
739
- },
740
- releases: {
741
- [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.manage.value]
742
- },
743
- userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
744
- }
745
- },
746
- almostAdminNew: {
747
- editable: true,
748
- isCustom: void 0,
749
- uiPermissions: {
750
- ...import_constants.emptyUiPermissions,
751
- auditlog: [import_constants.uiPermissionsById.read.value],
752
- deployments: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.manage.value],
753
- groups: {
754
- [import_constants.ALL_DEVICES]: [
755
- import_constants.uiPermissionsById.read.value,
756
- import_constants.uiPermissionsById.manage.value,
757
- import_constants.uiPermissionsById.deploy.value,
758
- import_constants.uiPermissionsById.connect.value,
759
- import_constants.uiPermissionsById.configure.value
760
- ]
761
- },
762
- releases: {
763
- [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.read.value]
764
- },
765
- tenantManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value],
766
- userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
767
- }
768
- }
769
- };
770
- var defaultRolesById = {
771
- ...import_constants.rolesById,
772
- test: {
773
- ...import_constants.emptyRole,
774
- name: "test",
775
- description: "test description",
776
- editable: true,
777
- uiPermissions: {
778
- ...import_constants.emptyUiPermissions,
779
- groups: { testGroup: [import_constants.uiPermissionsById.read.value] },
780
- releases: { bar: [import_constants.uiPermissionsById.read.value] }
781
- }
782
- }
783
- };
784
- var receivedRoles = rbacRoles.reduce(
785
- (accu, role) => {
786
- const { name, description, ...roleRemainder } = role;
787
- if (name.startsWith("RBAC")) {
788
- accu[name] = {
789
- ...defaultRolesById[name],
790
- ...roleRemainder,
791
- editable: false,
792
- isCustom: false,
793
- description: defaultRolesById[name].description ? defaultRolesById[name].description : description
794
- };
795
- } else {
796
- const result = expectedParsedRoles[name] ?? {};
797
- accu[name] = {
798
- ...import_constants.emptyRole,
799
- ...role,
800
- ...result,
801
- name
802
- };
803
- }
804
- return accu;
805
- },
806
- { ...defaultRolesById }
807
- );
808
- var receivedPermissionSets = permissionSets.reduce((accu, set) => {
809
- const result = import_constants.defaultPermissionSets[set.name]?.result ?? {};
810
- accu[set.name] = {
811
- ...set,
812
- result: {
813
- ...import_constants.emptyUiPermissions,
814
- ...result
815
- }
816
- };
817
- return accu;
818
- }, {});
819
-
820
- // src/requestHandlers/userHandlers.ts
821
- var userHandlers = [
822
- import_msw.http.post(`${import_constants2.useradmApiUrl}/auth/login`, ({ request }) => {
823
- const authHeader = request.headers.get("authorization");
824
- const authInfo = atob(authHeader?.split(" ")[1]);
825
- const [user, password] = authInfo.split(":");
826
- if (!password) {
827
- return import_msw.HttpResponse.json({ id: testSsoId, kind: "sso/saml" });
828
- } else if (password !== defaultPassword) {
829
- return new import_msw.HttpResponse(null, { status: 401 });
830
- } else if (user.includes("limited")) {
831
- return new import_msw.HttpResponse("limitedToken", { headers: { "Content-Type": import_constants2.APPLICATION_JWT_CONTENT_TYPE } });
832
- } else if (user.includes("2fa")) {
833
- return new import_msw.HttpResponse(JSON.stringify({ error: "2fa needed" }), { status: 401 });
834
- }
835
- return new import_msw.HttpResponse(token, { headers: { "Content-Type": import_constants2.APPLICATION_JWT_CONTENT_TYPE } });
836
- }),
837
- import_msw.http.get(`https://hosted.mender.io${import_constants2.useradmApiUrl}/auth/magic/:id`, ({ params: { id } }) => {
838
- if (id) {
839
- return new import_msw.HttpResponse("test", { headers: { "Set-Cookie": "JWT=test" } });
840
- }
841
- return new import_msw.HttpResponse(null, { status: 400 });
842
- }),
843
- import_msw.http.post(`${import_constants2.useradmApiUrl}/auth/logout`, () => new import_msw.HttpResponse(null, { status: 200 })),
844
- import_msw.http.post(`${import_constants2.useradmApiUrl}/auth/password-reset/:status`, async ({ params: { status }, request }) => {
845
- const { email, secret_hash, password } = await request.json();
846
- if (!["start", "complete"].includes(status) && ![email, secret_hash, password].some((item) => item)) {
847
- return new import_msw.HttpResponse(null, { status: 560 });
848
- }
849
- if (status === "start" && email) {
850
- return new import_msw.HttpResponse(null, { status: 200 });
851
- }
852
- if (status === "complete" && secret_hash && password) {
853
- return new import_msw.HttpResponse(null, { status: 200 });
854
- }
855
- return new import_msw.HttpResponse(null, { status: 561 });
856
- }),
857
- import_msw.http.put(`${import_constants2.useradmApiUrl}/2faverify`, async ({ request }) => {
858
- const { token2fa } = await request.json();
859
- if (!token2fa) {
860
- return new import_msw.HttpResponse(null, { status: 562 });
861
- }
862
- return new import_msw.HttpResponse(null, { status: 200 });
863
- }),
864
- import_msw.http.get(`${import_constants2.useradmApiUrl}/users`, () => import_msw.HttpResponse.json(Object.values(mockApiResponses.users.byId))),
865
- import_msw.http.get(`${import_constants2.useradmApiUrl}/users/me`, ({ request }) => {
866
- const authHeader = request.headers.get("authorization");
867
- if (authHeader?.includes("limited")) {
868
- return new import_msw.HttpResponse(JSON.stringify({ error: "forbidden by role-based access control" }), { status: 403 });
869
- }
870
- return import_msw.HttpResponse.json(mockApiResponses.users.byId[userId]);
871
- }),
872
- import_msw.http.get(`${import_constants2.useradmApiUrl}/users/exists`, ({ request }) => {
873
- const url = new URL(request.url);
874
- const email = url.searchParams.get("email");
875
- if (!decodeURIComponent(email).includes("child+123")) {
876
- return new import_msw.HttpResponse(null, { status: 578 });
877
- }
878
- return import_msw.HttpResponse.json({ exists: true });
879
- }),
880
- import_msw.http.get(`${import_constants2.useradmApiUrl}/users/:userId`, ({ params: { userId: userId2 } }) => {
881
- if (userId2 === "me" || mockApiResponses.users.byId[userId2]) {
882
- const user = userId2 === "me" ? userId : userId2;
883
- return import_msw.HttpResponse.json(mockApiResponses.users.byId[user]);
884
- }
885
- return new import_msw.HttpResponse(null, { status: 563 });
886
- }),
887
- import_msw.http.post(`${import_constants2.useradmApiUrl}/users`, async ({ request }) => {
888
- const { email, password } = await request.json();
889
- if (email === "test@test.com" || [email, password].every((value) => value)) {
890
- return import_msw.HttpResponse.json(mockApiResponses.users.byId.a1);
891
- }
892
- return new import_msw.HttpResponse(null, { status: 564 });
893
- }),
894
- import_msw.http.put(`${import_constants2.useradmApiUrl}/users/:userId`, async ({ params: { userId: userId2 }, request }) => {
895
- const { email, password, current_password } = await request.json();
896
- if (current_password === "bad_password") {
897
- return new import_msw.HttpResponse(null, { status: 401 });
898
- }
899
- if (mockApiResponses.users.byId[userId2] && [email, password].some((value) => Object.values(mockApiResponses.users.byId[userId2]).includes(value)) || email === "test@test.com") {
900
- return new import_msw.HttpResponse(null, { status: 200 });
901
- }
902
- return new import_msw.HttpResponse(null, { status: 565 });
903
- }),
904
- import_msw.http.delete(
905
- `${import_constants2.useradmApiUrl}/users/:userId`,
906
- ({ params: { userId: userId2 } }) => new import_msw.HttpResponse(null, { status: mockApiResponses.users.byId[userId2] ? 200 : 566 })
907
- ),
908
- import_msw.http.get(`${import_constants2.useradmApiUrl}/roles`, () => import_msw.HttpResponse.json(rbacRoles)),
909
- import_msw.http.post(`${import_constants2.useradmApiUrl}/roles`, async ({ request }) => {
910
- const { name, permissions } = await request.json();
911
- if ([name, permissions].every((value) => value) && permissions.every((permission) => permission.action && permission.object && permission.object.type && permission.object.value)) {
912
- return new import_msw.HttpResponse(null, { status: 200 });
913
- }
914
- return new import_msw.HttpResponse(null, { status: 567 });
915
- }),
916
- import_msw.http.put(`${import_constants2.useradmApiUrl}/roles/:roleId`, async ({ params: { roleId }, request }) => {
917
- const { description, name, permissions } = await request.json();
918
- if (mockApiResponses.users.rolesById[roleId] && [description, name, permissions].some((value) => value)) {
919
- return new import_msw.HttpResponse(null, { status: 200 });
920
- }
921
- return new import_msw.HttpResponse(null, { status: 568 });
922
- }),
923
- import_msw.http.post(`${import_constants2.useradmApiUrlv2}/support/feedback/product`, async () => new import_msw.HttpResponse(null, { status: 200 })),
924
- import_msw.http.delete(
925
- `${import_constants2.useradmApiUrl}/roles/:roleId`,
926
- ({ params: { roleId } }) => new import_msw.HttpResponse(null, { status: mockApiResponses.users.rolesById[roleId] ? 200 : 569 })
927
- ),
928
- import_msw.http.get(`${import_constants2.useradmApiUrlv2}/roles`, () => import_msw.HttpResponse.json(rbacRoles)),
929
- import_msw.http.get(`${import_constants2.useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId } }) => {
930
- if (mockApiResponses.users.rolesById[roleId]) {
931
- return import_msw.HttpResponse.json(mockApiResponses.users.rolesById[roleId]);
932
- }
933
- return new import_msw.HttpResponse(null, { status: 571 });
934
- }),
935
- import_msw.http.post(`${import_constants2.useradmApiUrlv2}/roles`, async ({ request }) => {
936
- const { name, permission_sets_with_scope } = await request.json();
937
- if (!!name && permission_sets_with_scope.every((permission) => permission.name && permissionSets.find((permissionSet) => permissionSet.name === permission.name))) {
938
- return new import_msw.HttpResponse(null, { status: 200 });
939
- }
940
- return new import_msw.HttpResponse(null, { status: 572 });
941
- }),
942
- import_msw.http.put(`${import_constants2.useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId }, request }) => {
943
- const { description, name, permission_sets_with_scope } = await request.json();
944
- if (mockApiResponses.users.rolesById[roleId] && [description, name, permission_sets_with_scope].some((value) => value)) {
945
- return new import_msw.HttpResponse(null, { status: 200 });
946
- }
947
- return new import_msw.HttpResponse(null, { status: 573 });
948
- }),
949
- import_msw.http.delete(`${import_constants2.useradmApiUrlv2}/roles/:roleId`, ({ params: { roleId } }) => {
950
- if (mockApiResponses.users.rolesById[roleId]) {
951
- return new import_msw.HttpResponse(null, { status: 200 });
952
- }
953
- return new import_msw.HttpResponse(null, { status: 574 });
954
- }),
955
- import_msw.http.get(`${import_constants2.useradmApiUrl}/settings`, () => import_msw.HttpResponse.json(mockApiResponses.users.globalSettings)),
956
- import_msw.http.post(`${import_constants2.useradmApiUrl}/settings`, () => new import_msw.HttpResponse(null, { status: 200 })),
957
- import_msw.http.get(`${import_constants2.useradmApiUrl}/settings/me`, () => import_msw.HttpResponse.json(mockApiResponses.users.userSettings)),
958
- import_msw.http.post(`${import_constants2.useradmApiUrl}/settings/me`, () => new import_msw.HttpResponse(null, { status: 200 })),
959
- import_msw.http.get(`${import_constants2.useradmApiUrl}/settings/tokens`, () => import_msw.HttpResponse.json(accessTokens)),
960
- import_msw.http.post(`${import_constants2.useradmApiUrl}/settings/tokens`, () => import_msw.HttpResponse.json("aNewToken")),
961
- import_msw.http.delete(
962
- `${import_constants2.useradmApiUrl}/settings/tokens/:tokenId`,
963
- ({ params: { tokenId } }) => new import_msw.HttpResponse(null, { status: tokenId === "some-id-1" ? 200 : 577 })
964
- ),
965
- import_msw.http.get(`${import_constants2.useradmApiUrl}/2faqr`, () => import_msw.HttpResponse.json({ qr: btoa("test") })),
966
- import_msw.http.post(`${import_constants2.useradmApiUrl}/users/:userId/2fa/enable`, ({ params: { userId: userId2 } }) => {
967
- if (mockApiResponses.users.byId[userId2] || userId2 === "me") {
968
- return new import_msw.HttpResponse(null, { status: 200 });
969
- }
970
- return new import_msw.HttpResponse(null, { status: 570 });
971
- }),
972
- import_msw.http.post(`${import_constants2.useradmApiUrl}/users/:userId/2fa/disable`, ({ params: { userId: userId2 } }) => {
973
- if (mockApiResponses.users.byId[userId2] || userId2 === "me") {
974
- return new import_msw.HttpResponse(null, { status: 200 });
975
- }
976
- return new import_msw.HttpResponse(null, { status: 571 });
977
- }),
978
- import_msw.http.post(`${import_constants2.useradmApiUrl}/auth/verify-email/start`, () => new import_msw.HttpResponse(null, { status: 200 })),
979
- import_msw.http.post(`${import_constants2.useradmApiUrl}/auth/verify-email/complete`, async ({ request }) => {
980
- const { secret_hash } = await request.json();
981
- return new import_msw.HttpResponse(null, { status: secret_hash === "superSecret" ? 200 : 576 });
982
- }),
983
- import_msw.http.get(`${import_constants2.useradmApiUrlv2}/permission_sets`, () => import_msw.HttpResponse.json(permissionSets)),
984
- import_msw.http.post(`${import_constants2.useradmApiUrl}/users/:userId/assign`, async ({ request }) => {
985
- const { tenant_ids } = await request.json();
986
- return new import_msw.HttpResponse(null, { status: tenant_ids.length ? 200 : 577 });
987
- }),
988
- import_msw.http.get(`${import_constants2.useradmApiUrl}/users/tenants/:tenantId/token`, () => import_msw.HttpResponse.text("differentToken"))
989
- ];
990
- // Annotate the CommonJS export names for ESM import in node:
991
- 0 && (module.exports = {
992
- userHandlers
993
- });
994
- //# sourceMappingURL=userHandlers.cjs.map