@northern.tech/testing 0.1.0

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