@northern.tech/testing 0.8.3 → 0.9.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 (101) hide show
  1. package/dist/chunk-CKQMccvm.cjs +28 -0
  2. package/dist/mockData.cjs +1288 -953
  3. package/dist/mockData.cjs.map +1 -1
  4. package/dist/mockData.d.cts +595 -569
  5. package/dist/mockData.d.ts +595 -569
  6. package/dist/mockData.js +1278 -45
  7. package/dist/mockData.js.map +1 -1
  8. package/dist/openapi.yaml.d.cjs +0 -0
  9. package/dist/openapi.yaml.d.cts +4 -0
  10. package/dist/openapi.yaml.d.ts +5 -0
  11. package/dist/requestHandlers/deploymentHandlers.cjs +181 -1031
  12. package/dist/requestHandlers/deploymentHandlers.cjs.map +1 -1
  13. package/dist/requestHandlers/deploymentHandlers.d.cts +5 -3
  14. package/dist/requestHandlers/deploymentHandlers.d.ts +5 -3
  15. package/dist/requestHandlers/deploymentHandlers.js +190 -6
  16. package/dist/requestHandlers/deploymentHandlers.js.map +1 -1
  17. package/dist/requestHandlers/deviceHandlers.cjs +427 -1090
  18. package/dist/requestHandlers/deviceHandlers.cjs.map +1 -1
  19. package/dist/requestHandlers/deviceHandlers.d.cts +17 -15
  20. package/dist/requestHandlers/deviceHandlers.d.ts +17 -15
  21. package/dist/requestHandlers/deviceHandlers.js +427 -10
  22. package/dist/requestHandlers/deviceHandlers.js.map +1 -1
  23. package/dist/requestHandlers/monitorHandlers.cjs +21 -831
  24. package/dist/requestHandlers/monitorHandlers.cjs.map +1 -1
  25. package/dist/requestHandlers/monitorHandlers.d.cts +5 -3
  26. package/dist/requestHandlers/monitorHandlers.d.ts +5 -3
  27. package/dist/requestHandlers/monitorHandlers.js +21 -7
  28. package/dist/requestHandlers/monitorHandlers.js.map +1 -1
  29. package/dist/requestHandlers/organizationHandlers.cjs +296 -1113
  30. package/dist/requestHandlers/organizationHandlers.cjs.map +1 -1
  31. package/dist/requestHandlers/organizationHandlers.d.cts +5 -3
  32. package/dist/requestHandlers/organizationHandlers.d.ts +5 -3
  33. package/dist/requestHandlers/organizationHandlers.js +308 -6
  34. package/dist/requestHandlers/organizationHandlers.js.map +1 -1
  35. package/dist/requestHandlers/releaseHandlers.cjs +157 -960
  36. package/dist/requestHandlers/releaseHandlers.cjs.map +1 -1
  37. package/dist/requestHandlers/releaseHandlers.d.cts +5 -3
  38. package/dist/requestHandlers/releaseHandlers.d.ts +5 -3
  39. package/dist/requestHandlers/releaseHandlers.js +158 -6
  40. package/dist/requestHandlers/releaseHandlers.js.map +1 -1
  41. package/dist/requestHandlers/requestHandlers.cjs +26 -2000
  42. package/dist/requestHandlers/requestHandlers.cjs.map +1 -1
  43. package/dist/requestHandlers/requestHandlers.d.cts +5 -4
  44. package/dist/requestHandlers/requestHandlers.d.ts +5 -3
  45. package/dist/requestHandlers/requestHandlers.js +24 -32
  46. package/dist/requestHandlers/requestHandlers.js.map +1 -1
  47. package/dist/requestHandlers/userHandlers.cjs +139 -990
  48. package/dist/requestHandlers/userHandlers.cjs.map +1 -1
  49. package/dist/requestHandlers/userHandlers.d.cts +5 -3
  50. package/dist/requestHandlers/userHandlers.d.ts +5 -3
  51. package/dist/requestHandlers/userHandlers.js +139 -7
  52. package/dist/requestHandlers/userHandlers.js.map +1 -1
  53. package/dist/requestHandlers/validation.cjs +4 -0
  54. package/dist/requestHandlers/validation.d.cts +6 -0
  55. package/dist/requestHandlers/validation.d.ts +6 -0
  56. package/dist/requestHandlers/validation.js +2 -0
  57. package/dist/setupTests.cjs +148 -992
  58. package/dist/setupTests.cjs.map +1 -1
  59. package/dist/setupTests.d.cts +68 -66
  60. package/dist/setupTests.d.ts +68 -66
  61. package/dist/setupTests.js +114 -117
  62. package/dist/setupTests.js.map +1 -1
  63. package/dist/theme/light.cjs +7 -39
  64. package/dist/theme/light.cjs.map +1 -1
  65. package/dist/theme/light.d.cts +5 -10
  66. package/dist/theme/light.d.ts +5 -10
  67. package/dist/theme/light.js +7 -6
  68. package/dist/theme/light.js.map +1 -1
  69. package/dist/theme/mui.d.cjs +0 -0
  70. package/dist/theme/mui.d.cts +11 -0
  71. package/dist/theme/mui.d.ts +11 -0
  72. package/dist/utils.cjs +18 -68
  73. package/dist/utils.cjs.map +1 -1
  74. package/dist/utils.d.cts +6 -67
  75. package/dist/utils.d.ts +6 -67
  76. package/dist/utils.js +16 -10
  77. package/dist/utils.js.map +1 -1
  78. package/dist/validation-CsEFO-Cv.cjs +77 -0
  79. package/dist/validation-CsEFO-Cv.cjs.map +1 -0
  80. package/dist/validation-JDM_vsFz.js +64 -0
  81. package/dist/validation-JDM_vsFz.js.map +1 -0
  82. package/package.json +8 -6
  83. package/dist/chunk-3CVNBMEF.js +0 -161
  84. package/dist/chunk-3CVNBMEF.js.map +0 -1
  85. package/dist/chunk-7GNK7IRV.js +0 -29
  86. package/dist/chunk-7GNK7IRV.js.map +0 -1
  87. package/dist/chunk-AP4MOFMD.js +0 -239
  88. package/dist/chunk-AP4MOFMD.js.map +0 -1
  89. package/dist/chunk-DOHA53UH.js +0 -301
  90. package/dist/chunk-DOHA53UH.js.map +0 -1
  91. package/dist/chunk-H4J7L3HX.js +0 -188
  92. package/dist/chunk-H4J7L3HX.js.map +0 -1
  93. package/dist/chunk-HRGVXWMH.js +0 -17
  94. package/dist/chunk-HRGVXWMH.js.map +0 -1
  95. package/dist/chunk-KCLTR6QS.js +0 -34
  96. package/dist/chunk-KCLTR6QS.js.map +0 -1
  97. package/dist/chunk-M2TKDOPD.js +0 -266
  98. package/dist/chunk-M2TKDOPD.js.map +0 -1
  99. package/dist/chunk-O42KIJXJ.js +0 -933
  100. package/dist/chunk-O42KIJXJ.js.map +0 -1
  101. /package/dist/{baseTestConfig.json → public/baseTestConfig.json} +0 -0
