@northern.tech/testing 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/baseTestConfig.json +17 -0
  2. package/dist/chunk-3CVNBMEF.js +161 -0
  3. package/dist/chunk-3CVNBMEF.js.map +1 -0
  4. package/dist/chunk-7GNK7IRV.js +29 -0
  5. package/dist/chunk-7GNK7IRV.js.map +1 -0
  6. package/dist/chunk-AP4MOFMD.js +239 -0
  7. package/dist/chunk-AP4MOFMD.js.map +1 -0
  8. package/dist/chunk-DOHA53UH.js +301 -0
  9. package/dist/chunk-DOHA53UH.js.map +1 -0
  10. package/dist/chunk-H4J7L3HX.js +188 -0
  11. package/dist/chunk-H4J7L3HX.js.map +1 -0
  12. package/dist/chunk-HRGVXWMH.js +17 -0
  13. package/dist/chunk-HRGVXWMH.js.map +1 -0
  14. package/dist/chunk-KCLTR6QS.js +34 -0
  15. package/dist/chunk-KCLTR6QS.js.map +1 -0
  16. package/dist/chunk-M2TKDOPD.js +266 -0
  17. package/dist/chunk-M2TKDOPD.js.map +1 -0
  18. package/dist/chunk-O42KIJXJ.js +933 -0
  19. package/dist/chunk-O42KIJXJ.js.map +1 -0
  20. package/dist/mockData.cjs +967 -0
  21. package/dist/mockData.cjs.map +1 -0
  22. package/dist/mockData.d.cts +636 -0
  23. package/dist/mockData.d.ts +636 -0
  24. package/dist/mockData.js +47 -0
  25. package/dist/mockData.js.map +1 -0
  26. package/dist/requestHandlers/deploymentHandlers.cjs +1044 -0
  27. package/dist/requestHandlers/deploymentHandlers.cjs.map +1 -0
  28. package/dist/requestHandlers/deploymentHandlers.d.cts +5 -0
  29. package/dist/requestHandlers/deploymentHandlers.d.ts +5 -0
  30. package/dist/requestHandlers/deploymentHandlers.js +8 -0
  31. package/dist/requestHandlers/deploymentHandlers.js.map +1 -0
  32. package/dist/requestHandlers/deviceHandlers.cjs +1096 -0
  33. package/dist/requestHandlers/deviceHandlers.cjs.map +1 -0
  34. package/dist/requestHandlers/deviceHandlers.d.cts +20 -0
  35. package/dist/requestHandlers/deviceHandlers.d.ts +20 -0
  36. package/dist/requestHandlers/deviceHandlers.js +12 -0
  37. package/dist/requestHandlers/deviceHandlers.js.map +1 -0
  38. package/dist/requestHandlers/monitorHandlers.cjs +834 -0
  39. package/dist/requestHandlers/monitorHandlers.cjs.map +1 -0
  40. package/dist/requestHandlers/monitorHandlers.d.cts +5 -0
  41. package/dist/requestHandlers/monitorHandlers.d.ts +5 -0
  42. package/dist/requestHandlers/monitorHandlers.js +8 -0
  43. package/dist/requestHandlers/monitorHandlers.js.map +1 -0
  44. package/dist/requestHandlers/organizationHandlers.cjs +1129 -0
  45. package/dist/requestHandlers/organizationHandlers.cjs.map +1 -0
  46. package/dist/requestHandlers/organizationHandlers.d.cts +5 -0
  47. package/dist/requestHandlers/organizationHandlers.d.ts +5 -0
  48. package/dist/requestHandlers/organizationHandlers.js +8 -0
  49. package/dist/requestHandlers/organizationHandlers.js.map +1 -0
  50. package/dist/requestHandlers/releaseHandlers.cjs +965 -0
  51. package/dist/requestHandlers/releaseHandlers.cjs.map +1 -0
  52. package/dist/requestHandlers/releaseHandlers.d.cts +5 -0
  53. package/dist/requestHandlers/releaseHandlers.d.ts +5 -0
  54. package/dist/requestHandlers/releaseHandlers.js +8 -0
  55. package/dist/requestHandlers/releaseHandlers.js.map +1 -0
  56. package/dist/requestHandlers/requestHandlers.cjs +2002 -0
  57. package/dist/requestHandlers/requestHandlers.cjs.map +1 -0
  58. package/dist/requestHandlers/requestHandlers.d.cts +5 -0
  59. package/dist/requestHandlers/requestHandlers.d.ts +5 -0
  60. package/dist/requestHandlers/requestHandlers.js +35 -0
  61. package/dist/requestHandlers/requestHandlers.js.map +1 -0
  62. package/dist/requestHandlers/userHandlers.cjs +993 -0
  63. package/dist/requestHandlers/userHandlers.cjs.map +1 -0
  64. package/dist/requestHandlers/userHandlers.d.cts +5 -0
  65. package/dist/requestHandlers/userHandlers.d.ts +5 -0
  66. package/dist/requestHandlers/userHandlers.js +8 -0
  67. package/dist/requestHandlers/userHandlers.js.map +1 -0
  68. package/dist/setupTests.cjs +995 -0
  69. package/dist/setupTests.cjs.map +1 -0
  70. package/dist/setupTests.d.cts +77 -0
  71. package/dist/setupTests.d.ts +77 -0
  72. package/dist/setupTests.js +138 -0
  73. package/dist/setupTests.js.map +1 -0
  74. package/dist/theme/light.cjs +41 -0
  75. package/dist/theme/light.cjs.map +1 -0
  76. package/dist/theme/light.d.cts +12 -0
  77. package/dist/theme/light.d.ts +12 -0
  78. package/dist/theme/light.js +7 -0
  79. package/dist/theme/light.js.map +1 -0
  80. package/dist/utils.cjs +71 -0
  81. package/dist/utils.cjs.map +1 -0
  82. package/dist/utils.d.cts +69 -0
  83. package/dist/utils.d.ts +69 -0
  84. package/dist/utils.js +12 -0
  85. package/dist/utils.js.map +1 -0
  86. package/package.json +1 -1
