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