@@ -1,1067 +1,248 @@
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 });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../chunk-CKQMccvm.cjs");
3
+ const require_mockData = require("../mockData.cjs");
4
+ const require_validation = require("../validation-CsEFO-Cv.cjs");
5
+ let _northern_tech_utils_constants = require("@northern.tech/utils/constants");
6
+ let msw = require("msw");
7
+ //#region src/requestHandlers/organizationHandlers.ts
8
+ const PLANS = {
9
+ os: {
10
+ id: "os",
11
+ name: "Basic"
12
+ },
13
+ professional: {
14
+ id: "professional",
15
+ name: "Professional"
16
+ },
17
+ enterprise: {
18
+ id: "enterprise",
19
+ name: "Enterprise"
20
+ }
9
21
  };
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;
22
+ const releasesSample = {
23
+ lts: ["3.3"],
24
+ releases: {
25
+ "3.2": {
26
+ "3.2.1": {
27
+ release_date: "2022-02-02",
28
+ release: "3.2.1",
29
+ repos: [
30
+ {
31
+ name: "integration",
32
+ version: "1.2.3"
33
+ },
34
+ {
35
+ name: "mender",
36
+ version: "3.2.1"
37
+ },
38
+ {
39
+ name: "mender-artifact",
40
+ version: "1.3.7"
41
+ },
42
+ {
43
+ name: "service",
44
+ version: "3.0.0"
45
+ },
46
+ {
47
+ name: "other-service",
48
+ version: "1.1.0"
49
+ }
50
+ ]
51
+ },
52
+ "3.2.0": {
53
+ release_date: "2022-01-24",
54
+ release: "3.2.0",
55
+ repos: [{
56
+ name: "service",
57
+ version: "3.0.0"
58
+ }, {
59
+ name: "another-service",
60
+ version: "4.1.0"
61
+ }]
62
+ }
63
+ },
64
+ "2.7": { "2.7.2": {
65
+ release_date: "2021-11-04",
66
+ release: "2.7.2",
67
+ repos: [{
68
+ name: "service",
69
+ version: "1.1.0"
70
+ }, {
71
+ name: "more-service",
72
+ version: "1.0.2"
73
+ }]
74
+ } },
75
+ "1.0": {
76
+ supported_until: "2018-02",
77
+ "1.0.1": {
78
+ release_date: "2017-04-03",
79
+ release: "1.0.1",
80
+ repos: [{
81
+ name: "service",
82
+ version: "1.0.1"
83
+ }]
84
+ },
85
+ "1.0.0": {
86
+ release_date: "2017-02-16",
87
+ release: "1.0.0",
88
+ repos: [{
89
+ name: "mono-service",
90
+ version: "1.0.0"
91
+ }]
92
+ }
93
+ }
94
+ },
95
+ saas: [
96
+ {
97
+ tag: "saas-v2022.03.10",
98
+ date: "2022-03-09"
99
+ },
100
+ {
101
+ tag: "saas-v2020.09.25",
102
+ date: "2020-09-24"
103
+ },
104
+ {
105
+ tag: "saas-v2020.07.09",
106
+ date: "2020-07-09"
107
+ }
108
+ ]
17
109
  };
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
110
+ const tagsSample = [{
111
+ name: "saas-v2023.05.02",
112
+ more: "here"
113
+ }];
114
+ const signupHandler = require_validation.validated(async ({ request }) => {
115
+ const signup = await request.json();
116
+ if ([
117
+ "email",
118
+ "organization",
119
+ "plan"
120
+ ].every((item) => !!signup[item])) return msw.HttpResponse.text("test");
121
+ return new msw.HttpResponse(null, { status: 400 });
24
122
  });
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
- ]
123
+ const invoicePreviewBasic = {
124
+ id: "upcoming_in_1RlAkbFlFfXikjZVOHK5VQx0",
125
+ period_start: "2025-07-15T15:25:22Z",
126
+ period_end: "2025-08-15T15:25:22Z",
127
+ total: 3200,
128
+ currency: "usd",
129
+ lines: [{
130
+ description: "50 device × Mender Basic (Tier 1 at $0.00 / month)",
131
+ amount: 0,
132
+ currency: "usd",
133
+ product: "mender_standard",
134
+ quantity: 50,
135
+ price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
136
+ }, {
137
+ description: "Mender Basic (Tier 1 at $32.00 / month)",
138
+ amount: 3200,
139
+ currency: "usd",
140
+ product: "mender_standard",
141
+ quantity: 0,
142
+ price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
143
+ }]
931
144
  };
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 });
145
+ const subscriptionBasic = {
146
+ id: "sub_1RlAjOFlFfXikjZVj5BvpJE4",
147
+ status: "active",
148
+ plan: "os",
149
+ products: [{
150
+ name: "mender_standard",
151
+ quantity: 50
152
+ }]
939
153
  };
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
154
+ const organizationHandlers = [
155
+ msw.http.get("/tags.json", () => msw.HttpResponse.json(tagsSample)),
156
+ msw.http.get("/versions.json", () => msw.HttpResponse.json(releasesSample)),
157
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv1}/user/tenant`, () => msw.HttpResponse.json(require_mockData.mockApiResponses.organization.organization)),
158
+ msw.http.put(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/:tenantId/child`, require_validation.validated(() => new msw.HttpResponse(null, { status: 200 }))),
159
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/:tenantId/cancel`, require_validation.validated(() => new msw.HttpResponse(null, { status: 200 }))),
160
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
161
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants`, async ({ request }) => {
162
+ const { users } = await request.json();
163
+ const { email } = users[0];
164
+ if (email.includes("bad")) return new msw.HttpResponse(null, { status: 553 });
165
+ return new msw.HttpResponse(null, { status: 200 });
166
+ }),
167
+ msw.http.post(`https://hosted.mender.io${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/trial`, signupHandler),
168
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants`, () => msw.HttpResponse.json(require_mockData.tenants)),
169
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing`, () => msw.HttpResponse.json({ card: {
170
+ last4: "7890",
171
+ exp_month: 1,
172
+ exp_year: 2024,
173
+ brand: "testCorp"
174
+ } })),
175
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/profile`, () => msw.HttpResponse.json({
176
+ name: "company",
177
+ email: "test@test.com",
178
+ address: {
179
+ state: "OSLO",
180
+ line1: "Blindern",
181
+ country: "NO",
182
+ city: "OSLO",
183
+ postal_code: "0123"
184
+ },
185
+ shipping: { address: {
186
+ state: "OSLO",
187
+ line1: "Blindern",
188
+ country: "NO",
189
+ city: "OSLO",
190
+ postal_code: "0123"
191
+ } }
192
+ })),
193
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/card`, require_validation.validated(() => msw.HttpResponse.json({
194
+ intent_id: require_mockData.mockApiResponses.organization.intentId,
195
+ secret: "testSecret"
196
+ }))),
197
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/card/:intentId/confirm`, require_validation.validated(({ params: { intentId } }) => new msw.HttpResponse(null, { status: intentId == require_mockData.mockApiResponses.organization.intentId ? 200 : 540 }))),
198
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/:tenantId/upgrade/:status`, async ({ params: { status, tenantId }, request }) => {
199
+ if (tenantId != require_mockData.mockApiResponses.organization.organization.id || ![
200
+ "cancel",
201
+ "complete",
202
+ "start"
203
+ ].includes(status)) return new msw.HttpResponse(null, { status: 541 });
204
+ if (status === "start") return msw.HttpResponse.json({ secret: "testSecret" });
205
+ let plan;
206
+ try {
207
+ plan = (await request.json()).plan;
208
+ } catch {}
209
+ if (plan && !Object.keys(PLANS).includes(plan)) return new msw.HttpResponse(null, { status: 542 });
210
+ return new msw.HttpResponse(null, { status: 200 });
211
+ }),
212
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/:tenantId/plan`, require_validation.validated(async ({ params: { tenantId }, request }) => {
213
+ const body = await request.json();
214
+ const expectedKeys = [
215
+ "current_plan",
216
+ "requested_plan",
217
+ "current_addons",
218
+ "requested_addons",
219
+ "user_message"
220
+ ];
221
+ if (tenantId != require_mockData.mockApiResponses.organization.organization.id || !Object.keys(body).every((key) => expectedKeys.includes(key))) return new msw.HttpResponse(null, { status: 544 });
222
+ if (body.requested_plan && !Object.values(PLANS).some((item) => item.name === body.requested_plan)) return new msw.HttpResponse(null, { status: 545 });
223
+ return new msw.HttpResponse(null, { status: 200 });
224
+ })),
225
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/contact/support`, require_validation.validated(async ({ request }) => {
226
+ const { subject, body } = await request.json();
227
+ if (!(subject && body)) return new msw.HttpResponse(null, { status: 543 });
228
+ return new msw.HttpResponse(null, { status: 200 });
229
+ })),
230
+ msw.http.patch(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/profile`, require_validation.validated(() => new msw.HttpResponse(null, { status: 200 }))),
231
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/profile`, require_validation.validated(() => new msw.HttpResponse(null, { status: 200 }))),
232
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/subscription`, require_validation.validated(() => new msw.HttpResponse(null, { status: 202 }))),
233
+ msw.http.post(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/subscription/invoices/preview`, () => msw.HttpResponse.json(invoicePreviewBasic)),
234
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/subscription`, () => msw.HttpResponse.json(subscriptionBasic)),
235
+ msw.http.get(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/billing/products`, () => msw.HttpResponse.json(require_mockData.mockApiResponses.organization.products)),
236
+ msw.http.get(`${_northern_tech_utils_constants.auditLogsApiUrl}/logs`, ({ request }) => {
237
+ const { searchParams } = new URL(request.url);
238
+ if (Number(searchParams.get("per_page")) === 500) return msw.HttpResponse.json([{
239
+ meta: require_mockData.mockApiResponses.organization.auditlog.events[2].meta,
240
+ time: require_mockData.mockApiResponses.organization.auditlog.events[1].time,
241
+ action: "close_terminal"
242
+ }]);
243
+ return new msw.HttpResponse(JSON.stringify(require_mockData.mockApiResponses.organization.auditlog.events), { headers: { [_northern_tech_utils_constants.headerNames.total]: require_mockData.mockApiResponses.organization.auditlog.events.length } });
244
+ }),
245
+ msw.http.get(`${_northern_tech_utils_constants.auditLogsApiUrl}/logs/export`, () => 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
246
  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
247
  Diff:
1067
248
  --- Original
@@ -1071,59 +252,61 @@ var organizationHandlers = [
1071
252
  + ""RBAC_ROLE_OBSERVER"",
1072
253
  + ""RBAC_ROLE_PERMIT_ALL""
1073
254
  "
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 }))
255
+ `)),
256
+ msw.http.get(`${_northern_tech_utils_constants.iotManagerBaseURL}/integrations`, () => msw.HttpResponse.json([{
257
+ connection_string: "something_else",
258
+ id: 1,
259
+ provider: "iot-hub"
260
+ }, {
261
+ id: 2,
262
+ provider: "iot-core",
263
+ something: "new"
264
+ }])),
265
+ msw.http.post(`${_northern_tech_utils_constants.iotManagerBaseURL}/integrations`, require_validation.validated(() => msw.HttpResponse.json([{
266
+ connection_string: "something_else",
267
+ provider: "iot-hub"
268
+ }]))),
269
+ msw.http.put(`${_northern_tech_utils_constants.iotManagerBaseURL}/integrations/:integrationId`, require_validation.validated(({ params: { integrationId } }) => {
270
+ if (!integrationId) return new msw.HttpResponse(null, { status: 547 });
271
+ return new msw.HttpResponse(null, { status: 200 });
272
+ })),
273
+ msw.http.put(`${_northern_tech_utils_constants.iotManagerBaseURL}/integrations/:integrationId/credentials`, require_validation.validated(({ params: { integrationId } }) => {
274
+ if (!integrationId) return new msw.HttpResponse(null, { status: 548 });
275
+ return new msw.HttpResponse(null, { status: 200 });
276
+ })),
277
+ msw.http.delete(`${_northern_tech_utils_constants.iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
278
+ if (!integrationId) return new msw.HttpResponse(null, { status: 549 });
279
+ return new msw.HttpResponse(null, { status: 200 });
280
+ }),
281
+ msw.http.get(`${_northern_tech_utils_constants.iotManagerBaseURL}/events`, ({ request }) => {
282
+ const { searchParams } = new URL(request.url);
283
+ const page = Number(searchParams.get("page"));
284
+ const perPage = Number(searchParams.get("per_page"));
285
+ return msw.HttpResponse.json(require_mockData.webhookEvents.slice(page - 1, page * perPage));
286
+ }),
287
+ msw.http.get(_northern_tech_utils_constants.ssoIdpApiUrlv1, () => msw.HttpResponse.json([{
288
+ id: "1",
289
+ issuer: "https://samltest.id/saml/idp",
290
+ valid_until: "2038-08-24T21:14:09Z"
291
+ }, {
292
+ id: "2",
293
+ issuer: "https://samltest2.id/saml/idp",
294
+ valid_until: "2030-10-24T21:14:09Z"
295
+ }])),
296
+ msw.http.post(_northern_tech_utils_constants.ssoIdpApiUrlv1, require_validation.validated(() => new msw.HttpResponse(null, { status: 200 }))),
297
+ msw.http.get(`${_northern_tech_utils_constants.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => {
298
+ if (!configId) return new msw.HttpResponse(null, { status: 550 });
299
+ return msw.HttpResponse.json({
300
+ email: "user@acme.com",
301
+ password: "mypass1234",
302
+ login: { google: "bob@gmail.com" },
303
+ config: "<div>not quite right</div>"
304
+ });
305
+ }),
306
+ msw.http.put(`${_northern_tech_utils_constants.ssoIdpApiUrlv1}/:configId`, require_validation.validated(({ params: { configId } }) => new msw.HttpResponse(null, { status: configId ? 200 : 551 }))),
307
+ msw.http.delete(`${_northern_tech_utils_constants.ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new msw.HttpResponse(null, { status: configId ? 200 : 552 }))
1124
308
  ];
1125
- // Annotate the CommonJS export names for ESM import in node:
1126
- 0 && (module.exports = {
1127
- organizationHandlers
1128
- });
309
+ //#endregion
310
+ exports.organizationHandlers = organizationHandlers;
311
+
1129
312
  //# sourceMappingURL=organizationHandlers.cjs.map