@@ -0,0 +1,1129 @@
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/organizationHandlers.ts
21
+ var organizationHandlers_exports = {};
22
+ __export(organizationHandlers_exports, {
23
+ organizationHandlers: () => organizationHandlers
24
+ });
25
+ module.exports = __toCommonJS(organizationHandlers_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 defaultCreationDate = "2019-01-13T06:25:00.000Z";
35
+ var defaultMacAddress = "dc:a6:32:12:ad:bf";
36
+ var permissionSetObjectTypes = {
37
+ any: "Any",
38
+ artifacts: "Artifacts",
39
+ empty: "",
40
+ groups: "Device groups",
41
+ releases: "Releases",
42
+ tenantManagement: "Tenant management",
43
+ userManagement: "User management"
44
+ };
45
+ var commonEndpoints = {
46
+ artifacts: "^/api/management/v1/deployments/artifacts",
47
+ artifactDetails: "^/api/management/v1/deployments/artifacts/[^/]+",
48
+ deviceManagement: "^/api/management/(v[1-9])/(devauth|inventory)/"
49
+ };
50
+ var webhookEvents = [
51
+ {
52
+ id: "1",
53
+ type: "device-status-changed",
54
+ data: { id: "1", status: "accepted" },
55
+ time: "2020-09-01T12:00:00.000Z",
56
+ delivery_statuses: [{ integration_id: "1", success: true, status_code: 200 }]
57
+ },
58
+ {
59
+ id: "2",
60
+ type: "device-status-changed",
61
+ data: { id: "3", status: "accepted" },
62
+ time: "2020-09-01T12:00:05.000Z",
63
+ delivery_statuses: [{ integration_id: "1", success: true, status_code: 200 }]
64
+ }
65
+ ];
66
+ var tenants = [
67
+ {
68
+ id: "671a0f1dd58c813118fe8622",
69
+ parent_tenant_id: "6718de64b42e08dea2a2065d",
70
+ name: "child2",
71
+ tenant_token: "mQDYRCr-tGbDuJhPp7fArbfTA5htVTWE9G204AzhDUM",
72
+ status: "active",
73
+ additional_info: {
74
+ marketing: false,
75
+ campaign: ""
76
+ },
77
+ plan: "enterprise",
78
+ trial: false,
79
+ trial_expiration: null,
80
+ service_provider: false,
81
+ created_at: "2024-10-24T09:10:53.281Z",
82
+ cancelled_at: null,
83
+ children_tenants: null,
84
+ max_child_tenants: 0,
85
+ device_count: 0,
86
+ device_limit: 100,
87
+ device_limits: {
88
+ max_devices: {
89
+ current_value: 0,
90
+ name: "max_devices",
91
+ tenant_id: "699f07a3e783def54cf6201f",
92
+ value: 200
93
+ },
94
+ max_micro_devices: {
95
+ current_value: 0,
96
+ name: "max_micro_devices",
97
+ tenant_id: "699f07a3e783def54cf6201f",
98
+ value: 280
99
+ },
100
+ max_system_devices: {
101
+ current_value: 0,
102
+ name: "max_system_devices",
103
+ tenant_id: "699f07a3e783def54cf6201f",
104
+ value: 20
105
+ }
106
+ },
107
+ binary_delta: true
108
+ }
109
+ ];
110
+ var userId = "a30a780b-b843-5344-80e3-0fd95a4f6fc3";
111
+ var defaultUser = {
112
+ created_ts: "2019-01-01T10:30:00.000Z",
113
+ email: "a@b.com",
114
+ id: "a1",
115
+ roles: ["RBAC_ROLE_PERMIT_ALL"],
116
+ tfa_status: "enabled",
117
+ verified: true
118
+ };
119
+ var deviceTypes = { qemu: "qemux86-64" };
120
+ var checkInTimeRounded = "2019-01-01T00:00:00.000Z";
121
+ var checkInTimeExact = "2019-01-01T10:25:00.000Z";
122
+ var mockApiResponses = {
123
+ deployments: {
124
+ byId: {
125
+ d1: {
126
+ id: "d1",
127
+ name: "test deployment",
128
+ created: "2019-01-01T12:30:00.000Z",
129
+ devices: {
130
+ a1: {
131
+ id: "a1",
132
+ status: "installing",
133
+ attributes: {},
134
+ image: { size: 123 }
135
+ }
136
+ },
137
+ statistics: {
138
+ status: {
139
+ "already-installed": 0,
140
+ decommissioned: 0,
141
+ downloading: 0,
142
+ failure: 0,
143
+ installing: 1,
144
+ noartifact: 0,
145
+ pending: 0,
146
+ rebooting: 0,
147
+ success: 0
148
+ },
149
+ total_size: 1234
150
+ }
151
+ },
152
+ d2: {
153
+ id: "d2",
154
+ name: "test deployment 2",
155
+ artifact_name: "r1",
156
+ artifacts: ["123"],
157
+ created: "2019-01-01T12:25:00.000Z",
158
+ device_count: 1,
159
+ devices: {
160
+ b1: {
161
+ attributes: {},
162
+ id: "b1",
163
+ status: "pending"
164
+ }
165
+ },
166
+ filter: void 0,
167
+ group: void 0,
168
+ statistics: {
169
+ status: {
170
+ downloading: 0,
171
+ decommissioned: 0,
172
+ failure: 0,
173
+ installing: 0,
174
+ noartifact: 0,
175
+ pending: 1,
176
+ rebooting: 0,
177
+ success: 0,
178
+ "already-installed": 0
179
+ }
180
+ }
181
+ },
182
+ d3: {
183
+ id: "d3",
184
+ name: "Test",
185
+ phases: [
186
+ { id: "0", batch_size: 2, device_count: 2 },
187
+ { id: "1", start_ts: "2019-02-04T11:45:10.002Z", batch_size: 3, device_count: 3 },
188
+ { id: "2", start_ts: "2019-02-05T11:45:10.002Z", batch_size: 5, device_count: 5 },
189
+ { id: "3", start_ts: "2019-02-06T11:45:10.002Z", batch_size: 5, device_count: 5 },
190
+ { id: "4", start_ts: "2019-02-21T11:45:10.002Z", batch_size: 5, device_count: 0 }
191
+ ],
192
+ max_devices: 0,
193
+ created: "2019-01-31T12:59:30.020Z",
194
+ devices: {},
195
+ filter: void 0,
196
+ group: void 0,
197
+ stats: {
198
+ pending: 3,
199
+ decommissioned: 0,
200
+ failure: 23,
201
+ pause_before_committing: 0,
202
+ pause_before_rebooting: 0,
203
+ installing: 0,
204
+ rebooting: 0,
205
+ "already-installed": 0,
206
+ pause_before_installing: 0,
207
+ downloading: 0,
208
+ success: 6,
209
+ aborted: 0,
210
+ noartifact: 0
211
+ },
212
+ statistics: { total_size: "1234" },
213
+ status: "inprogress",
214
+ active: true,
215
+ device_count: 100,
216
+ retries: "0",
217
+ type: "software"
218
+ }
219
+ },
220
+ byStatus: {
221
+ pending: { deploymentIds: ["d2"] },
222
+ inprogress: { deploymentIds: ["d3"] }
223
+ }
224
+ },
225
+ devices: {
226
+ byId: {
227
+ a1: {
228
+ id: "a1",
229
+ auth_sets: [
230
+ {
231
+ id: "auth1",
232
+ identity_data: { mac: defaultMacAddress },
233
+ pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
234
+ status: "accepted",
235
+ ts: defaultCreationDate
236
+ }
237
+ ],
238
+ updated_ts: "2019-01-01T09:25:00.000Z"
239
+ },
240
+ b1: {
241
+ id: "b1",
242
+ attributes: {
243
+ ipv4_wlan0: "192.168.10.141/24",
244
+ device_type: [deviceTypes.qemu]
245
+ },
246
+ system: {
247
+ check_in_time: checkInTimeRounded
248
+ },
249
+ check_in_time: checkInTimeExact,
250
+ check_in_time_exact: checkInTimeExact,
251
+ check_in_time_rounded: checkInTimeRounded,
252
+ identity_data: { mac: defaultMacAddress },
253
+ status: "accepted",
254
+ decommissioning: false,
255
+ created_ts: defaultCreationDate,
256
+ updated_ts: "2019-01-01T09:25:00.000Z",
257
+ auth_sets: [
258
+ {
259
+ id: "auth1",
260
+ identity_data: { mac: defaultMacAddress },
261
+ pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
262
+ ts: defaultCreationDate,
263
+ status: "accepted"
264
+ }
265
+ ]
266
+ }
267
+ },
268
+ groups: {
269
+ byId: {
270
+ testGroup: {
271
+ deviceIds: ["a1", "b1"],
272
+ filters: [],
273
+ total: 2
274
+ },
275
+ testGroupDynamic: {
276
+ id: "filter1",
277
+ name: "filter1",
278
+ filters: [{ scope: "system", key: "group", operator: "$eq", value: "things" }]
279
+ }
280
+ }
281
+ },
282
+ limits: { standard: 500, micro: 0, system: 0 },
283
+ byStatus: {
284
+ accepted: { deviceIds: ["a1", "b1"], total: 2 },
285
+ active: { deviceIds: [], total: 0 },
286
+ inactive: { deviceIds: [], total: 0 },
287
+ pending: { deviceIds: ["c1"], total: 1 },
288
+ preauthorized: { deviceIds: [], total: 0 },
289
+ rejected: { deviceIds: [], total: 0 }
290
+ }
291
+ },
292
+ organization: {
293
+ organization: {
294
+ id: "1",
295
+ addons: [],
296
+ name: "test",
297
+ plan: "os",
298
+ trial: false
299
+ },
300
+ products: [
301
+ {
302
+ name: "mender_standard",
303
+ billing_unit: "devices",
304
+ prices: [
305
+ {
306
+ plan: "os",
307
+ constraints: {
308
+ min: 50,
309
+ max: 1e3,
310
+ div: 50
311
+ }
312
+ },
313
+ {
314
+ plan: "professional",
315
+ constraints: {
316
+ min: 250,
317
+ max: 1e4,
318
+ div: 50
319
+ }
320
+ }
321
+ ],
322
+ addons: [
323
+ {
324
+ name: "troubleshoot",
325
+ prices: [{ plan: "os" }, { plan: "professional" }]
326
+ },
327
+ {
328
+ name: "configure",
329
+ prices: [{ plan: "os" }, { plan: "professional" }]
330
+ },
331
+ {
332
+ name: "monitor",
333
+ prices: [{ plan: "professional" }]
334
+ }
335
+ ]
336
+ },
337
+ {
338
+ name: "mender_micro",
339
+ billing_unit: "devices",
340
+ prices: [
341
+ {
342
+ plan: "os",
343
+ constraints: {
344
+ min: 50,
345
+ max: 5e3,
346
+ div: 50
347
+ }
348
+ },
349
+ {
350
+ plan: "professional",
351
+ constraints: {
352
+ min: 500,
353
+ max: 1e5,
354
+ div: 50
355
+ }
356
+ }
357
+ ]
358
+ }
359
+ ],
360
+ intentId: "testIntent",
361
+ auditlog: {
362
+ events: [
363
+ {
364
+ actor: {
365
+ id: "string",
366
+ type: "user",
367
+ email: "string@example.com"
368
+ },
369
+ time: "2019-01-01T12:10:22.667Z",
370
+ action: "create",
371
+ object: {
372
+ id: "string",
373
+ type: "user",
374
+ user: {
375
+ email: "user@acme.com"
376
+ }
377
+ },
378
+ change: "change1"
379
+ },
380
+ {
381
+ actor: {
382
+ id: "string",
383
+ type: "user",
384
+ email: "string",
385
+ identity_data: "string"
386
+ },
387
+ time: "2019-01-01T12:16:22.667Z",
388
+ action: "create",
389
+ object: {
390
+ id: "string",
391
+ type: "deployment",
392
+ deployment: {
393
+ name: "production",
394
+ artifact_name: "Application 0.0.1"
395
+ }
396
+ },
397
+ change: "change2"
398
+ },
399
+ {
400
+ actor: {
401
+ id: "string",
402
+ type: "user",
403
+ email: "string@example.com"
404
+ },
405
+ time: "2019-01-01T12:10:22.669Z",
406
+ action: "open_terminal",
407
+ meta: {
408
+ session_id: ["abd313a8-ee88-48ab-9c99-fbcd80048e6e"]
409
+ },
410
+ object: {
411
+ id: "a1",
412
+ type: "device"
413
+ },
414
+ change: "change3"
415
+ }
416
+ ]
417
+ }
418
+ },
419
+ releases: {
420
+ byId: {
421
+ r1: {
422
+ name: "r1",
423
+ artifacts: [
424
+ {
425
+ id: "art1",
426
+ description: "test description",
427
+ device_types_compatible: [deviceTypes.qemu],
428
+ modified: "2020-09-10T12:16:22.667Z",
429
+ updates: [{ type_info: { type: "testtype" } }],
430
+ artifact_depends: {
431
+ device_type: [deviceTypes.qemu]
432
+ },
433
+ artifact_provides: {
434
+ artifact_name: "myapp",
435
+ "data-partition.myapp.version": "v2020.10",
436
+ list_of_fancy: [deviceTypes.qemu, "x172"]
437
+ },
438
+ clears_artifact_provides: ["data-partition.myapp.*"]
439
+ }
440
+ ],
441
+ device_types_compatible: [deviceTypes.qemu],
442
+ modified: "2020-09-10T12:16:22.667Z",
443
+ metaData: {}
444
+ }
445
+ }
446
+ },
447
+ users: {
448
+ byId: {
449
+ a1: defaultUser,
450
+ [userId]: { ...defaultUser, id: userId, email: "a2@b.com", created_ts: "2019-01-01T12:30:00.000Z" }
451
+ },
452
+ rolesById: {
453
+ admin: {
454
+ name: "admin",
455
+ description: "Administrator role",
456
+ permissions: []
457
+ },
458
+ test: { name: "test", description: "test description", permissions: [] }
459
+ },
460
+ globalSettings: {
461
+ "2fa": "enabled",
462
+ id_attribute: void 0,
463
+ previousFilters: []
464
+ },
465
+ userSettings: {
466
+ "2fa": "disabled",
467
+ columnSelection: [],
468
+ onboarding: { something: "here" },
469
+ tooltips: {},
470
+ previousFilters: []
471
+ }
472
+ }
473
+ };
474
+ var releasesList = Array.from({ length: 5e3 }, (x, i) => ({
475
+ artifacts: [
476
+ {
477
+ id: "art1",
478
+ description: "test description",
479
+ device_types_compatible: [deviceTypes.qemu],
480
+ modified: "2020-09-10T12:16:22.667Z",
481
+ updates: [{ type_info: { type: "testtype" } }],
482
+ artifact_depends: {
483
+ device_type: [deviceTypes.qemu]
484
+ },
485
+ artifact_provides: {
486
+ artifact_name: "myapp",
487
+ "data-partition.myapp.version": "v2020.10",
488
+ list_of_fancy: [deviceTypes.qemu, "x172"]
489
+ },
490
+ clears_artifact_provides: ["data-partition.myapp.*"]
491
+ }
492
+ ],
493
+ device_types_compatible: [deviceTypes.qemu],
494
+ metaData: {},
495
+ name: `release-${i + 1}`,
496
+ modified: i
497
+ }));
498
+ var permissionSets = [
499
+ {
500
+ ...import_constants.defaultPermissionSets.Basic,
501
+ object: permissionSetObjectTypes.empty,
502
+ description: "Set containing basic permissions.",
503
+ permissions: [
504
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/settings$" } },
505
+ { action: "http", object: { type: "any", value: "^/api/management/v1/useradm/users/me$" } },
506
+ { action: "http", object: { type: "any", value: "^/api/management/1.0/auth/verify$" } },
507
+ { action: "http", object: { type: "PUT", value: "^/api/management/v1/useradm/2faverify$" } },
508
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/useradm/users/me/2fa/(enable|disable)$" } },
509
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/roles" } },
510
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/user/tenant" } }
511
+ ]
512
+ },
513
+ {
514
+ ...import_constants.defaultPermissionSets.ManageReleases,
515
+ action: import_constants.uiPermissionsById.manage.title,
516
+ object: permissionSetObjectTypes.releases,
517
+ description: "Set of permissions which allows user to manage releases",
518
+ permissions: [
519
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
520
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
521
+ { action: "http", object: { type: "PUT", value: commonEndpoints.artifactDetails } },
522
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.artifactDetails } },
523
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
524
+ ]
525
+ },
526
+ {
527
+ ...import_constants.defaultPermissionSets.ReadUsers,
528
+ action: import_constants.uiPermissionsById.read.title,
529
+ object: permissionSetObjectTypes.userManagement,
530
+ description: "Set of permissions which allows user to view other users",
531
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/useradm/" } }]
532
+ },
533
+ {
534
+ ...import_constants.defaultPermissionSets.ManageUsers,
535
+ action: import_constants.uiPermissionsById.manage.title,
536
+ object: permissionSetObjectTypes.userManagement,
537
+ description: "Set of permissions which allows user manage other user accounts",
538
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/" } }]
539
+ },
540
+ {
541
+ ...import_constants.defaultPermissionSets.ReadTenants,
542
+ action: import_constants.uiPermissionsById.read.title,
543
+ object: permissionSetObjectTypes.tenantManagement,
544
+ description: "Set of permissions which allows user to list other tenants and their config",
545
+ permissions: [
546
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
547
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } }
548
+ ]
549
+ },
550
+ {
551
+ ...import_constants.defaultPermissionSets.ManageTenants,
552
+ action: import_constants.uiPermissionsById.manage.title,
553
+ object: permissionSetObjectTypes.tenantManagement,
554
+ description: "Set of permissions which allows user to manage other tenants and their config",
555
+ permissions: [
556
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/tenantadm/" } },
557
+ { action: "http", object: { type: "POST", value: "^/api/management/(v[1-9])/tenantadm/" } },
558
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9])/tenantadm/" } }
559
+ ]
560
+ },
561
+ {
562
+ ...import_constants.defaultPermissionSets.ReadAuditLogs,
563
+ action: import_constants.uiPermissionsById.read.title,
564
+ object: "System Audit Log",
565
+ description: "Set of permissions which allows user to view system audit log",
566
+ permissions: [{ action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/auditlogs/logs" } }]
567
+ },
568
+ {
569
+ ...import_constants.defaultPermissionSets.DeployToDevices,
570
+ action: "Deploy",
571
+ object: permissionSetObjectTypes.groups,
572
+ description: "Set of permissions which allows user to deploy to devices",
573
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/(deployments|deviceconfig)/" } }],
574
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
575
+ },
576
+ {
577
+ ...import_constants.defaultPermissionSets.ConfigureDevices,
578
+ action: "Configure",
579
+ object: permissionSetObjectTypes.groups,
580
+ description: "Set of permissions which allows user to manage configuration of the devices",
581
+ permissions: [{ action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/" } }],
582
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
583
+ },
584
+ {
585
+ ...import_constants.defaultPermissionSets.ConnectToDevices,
586
+ action: "Connect",
587
+ object: permissionSetObjectTypes.groups,
588
+ description: "Set of permissions which allows user to use remote terminal and file transfer",
589
+ permissions: [
590
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/connect$" } },
591
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/download\\?path=[^&]+$" } },
592
+ { action: "http", object: { type: "PUT", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+/upload$" } }
593
+ ],
594
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
595
+ },
596
+ {
597
+ ...import_constants.defaultPermissionSets.SuperUser,
598
+ action: "Any",
599
+ object: permissionSetObjectTypes.any,
600
+ description: "Set of permissions which allows user to do anything",
601
+ permissions: [{ action: "any", object: { type: "any", value: "any" } }]
602
+ },
603
+ {
604
+ ...import_constants.defaultPermissionSets.UploadArtifacts,
605
+ action: "Upload",
606
+ object: permissionSetObjectTypes.artifacts,
607
+ description: "Set of permissions which allows user to upload artifacts",
608
+ permissions: [
609
+ { action: "http", object: { type: "POST", value: commonEndpoints.artifacts } },
610
+ { action: "http", object: { type: "POST", value: "^/api/management/v1/deployments/artifacts/generate" } }
611
+ ]
612
+ },
613
+ {
614
+ ...import_constants.defaultPermissionSets.ReadDevices,
615
+ action: import_constants.uiPermissionsById.read.title,
616
+ object: permissionSetObjectTypes.groups,
617
+ description: "Set of permissions which allows user to view devices",
618
+ permissions: [
619
+ { action: "http", object: { type: "POST", value: "^/api/management/v2/inventory/filters/search" } },
620
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9])/(deployments|devauth|inventory|deviceconfig|devicemonitor)/" } },
621
+ { action: "http", object: { type: "GET", value: "^/api/management/(v[1-9]|0.1.0)/deviceconnect/devices/[^/]+$" } }
622
+ ],
623
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
624
+ },
625
+ {
626
+ ...import_constants.defaultPermissionSets.ManageDevices,
627
+ action: import_constants.uiPermissionsById.manage.title,
628
+ object: permissionSetObjectTypes.groups,
629
+ description: "Set of permissions which allows user to manage devices",
630
+ permissions: [
631
+ { action: "http", object: { type: "POST", value: commonEndpoints.deviceManagement } },
632
+ { action: "http", object: { type: "PUT", value: commonEndpoints.deviceManagement } },
633
+ { action: "http", object: { type: "DELETE", value: commonEndpoints.deviceManagement } }
634
+ ],
635
+ supported_scope_types: [import_constants.scopedPermissionAreas.groups.scopeType]
636
+ },
637
+ {
638
+ ...import_constants.defaultPermissionSets.ReadReleases,
639
+ action: import_constants.uiPermissionsById.read.title,
640
+ object: permissionSetObjectTypes.releases,
641
+ description: "Set of permissions which allows user to view releases",
642
+ permissions: [
643
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifacts } },
644
+ { action: "http", object: { type: "GET", value: commonEndpoints.artifactDetails } },
645
+ { action: "http", object: { type: "GET", value: "^/api/management/v1/deployments/artifacts/[^/]+/download" } }
646
+ ]
647
+ },
648
+ {
649
+ name: "almostAdmin",
650
+ object: permissionSetObjectTypes.empty,
651
+ description: "Set containing all the permissions.",
652
+ permissions: [
653
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/auditlogs/.*" } },
654
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/.*" } },
655
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/config/.*" } },
656
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/.*" } },
657
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deployments/deployments/releases/.*" } },
658
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/devauth/.*" } },
659
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconfig/.*" } },
660
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/.*" } },
661
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/deviceconnect/devices" } },
662
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/inventory/.*" } },
663
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/iot-manager/.*" } },
664
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/monitor/.*" } },
665
+ { action: "http", object: { type: "any", value: "^/api/management/(v[1-9])/useradm/.*" } }
666
+ ]
667
+ }
668
+ ];
669
+ var rbacRoles = [
670
+ {
671
+ name: "dyn",
672
+ description: "",
673
+ permissions: [
674
+ { action: "CREATE_DEPLOYMENT", object: { type: "DEVICE_GROUP", value: "dyn" } },
675
+ { action: "VIEW_DEVICE", object: { type: "DEVICE_GROUP", value: "dyn" } }
676
+ ]
677
+ },
678
+ { name: "asdasd", description: "123", permissions: [{ action: "http", object: { type: "any", value: "/api/management/v1/useradm/.*" } }] },
679
+ {
680
+ name: "141sasd",
681
+ description: "1313adg",
682
+ permission_sets_with_scope: [
683
+ { ...import_constants.defaultPermissionSets.ReadDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
684
+ { ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } },
685
+ { ...import_constants.defaultPermissionSets.ManageUsers }
686
+ ]
687
+ },
688
+ {
689
+ name: "kljlkk",
690
+ description: "lkl",
691
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["bestgroup"] } }]
692
+ },
693
+ {
694
+ name: "yyyyy",
695
+ description: "asd",
696
+ permission_sets_with_scope: [
697
+ { ...import_constants.defaultPermissionSets.ManageDevices, scope: { type: import_constants.scopedPermissionAreas.groups.scopeType, value: ["dockerclient"] } },
698
+ { ...import_constants.defaultPermissionSets.ManageReleases }
699
+ ]
700
+ },
701
+ {
702
+ name: "RBAC_ROLE_DEPLOYMENTS_MANAGER",
703
+ description: "Intended for users responsible for managing deployments, this role can create and abort deployments",
704
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.DeployToDevices }]
705
+ },
706
+ {
707
+ name: "RBAC_ROLE_REMOTE_TERMINAL",
708
+ description: `Intended for tech support accounts, this role can access the devices' Remote Terminal.`,
709
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ConnectToDevices }]
710
+ },
711
+ { name: "RBAC_ROLE_PERMIT_ALL", description: "", permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.SuperUser }] },
712
+ {
713
+ name: "RBAC_ROLE_OBSERVER",
714
+ 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.",
715
+ permission_sets_with_scope: [{ ...import_constants.defaultPermissionSets.ReadReleases }, { ...import_constants.defaultPermissionSets.ReadDevices }]
716
+ },
717
+ {
718
+ name: "RBAC_ROLE_CI",
719
+ 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.",
720
+ permission_sets_with_scope: [
721
+ { ...import_constants.defaultPermissionSets.ReadReleases },
722
+ { ...import_constants.defaultPermissionSets.ManageReleases },
723
+ { ...import_constants.defaultPermissionSets.UploadArtifacts }
724
+ ]
725
+ },
726
+ {
727
+ name: "almostAdmin",
728
+ description: "almost admin rights",
729
+ permissions: permissionSets.find((item) => item.name === "almostAdmin")?.permissions
730
+ },
731
+ {
732
+ name: "almostAdminNew",
733
+ description: "almost admin rights",
734
+ permission_sets_with_scope: Object.values(import_constants.defaultPermissionSets)
735
+ }
736
+ ];
737
+ var expectedParsedRoles = {
738
+ "141sasd": {
739
+ editable: true,
740
+ isCustom: void 0,
741
+ uiPermissions: {
742
+ ...import_constants.emptyUiPermissions,
743
+ groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] },
744
+ userManagement: [import_constants.uiPermissionsById.manage.value]
745
+ }
746
+ },
747
+ asdasd: {
748
+ editable: false,
749
+ isCustom: true,
750
+ uiPermissions: { ...import_constants.emptyUiPermissions, userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] }
751
+ },
752
+ dyn: {
753
+ editable: false,
754
+ isCustom: true,
755
+ uiPermissions: {
756
+ ...import_constants.emptyUiPermissions,
757
+ deployments: [import_constants.uiPermissionsById.deploy.value],
758
+ groups: { dyn: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value] }
759
+ }
760
+ },
761
+ kljlkk: {
762
+ editable: true,
763
+ isCustom: false,
764
+ uiPermissions: { ...import_constants.emptyUiPermissions, groups: { bestgroup: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.connect.value] } }
765
+ },
766
+ yyyyy: {
767
+ editable: true,
768
+ isCustom: void 0,
769
+ uiPermissions: {
770
+ ...import_constants.emptyUiPermissions,
771
+ groups: { dockerclient: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value] },
772
+ releases: { [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value] }
773
+ }
774
+ },
775
+ almostAdmin: {
776
+ editable: false,
777
+ isCustom: true,
778
+ uiPermissions: {
779
+ ...import_constants.emptyUiPermissions,
780
+ auditlog: [import_constants.uiPermissionsById.read.value],
781
+ deployments: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.read.value],
782
+ groups: {
783
+ [import_constants.ALL_DEVICES]: [
784
+ import_constants.uiPermissionsById.read.value,
785
+ // we can't assign deployment permissions to devices here, since the old path based rbac controls don't allow the scoped permissions
786
+ // uiPermissionsById.deploy.value,
787
+ import_constants.uiPermissionsById.manage.value,
788
+ import_constants.uiPermissionsById.connect.value,
789
+ import_constants.uiPermissionsById.configure.value
790
+ ]
791
+ },
792
+ releases: {
793
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.manage.value]
794
+ },
795
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
796
+ }
797
+ },
798
+ almostAdminNew: {
799
+ editable: true,
800
+ isCustom: void 0,
801
+ uiPermissions: {
802
+ ...import_constants.emptyUiPermissions,
803
+ auditlog: [import_constants.uiPermissionsById.read.value],
804
+ deployments: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.deploy.value, import_constants.uiPermissionsById.manage.value],
805
+ groups: {
806
+ [import_constants.ALL_DEVICES]: [
807
+ import_constants.uiPermissionsById.read.value,
808
+ import_constants.uiPermissionsById.manage.value,
809
+ import_constants.uiPermissionsById.deploy.value,
810
+ import_constants.uiPermissionsById.connect.value,
811
+ import_constants.uiPermissionsById.configure.value
812
+ ]
813
+ },
814
+ releases: {
815
+ [import_constants.ALL_RELEASES]: [import_constants.uiPermissionsById.manage.value, import_constants.uiPermissionsById.upload.value, import_constants.uiPermissionsById.read.value]
816
+ },
817
+ tenantManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value],
818
+ userManagement: [import_constants.uiPermissionsById.read.value, import_constants.uiPermissionsById.manage.value]
819
+ }
820
+ }
821
+ };
822
+ var defaultRolesById = {
823
+ ...import_constants.rolesById,
824
+ test: {
825
+ ...import_constants.emptyRole,
826
+ name: "test",
827
+ description: "test description",
828
+ editable: true,
829
+ uiPermissions: {
830
+ ...import_constants.emptyUiPermissions,
831
+ groups: { testGroup: [import_constants.uiPermissionsById.read.value] },
832
+ releases: { bar: [import_constants.uiPermissionsById.read.value] }
833
+ }
834
+ }
835
+ };
836
+ var receivedRoles = rbacRoles.reduce(
837
+ (accu, role) => {
838
+ const { name, description, ...roleRemainder } = role;
839
+ if (name.startsWith("RBAC")) {
840
+ accu[name] = {
841
+ ...defaultRolesById[name],
842
+ ...roleRemainder,
843
+ editable: false,
844
+ isCustom: false,
845
+ description: defaultRolesById[name].description ? defaultRolesById[name].description : description
846
+ };
847
+ } else {
848
+ const result = expectedParsedRoles[name] ?? {};
849
+ accu[name] = {
850
+ ...import_constants.emptyRole,
851
+ ...role,
852
+ ...result,
853
+ name
854
+ };
855
+ }
856
+ return accu;
857
+ },
858
+ { ...defaultRolesById }
859
+ );
860
+ var receivedPermissionSets = permissionSets.reduce((accu, set) => {
861
+ const result = import_constants.defaultPermissionSets[set.name]?.result ?? {};
862
+ accu[set.name] = {
863
+ ...set,
864
+ result: {
865
+ ...import_constants.emptyUiPermissions,
866
+ ...result
867
+ }
868
+ };
869
+ return accu;
870
+ }, {});
871
+
872
+ // src/requestHandlers/organizationHandlers.ts
873
+ var PLANS = {
874
+ os: { id: "os", name: "Basic" },
875
+ professional: { id: "professional", name: "Professional" },
876
+ enterprise: { id: "enterprise", name: "Enterprise" }
877
+ };
878
+ var releasesSample = {
879
+ lts: ["3.3"],
880
+ releases: {
881
+ "3.2": {
882
+ "3.2.1": {
883
+ release_date: "2022-02-02",
884
+ release: "3.2.1",
885
+ repos: [
886
+ { name: "integration", version: "1.2.3" },
887
+ { name: "mender", version: "3.2.1" },
888
+ { name: "mender-artifact", version: "1.3.7" },
889
+ { name: "service", version: "3.0.0" },
890
+ { name: "other-service", version: "1.1.0" }
891
+ ]
892
+ },
893
+ "3.2.0": {
894
+ release_date: "2022-01-24",
895
+ release: "3.2.0",
896
+ repos: [
897
+ { name: "service", version: "3.0.0" },
898
+ { name: "another-service", version: "4.1.0" }
899
+ ]
900
+ }
901
+ },
902
+ "2.7": {
903
+ "2.7.2": {
904
+ release_date: "2021-11-04",
905
+ release: "2.7.2",
906
+ repos: [
907
+ { name: "service", version: "1.1.0" },
908
+ { name: "more-service", version: "1.0.2" }
909
+ ]
910
+ }
911
+ },
912
+ "1.0": {
913
+ supported_until: "2018-02",
914
+ "1.0.1": {
915
+ release_date: "2017-04-03",
916
+ release: "1.0.1",
917
+ repos: [{ name: "service", version: "1.0.1" }]
918
+ },
919
+ "1.0.0": {
920
+ release_date: "2017-02-16",
921
+ release: "1.0.0",
922
+ repos: [{ name: "mono-service", version: "1.0.0" }]
923
+ }
924
+ }
925
+ },
926
+ saas: [
927
+ { tag: "saas-v2022.03.10", date: "2022-03-09" },
928
+ { tag: "saas-v2020.09.25", date: "2020-09-24" },
929
+ { tag: "saas-v2020.07.09", date: "2020-07-09" }
930
+ ]
931
+ };
932
+ var tagsSample = [{ name: "saas-v2023.05.02", more: "here" }];
933
+ var signupHandler = async ({ request }) => {
934
+ const signup = await request.json();
935
+ if (["email", "organization", "plan", "tos"].every((item) => !!signup[item])) {
936
+ return import_msw.HttpResponse.text("test");
937
+ }
938
+ return new import_msw.HttpResponse(null, { status: 400 });
939
+ };
940
+ var invoicePreviewBasic = {
941
+ id: "upcoming_in_1RlAkbFlFfXikjZVOHK5VQx0",
942
+ period_start: "2025-07-15T15:25:22Z",
943
+ period_end: "2025-08-15T15:25:22Z",
944
+ total: 3200,
945
+ currency: "usd",
946
+ lines: [
947
+ {
948
+ description: "50 device \xD7 Mender Basic (Tier 1 at $0.00 / month)",
949
+ amount: 0,
950
+ currency: "usd",
951
+ product: "mender_standard",
952
+ quantity: 50,
953
+ price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
954
+ },
955
+ {
956
+ description: "Mender Basic (Tier 1 at $32.00 / month)",
957
+ amount: 3200,
958
+ currency: "usd",
959
+ product: "mender_standard",
960
+ quantity: 0,
961
+ price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
962
+ }
963
+ ]
964
+ };
965
+ var subscriptionBasic = {
966
+ id: "sub_1RlAjOFlFfXikjZVj5BvpJE4",
967
+ status: "active",
968
+ plan: "os",
969
+ products: [
970
+ {
971
+ name: "mender_standard",
972
+ quantity: 50
973
+ }
974
+ ]
975
+ };
976
+ var organizationHandlers = [
977
+ import_msw.http.get("/tags.json", () => import_msw.HttpResponse.json(tagsSample)),
978
+ import_msw.http.get("/versions.json", () => import_msw.HttpResponse.json(releasesSample)),
979
+ import_msw.http.get(`${import_constants2.tenantadmApiUrlv1}/user/tenant`, () => import_msw.HttpResponse.json(mockApiResponses.organization.organization)),
980
+ import_msw.http.put(`${import_constants2.tenantadmApiUrlv2}/tenants/:tenantId/child`, () => new import_msw.HttpResponse(null, { status: 200 })),
981
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/tenants/:tenantId/cancel`, () => new import_msw.HttpResponse(null, { status: 200 })),
982
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
983
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/tenants`, async ({ request }) => {
984
+ const { users } = await request.json();
985
+ const { email } = users[0];
986
+ if (email.includes("bad")) {
987
+ return new import_msw.HttpResponse(null, { status: 553 });
988
+ }
989
+ return new import_msw.HttpResponse(null, { status: 200 });
990
+ }),
991
+ import_msw.http.post(`https://hosted.mender.io${import_constants2.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
992
+ import_msw.http.get(`${import_constants2.tenantadmApiUrlv2}/tenants`, () => import_msw.HttpResponse.json(tenants)),
993
+ import_msw.http.get(`${import_constants2.tenantadmApiUrlv2}/billing`, () => import_msw.HttpResponse.json({ card: { last4: "7890", exp_month: 1, exp_year: 2024, brand: "testCorp" } })),
994
+ import_msw.http.get(
995
+ `${import_constants2.tenantadmApiUrlv2}/billing/profile`,
996
+ () => import_msw.HttpResponse.json({
997
+ name: "company",
998
+ email: "test@test.com",
999
+ address: { state: "OSLO", line1: "Blindern", country: "NO", city: "OSLO", postal_code: "0123" },
1000
+ shipping: { address: { state: "OSLO", line1: "Blindern", country: "NO", city: "OSLO", postal_code: "0123" } }
1001
+ })
1002
+ ),
1003
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/billing/card`, () => import_msw.HttpResponse.json({ intent_id: mockApiResponses.organization.intentId, secret: "testSecret" })),
1004
+ import_msw.http.post(
1005
+ `${import_constants2.tenantadmApiUrlv2}/billing/card/:intentId/confirm`,
1006
+ ({ params: { intentId } }) => new import_msw.HttpResponse(null, { status: intentId == mockApiResponses.organization.intentId ? 200 : 540 })
1007
+ ),
1008
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/tenants/:tenantId/upgrade/:status`, async ({ params: { status, tenantId }, request }) => {
1009
+ if (tenantId != mockApiResponses.organization.organization.id || !["cancel", "complete", "start"].includes(status)) {
1010
+ return new import_msw.HttpResponse(null, { status: 541 });
1011
+ }
1012
+ if (status === "start") {
1013
+ return import_msw.HttpResponse.json({ secret: "testSecret" });
1014
+ }
1015
+ let plan;
1016
+ try {
1017
+ const body = await request.json();
1018
+ plan = body.plan;
1019
+ } catch {
1020
+ }
1021
+ if (plan && !Object.keys(PLANS).includes(plan)) {
1022
+ return new import_msw.HttpResponse(null, { status: 542 });
1023
+ }
1024
+ return new import_msw.HttpResponse(null, { status: 200 });
1025
+ }),
1026
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/tenants/:tenantId/plan`, async ({ params: { tenantId }, request }) => {
1027
+ const body = await request.json();
1028
+ const expectedKeys = ["current_plan", "requested_plan", "current_addons", "requested_addons", "user_message"];
1029
+ if (tenantId != mockApiResponses.organization.organization.id || !Object.keys(body).every((key) => expectedKeys.includes(key))) {
1030
+ return new import_msw.HttpResponse(null, { status: 544 });
1031
+ }
1032
+ if (body.requested_plan && !Object.values(PLANS).some((item) => item.name === body.requested_plan)) {
1033
+ return new import_msw.HttpResponse(null, { status: 545 });
1034
+ }
1035
+ return new import_msw.HttpResponse(null, { status: 200 });
1036
+ }),
1037
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/contact/support`, async ({ request }) => {
1038
+ const { subject, body } = await request.json();
1039
+ if (!(subject && body)) {
1040
+ return new import_msw.HttpResponse(null, { status: 543 });
1041
+ }
1042
+ return new import_msw.HttpResponse(null, { status: 200 });
1043
+ }),
1044
+ import_msw.http.patch(`${import_constants2.tenantadmApiUrlv2}/billing/profile`, () => new import_msw.HttpResponse(null, { status: 200 })),
1045
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/billing/profile`, () => new import_msw.HttpResponse(null, { status: 200 })),
1046
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/billing/subscription`, () => new import_msw.HttpResponse(null, { status: 202 })),
1047
+ import_msw.http.post(`${import_constants2.tenantadmApiUrlv2}/billing/subscription/invoices/preview`, () => import_msw.HttpResponse.json(invoicePreviewBasic)),
1048
+ import_msw.http.get(`${import_constants2.tenantadmApiUrlv2}/billing/subscription`, () => import_msw.HttpResponse.json(subscriptionBasic)),
1049
+ import_msw.http.get(`${import_constants2.tenantadmApiUrlv2}/billing/products`, () => import_msw.HttpResponse.json(mockApiResponses.organization.products)),
1050
+ import_msw.http.get(`${import_constants2.auditLogsApiUrl}/logs`, ({ request }) => {
1051
+ const { searchParams } = new URL(request.url);
1052
+ const perPage = Number(searchParams.get("per_page"));
1053
+ if (perPage === 500) {
1054
+ return import_msw.HttpResponse.json([
1055
+ { meta: mockApiResponses.organization.auditlog.events[2].meta, time: mockApiResponses.organization.auditlog.events[1].time, action: "close_terminal" }
1056
+ ]);
1057
+ }
1058
+ return new import_msw.HttpResponse(JSON.stringify(mockApiResponses.organization.auditlog.events), {
1059
+ headers: { [import_constants2.headerNames.total]: mockApiResponses.organization.auditlog.events.length }
1060
+ });
1061
+ }),
1062
+ import_msw.http.get(
1063
+ `${import_constants2.auditLogsApiUrl}/logs/export`,
1064
+ () => import_msw.HttpResponse.text(`action,actor.id,actor.type,actor.email,actor.identity_data,object.id,object.type,object.user.email,object.deployment.name,object.deployment.artifact_name,change
1065
+ update,5c56c2ed-2a9a-5de9-bb86-cf38b3d4a5e1,user,test@example.coim,,067f23a9-76a5-5585-b119-32402a120978,user,test@example.com,,,"Update user 067f23a9-76a5-5585-b119-32402a120978 (test@example.com).
1066
+ Diff:
1067
+ --- Original
1068
+ +++ Current
1069
+ @@ -9 +9,2 @@
1070
+ - ""RBAC_ROLE_OBSERVER""
1071
+ + ""RBAC_ROLE_OBSERVER"",
1072
+ + ""RBAC_ROLE_PERMIT_ALL""
1073
+ "
1074
+ `)
1075
+ ),
1076
+ import_msw.http.get(
1077
+ `${import_constants2.iotManagerBaseURL}/integrations`,
1078
+ () => import_msw.HttpResponse.json([
1079
+ { connection_string: "something_else", id: 1, provider: "iot-hub" },
1080
+ { id: 2, provider: "iot-core", something: "new" }
1081
+ ])
1082
+ ),
1083
+ import_msw.http.post(`${import_constants2.iotManagerBaseURL}/integrations`, () => import_msw.HttpResponse.json([{ connection_string: "something_else", provider: "iot-hub" }])),
1084
+ import_msw.http.put(`${import_constants2.iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
1085
+ if (!integrationId) {
1086
+ return new import_msw.HttpResponse(null, { status: 547 });
1087
+ }
1088
+ return new import_msw.HttpResponse(null, { status: 200 });
1089
+ }),
1090
+ import_msw.http.put(`${import_constants2.iotManagerBaseURL}/integrations/:integrationId/credentials`, ({ params: { integrationId } }) => {
1091
+ if (!integrationId) {
1092
+ return new import_msw.HttpResponse(null, { status: 548 });
1093
+ }
1094
+ return new import_msw.HttpResponse(null, { status: 200 });
1095
+ }),
1096
+ import_msw.http.delete(`${import_constants2.iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
1097
+ if (!integrationId) {
1098
+ return new import_msw.HttpResponse(null, { status: 549 });
1099
+ }
1100
+ return new import_msw.HttpResponse(null, { status: 200 });
1101
+ }),
1102
+ import_msw.http.get(`${import_constants2.iotManagerBaseURL}/events`, ({ request }) => {
1103
+ const { searchParams } = new URL(request.url);
1104
+ const page = Number(searchParams.get("page"));
1105
+ const perPage = Number(searchParams.get("per_page"));
1106
+ return import_msw.HttpResponse.json(webhookEvents.slice(page - 1, page * perPage));
1107
+ }),
1108
+ import_msw.http.get(
1109
+ import_constants2.ssoIdpApiUrlv1,
1110
+ () => import_msw.HttpResponse.json([
1111
+ { id: "1", issuer: "https://samltest.id/saml/idp", valid_until: "2038-08-24T21:14:09Z" },
1112
+ { id: "2", issuer: "https://samltest2.id/saml/idp", valid_until: "2030-10-24T21:14:09Z" }
1113
+ ])
1114
+ ),
1115
+ import_msw.http.post(import_constants2.ssoIdpApiUrlv1, () => new import_msw.HttpResponse(null, { status: 200 })),
1116
+ import_msw.http.get(`${import_constants2.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => {
1117
+ if (!configId) {
1118
+ return new import_msw.HttpResponse(null, { status: 550 });
1119
+ }
1120
+ return import_msw.HttpResponse.json({ email: "user@acme.com", password: "mypass1234", login: { google: "bob@gmail.com" }, config: "<div>not quite right</div>" });
1121
+ }),
1122
+ import_msw.http.put(`${import_constants2.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new import_msw.HttpResponse(null, { status: configId ? 200 : 551 })),
1123
+ import_msw.http.delete(`${import_constants2.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new import_msw.HttpResponse(null, { status: configId ? 200 : 552 }))
1124
+ ];
1125
+ // Annotate the CommonJS export names for ESM import in node:
1126
+ 0 && (module.exports = {
1127
+ organizationHandlers
1128
+ });
1129
+ //# sourceMappingURL=organizationHandlers.cjs.map