@northern.tech/testing 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/package.json +2 -4
  2. package/dist/baseTestConfig.json +0 -17
  3. package/dist/chunk-5ESUU7GT.js +0 -266
  4. package/dist/chunk-5ESUU7GT.js.map +0 -1
  5. package/dist/chunk-CGSW2XF4.js +0 -318
  6. package/dist/chunk-CGSW2XF4.js.map +0 -1
  7. package/dist/chunk-GPKMKZ6O.js +0 -161
  8. package/dist/chunk-GPKMKZ6O.js.map +0 -1
  9. package/dist/chunk-GQLNLYEI.js +0 -934
  10. package/dist/chunk-GQLNLYEI.js.map +0 -1
  11. package/dist/chunk-HRGVXWMH.js +0 -17
  12. package/dist/chunk-HRGVXWMH.js.map +0 -1
  13. package/dist/chunk-KCLTR6QS.js +0 -34
  14. package/dist/chunk-KCLTR6QS.js.map +0 -1
  15. package/dist/chunk-T3BKBWUF.js +0 -239
  16. package/dist/chunk-T3BKBWUF.js.map +0 -1
  17. package/dist/chunk-TSEGY3EV.js +0 -29
  18. package/dist/chunk-TSEGY3EV.js.map +0 -1
  19. package/dist/chunk-Y4IJBU7U.js +0 -188
  20. package/dist/chunk-Y4IJBU7U.js.map +0 -1
  21. package/dist/mockData.cjs +0 -968
  22. package/dist/mockData.cjs.map +0 -1
  23. package/dist/mockData.d.cts +0 -636
  24. package/dist/mockData.d.ts +0 -636
  25. package/dist/mockData.js +0 -47
  26. package/dist/mockData.js.map +0 -1
  27. package/dist/requestHandlers/deploymentHandlers.cjs +0 -1045
  28. package/dist/requestHandlers/deploymentHandlers.cjs.map +0 -1
  29. package/dist/requestHandlers/deploymentHandlers.d.cts +0 -5
  30. package/dist/requestHandlers/deploymentHandlers.d.ts +0 -5
  31. package/dist/requestHandlers/deploymentHandlers.js +0 -8
  32. package/dist/requestHandlers/deploymentHandlers.js.map +0 -1
  33. package/dist/requestHandlers/deviceHandlers.cjs +0 -1113
  34. package/dist/requestHandlers/deviceHandlers.cjs.map +0 -1
  35. package/dist/requestHandlers/deviceHandlers.d.cts +0 -20
  36. package/dist/requestHandlers/deviceHandlers.d.ts +0 -20
  37. package/dist/requestHandlers/deviceHandlers.js +0 -12
  38. package/dist/requestHandlers/deviceHandlers.js.map +0 -1
  39. package/dist/requestHandlers/monitorHandlers.cjs +0 -835
  40. package/dist/requestHandlers/monitorHandlers.cjs.map +0 -1
  41. package/dist/requestHandlers/monitorHandlers.d.cts +0 -5
  42. package/dist/requestHandlers/monitorHandlers.d.ts +0 -5
  43. package/dist/requestHandlers/monitorHandlers.js +0 -8
  44. package/dist/requestHandlers/monitorHandlers.js.map +0 -1
  45. package/dist/requestHandlers/organizationHandlers.cjs +0 -1130
  46. package/dist/requestHandlers/organizationHandlers.cjs.map +0 -1
  47. package/dist/requestHandlers/organizationHandlers.d.cts +0 -5
  48. package/dist/requestHandlers/organizationHandlers.d.ts +0 -5
  49. package/dist/requestHandlers/organizationHandlers.js +0 -8
  50. package/dist/requestHandlers/organizationHandlers.js.map +0 -1
  51. package/dist/requestHandlers/releaseHandlers.cjs +0 -966
  52. package/dist/requestHandlers/releaseHandlers.cjs.map +0 -1
  53. package/dist/requestHandlers/releaseHandlers.d.cts +0 -5
  54. package/dist/requestHandlers/releaseHandlers.d.ts +0 -5
  55. package/dist/requestHandlers/releaseHandlers.js +0 -8
  56. package/dist/requestHandlers/releaseHandlers.js.map +0 -1
  57. package/dist/requestHandlers/requestHandlers.cjs +0 -2019
  58. package/dist/requestHandlers/requestHandlers.cjs.map +0 -1
  59. package/dist/requestHandlers/requestHandlers.d.cts +0 -5
  60. package/dist/requestHandlers/requestHandlers.d.ts +0 -5
  61. package/dist/requestHandlers/requestHandlers.js +0 -35
  62. package/dist/requestHandlers/requestHandlers.js.map +0 -1
  63. package/dist/requestHandlers/userHandlers.cjs +0 -994
  64. package/dist/requestHandlers/userHandlers.cjs.map +0 -1
  65. package/dist/requestHandlers/userHandlers.d.cts +0 -5
  66. package/dist/requestHandlers/userHandlers.d.ts +0 -5
  67. package/dist/requestHandlers/userHandlers.js +0 -8
  68. package/dist/requestHandlers/userHandlers.js.map +0 -1
  69. package/dist/setupTests.cjs +0 -996
  70. package/dist/setupTests.cjs.map +0 -1
  71. package/dist/setupTests.d.cts +0 -77
  72. package/dist/setupTests.d.ts +0 -77
  73. package/dist/setupTests.js +0 -138
  74. package/dist/setupTests.js.map +0 -1
  75. package/dist/theme/light.cjs +0 -41
  76. package/dist/theme/light.cjs.map +0 -1
  77. package/dist/theme/light.d.cts +0 -12
  78. package/dist/theme/light.d.ts +0 -12
  79. package/dist/theme/light.js +0 -7
  80. package/dist/theme/light.js.map +0 -1
  81. package/dist/utils.cjs +0 -71
  82. package/dist/utils.cjs.map +0 -1
  83. package/dist/utils.d.cts +0 -69
  84. package/dist/utils.d.ts +0 -69
  85. package/dist/utils.js +0 -12
  86. package/dist/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@northern.tech/testing",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -31,9 +31,7 @@
31
31
  "build": "tsup --publicDir",
32
32
  "dev": "tsup --watch --no-dts --onSuccess 'yalc publish --no-script --push'",
33
33
  "lint": "eslint --quiet .",
34
- "format:check": "prettier --check \"src/**/*.{js,ts,jsx,tsx,less}\"",
35
- "publish": "npm publish",
36
- "pre-publish": "npm publish --tag next"
34
+ "format:check": "prettier --check \"src/**/*.{js,ts,jsx,tsx,less}\""
37
35
  },
38
36
  "type": "module",
39
37
  "sideEffects": false,
@@ -1,17 +0,0 @@
1
- {
2
- "server": {
3
- "port": 80,
4
- "middlewareMode": false
5
- },
6
- "test": {
7
- "env": {
8
- "BABEL_ENV": "test",
9
- "NODE_ENV": "test",
10
- "PUBLIC_URL": "",
11
- "TZ": "UTC"
12
- },
13
- "retry": 0,
14
- "environment": "jsdom",
15
- "globals": true
16
- }
17
- }
@@ -1,266 +0,0 @@
1
- import {
2
- mockApiResponses,
3
- tenants,
4
- webhookEvents
5
- } from "./chunk-GQLNLYEI.js";
6
-
7
- // src/requestHandlers/organizationHandlers.ts
8
- import { auditLogsApiUrl, headerNames, iotManagerBaseURL, ssoIdpApiUrlv1, tenantadmApiUrlv1, tenantadmApiUrlv2 } from "@northern.tech/utils/constants";
9
- import { HttpResponse, http } from "msw";
10
- var PLANS = {
11
- os: { id: "os", name: "Basic" },
12
- professional: { id: "professional", name: "Professional" },
13
- enterprise: { id: "enterprise", name: "Enterprise" }
14
- };
15
- var releasesSample = {
16
- lts: ["3.3"],
17
- releases: {
18
- "3.2": {
19
- "3.2.1": {
20
- release_date: "2022-02-02",
21
- release: "3.2.1",
22
- repos: [
23
- { name: "integration", version: "1.2.3" },
24
- { name: "mender", version: "3.2.1" },
25
- { name: "mender-artifact", version: "1.3.7" },
26
- { name: "service", version: "3.0.0" },
27
- { name: "other-service", version: "1.1.0" }
28
- ]
29
- },
30
- "3.2.0": {
31
- release_date: "2022-01-24",
32
- release: "3.2.0",
33
- repos: [
34
- { name: "service", version: "3.0.0" },
35
- { name: "another-service", version: "4.1.0" }
36
- ]
37
- }
38
- },
39
- "2.7": {
40
- "2.7.2": {
41
- release_date: "2021-11-04",
42
- release: "2.7.2",
43
- repos: [
44
- { name: "service", version: "1.1.0" },
45
- { name: "more-service", version: "1.0.2" }
46
- ]
47
- }
48
- },
49
- "1.0": {
50
- supported_until: "2018-02",
51
- "1.0.1": {
52
- release_date: "2017-04-03",
53
- release: "1.0.1",
54
- repos: [{ name: "service", version: "1.0.1" }]
55
- },
56
- "1.0.0": {
57
- release_date: "2017-02-16",
58
- release: "1.0.0",
59
- repos: [{ name: "mono-service", version: "1.0.0" }]
60
- }
61
- }
62
- },
63
- saas: [
64
- { tag: "saas-v2022.03.10", date: "2022-03-09" },
65
- { tag: "saas-v2020.09.25", date: "2020-09-24" },
66
- { tag: "saas-v2020.07.09", date: "2020-07-09" }
67
- ]
68
- };
69
- var tagsSample = [{ name: "saas-v2023.05.02", more: "here" }];
70
- var signupHandler = async ({ request }) => {
71
- const signup = await request.json();
72
- if (["email", "organization", "plan", "tos"].every((item) => !!signup[item])) {
73
- return HttpResponse.text("test");
74
- }
75
- return new HttpResponse(null, { status: 400 });
76
- };
77
- var invoicePreviewBasic = {
78
- id: "upcoming_in_1RlAkbFlFfXikjZVOHK5VQx0",
79
- period_start: "2025-07-15T15:25:22Z",
80
- period_end: "2025-08-15T15:25:22Z",
81
- total: 3200,
82
- currency: "usd",
83
- lines: [
84
- {
85
- description: "50 device \xD7 Mender Basic (Tier 1 at $0.00 / month)",
86
- amount: 0,
87
- currency: "usd",
88
- product: "mender_standard",
89
- quantity: 50,
90
- price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
91
- },
92
- {
93
- description: "Mender Basic (Tier 1 at $32.00 / month)",
94
- amount: 3200,
95
- currency: "usd",
96
- product: "mender_standard",
97
- quantity: 0,
98
- price_id: "price_1PYktlFlFfXikjZVh2aNHp7i"
99
- }
100
- ]
101
- };
102
- var subscriptionBasic = {
103
- id: "sub_1RlAjOFlFfXikjZVj5BvpJE4",
104
- status: "active",
105
- plan: "os",
106
- products: [
107
- {
108
- name: "mender_standard",
109
- quantity: 50
110
- }
111
- ]
112
- };
113
- var organizationHandlers = [
114
- http.get("/tags.json", () => HttpResponse.json(tagsSample)),
115
- http.get("/versions.json", () => HttpResponse.json(releasesSample)),
116
- http.get(`${tenantadmApiUrlv1}/user/tenant`, () => HttpResponse.json(mockApiResponses.organization.organization)),
117
- http.put(`${tenantadmApiUrlv2}/tenants/:tenantId/child`, () => new HttpResponse(null, { status: 200 })),
118
- http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/cancel`, () => new HttpResponse(null, { status: 200 })),
119
- http.post(`${tenantadmApiUrlv2}/tenants/trial`, signupHandler),
120
- http.post(`${tenantadmApiUrlv2}/tenants`, async ({ request }) => {
121
- const { users } = await request.json();
122
- const { email } = users[0];
123
- if (email.includes("bad")) {
124
- return new HttpResponse(null, { status: 553 });
125
- }
126
- return new HttpResponse(null, { status: 200 });
127
- }),
128
- http.post(`https://hosted.mender.io${tenantadmApiUrlv2}/tenants/trial`, signupHandler),
129
- http.get(`${tenantadmApiUrlv2}/tenants`, () => HttpResponse.json(tenants)),
130
- http.get(`${tenantadmApiUrlv2}/billing`, () => HttpResponse.json({ card: { last4: "7890", exp_month: 1, exp_year: 2024, brand: "testCorp" } })),
131
- http.get(
132
- `${tenantadmApiUrlv2}/billing/profile`,
133
- () => HttpResponse.json({
134
- name: "company",
135
- email: "test@test.com",
136
- address: { state: "OSLO", line1: "Blindern", country: "NO", city: "OSLO", postal_code: "0123" },
137
- shipping: { address: { state: "OSLO", line1: "Blindern", country: "NO", city: "OSLO", postal_code: "0123" } }
138
- })
139
- ),
140
- http.post(`${tenantadmApiUrlv2}/billing/card`, () => HttpResponse.json({ intent_id: mockApiResponses.organization.intentId, secret: "testSecret" })),
141
- http.post(
142
- `${tenantadmApiUrlv2}/billing/card/:intentId/confirm`,
143
- ({ params: { intentId } }) => new HttpResponse(null, { status: intentId == mockApiResponses.organization.intentId ? 200 : 540 })
144
- ),
145
- http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/upgrade/:status`, async ({ params: { status, tenantId }, request }) => {
146
- if (tenantId != mockApiResponses.organization.organization.id || !["cancel", "complete", "start"].includes(status)) {
147
- return new HttpResponse(null, { status: 541 });
148
- }
149
- if (status === "start") {
150
- return HttpResponse.json({ secret: "testSecret" });
151
- }
152
- let plan;
153
- try {
154
- const body = await request.json();
155
- plan = body.plan;
156
- } catch {
157
- }
158
- if (plan && !Object.keys(PLANS).includes(plan)) {
159
- return new HttpResponse(null, { status: 542 });
160
- }
161
- return new HttpResponse(null, { status: 200 });
162
- }),
163
- http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/plan`, async ({ params: { tenantId }, request }) => {
164
- const body = await request.json();
165
- const expectedKeys = ["current_plan", "requested_plan", "current_addons", "requested_addons", "user_message"];
166
- if (tenantId != mockApiResponses.organization.organization.id || !Object.keys(body).every((key) => expectedKeys.includes(key))) {
167
- return new HttpResponse(null, { status: 544 });
168
- }
169
- if (body.requested_plan && !Object.values(PLANS).some((item) => item.name === body.requested_plan)) {
170
- return new HttpResponse(null, { status: 545 });
171
- }
172
- return new HttpResponse(null, { status: 200 });
173
- }),
174
- http.post(`${tenantadmApiUrlv2}/contact/support`, async ({ request }) => {
175
- const { subject, body } = await request.json();
176
- if (!(subject && body)) {
177
- return new HttpResponse(null, { status: 543 });
178
- }
179
- return new HttpResponse(null, { status: 200 });
180
- }),
181
- http.patch(`${tenantadmApiUrlv2}/billing/profile`, () => new HttpResponse(null, { status: 200 })),
182
- http.post(`${tenantadmApiUrlv2}/billing/profile`, () => new HttpResponse(null, { status: 200 })),
183
- http.post(`${tenantadmApiUrlv2}/billing/subscription`, () => new HttpResponse(null, { status: 202 })),
184
- http.post(`${tenantadmApiUrlv2}/billing/subscription/invoices/preview`, () => HttpResponse.json(invoicePreviewBasic)),
185
- http.get(`${tenantadmApiUrlv2}/billing/subscription`, () => HttpResponse.json(subscriptionBasic)),
186
- http.get(`${tenantadmApiUrlv2}/billing/products`, () => HttpResponse.json(mockApiResponses.organization.products)),
187
- http.get(`${auditLogsApiUrl}/logs`, ({ request }) => {
188
- const { searchParams } = new URL(request.url);
189
- const perPage = Number(searchParams.get("per_page"));
190
- if (perPage === 500) {
191
- return HttpResponse.json([
192
- { meta: mockApiResponses.organization.auditlog.events[2].meta, time: mockApiResponses.organization.auditlog.events[1].time, action: "close_terminal" }
193
- ]);
194
- }
195
- return new HttpResponse(JSON.stringify(mockApiResponses.organization.auditlog.events), {
196
- headers: { [headerNames.total]: mockApiResponses.organization.auditlog.events.length }
197
- });
198
- }),
199
- http.get(
200
- `${auditLogsApiUrl}/logs/export`,
201
- () => 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
202
- 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).
203
- Diff:
204
- --- Original
205
- +++ Current
206
- @@ -9 +9,2 @@
207
- - ""RBAC_ROLE_OBSERVER""
208
- + ""RBAC_ROLE_OBSERVER"",
209
- + ""RBAC_ROLE_PERMIT_ALL""
210
- "
211
- `)
212
- ),
213
- http.get(
214
- `${iotManagerBaseURL}/integrations`,
215
- () => HttpResponse.json([
216
- { connection_string: "something_else", id: 1, provider: "iot-hub" },
217
- { id: 2, provider: "iot-core", something: "new" }
218
- ])
219
- ),
220
- http.post(`${iotManagerBaseURL}/integrations`, () => HttpResponse.json([{ connection_string: "something_else", provider: "iot-hub" }])),
221
- http.put(`${iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
222
- if (!integrationId) {
223
- return new HttpResponse(null, { status: 547 });
224
- }
225
- return new HttpResponse(null, { status: 200 });
226
- }),
227
- http.put(`${iotManagerBaseURL}/integrations/:integrationId/credentials`, ({ params: { integrationId } }) => {
228
- if (!integrationId) {
229
- return new HttpResponse(null, { status: 548 });
230
- }
231
- return new HttpResponse(null, { status: 200 });
232
- }),
233
- http.delete(`${iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {
234
- if (!integrationId) {
235
- return new HttpResponse(null, { status: 549 });
236
- }
237
- return new HttpResponse(null, { status: 200 });
238
- }),
239
- http.get(`${iotManagerBaseURL}/events`, ({ request }) => {
240
- const { searchParams } = new URL(request.url);
241
- const page = Number(searchParams.get("page"));
242
- const perPage = Number(searchParams.get("per_page"));
243
- return HttpResponse.json(webhookEvents.slice(page - 1, page * perPage));
244
- }),
245
- http.get(
246
- ssoIdpApiUrlv1,
247
- () => HttpResponse.json([
248
- { id: "1", issuer: "https://samltest.id/saml/idp", valid_until: "2038-08-24T21:14:09Z" },
249
- { id: "2", issuer: "https://samltest2.id/saml/idp", valid_until: "2030-10-24T21:14:09Z" }
250
- ])
251
- ),
252
- http.post(ssoIdpApiUrlv1, () => new HttpResponse(null, { status: 200 })),
253
- http.get(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => {
254
- if (!configId) {
255
- return new HttpResponse(null, { status: 550 });
256
- }
257
- return HttpResponse.json({ email: "user@acme.com", password: "mypass1234", login: { google: "bob@gmail.com" }, config: "<div>not quite right</div>" });
258
- }),
259
- http.put(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new HttpResponse(null, { status: configId ? 200 : 551 })),
260
- http.delete(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new HttpResponse(null, { status: configId ? 200 : 552 }))
261
- ];
262
-
263
- export {
264
- organizationHandlers
265
- };
266
- //# sourceMappingURL=chunk-5ESUU7GT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/requestHandlers/organizationHandlers.ts"],"sourcesContent":["// Copyright 2020 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport { auditLogsApiUrl, headerNames, iotManagerBaseURL, ssoIdpApiUrlv1, tenantadmApiUrlv1, tenantadmApiUrlv2 } from '@northern.tech/utils/constants';\nimport { HttpResponse, http } from 'msw';\n\nimport { mockApiResponses, tenants, webhookEvents } from '../mockData';\n\nconst PLANS = {\n os: { id: 'os', name: 'Basic' },\n professional: { id: 'professional', name: 'Professional' },\n enterprise: { id: 'enterprise', name: 'Enterprise' }\n};\n\nconst releasesSample = {\n lts: ['3.3'],\n releases: {\n '3.2': {\n '3.2.1': {\n release_date: '2022-02-02',\n release: '3.2.1',\n repos: [\n { name: 'integration', version: '1.2.3' },\n { name: 'mender', version: '3.2.1' },\n { name: 'mender-artifact', version: '1.3.7' },\n { name: 'service', version: '3.0.0' },\n { name: 'other-service', version: '1.1.0' }\n ]\n },\n '3.2.0': {\n release_date: '2022-01-24',\n release: '3.2.0',\n repos: [\n { name: 'service', version: '3.0.0' },\n { name: 'another-service', version: '4.1.0' }\n ]\n }\n },\n '2.7': {\n '2.7.2': {\n release_date: '2021-11-04',\n release: '2.7.2',\n repos: [\n { name: 'service', version: '1.1.0' },\n { name: 'more-service', version: '1.0.2' }\n ]\n }\n },\n '1.0': {\n supported_until: '2018-02',\n '1.0.1': {\n release_date: '2017-04-03',\n release: '1.0.1',\n repos: [{ name: 'service', version: '1.0.1' }]\n },\n '1.0.0': {\n release_date: '2017-02-16',\n release: '1.0.0',\n repos: [{ name: 'mono-service', version: '1.0.0' }]\n }\n }\n },\n saas: [\n { tag: 'saas-v2022.03.10', date: '2022-03-09' },\n { tag: 'saas-v2020.09.25', date: '2020-09-24' },\n { tag: 'saas-v2020.07.09', date: '2020-07-09' }\n ]\n};\n\nconst tagsSample = [{ name: 'saas-v2023.05.02', more: 'here' }];\n\nconst signupHandler = async ({ request }) => {\n const signup = await request.json();\n if (['email', 'organization', 'plan', 'tos'].every(item => !!signup[item])) {\n return HttpResponse.text('test');\n }\n return new HttpResponse(null, { status: 400 });\n};\n\nconst invoicePreviewBasic = {\n id: 'upcoming_in_1RlAkbFlFfXikjZVOHK5VQx0',\n period_start: '2025-07-15T15:25:22Z',\n period_end: '2025-08-15T15:25:22Z',\n total: 3200,\n currency: 'usd',\n lines: [\n {\n description: '50 device × Mender Basic (Tier 1 at $0.00 / month)',\n amount: 0,\n currency: 'usd',\n product: 'mender_standard',\n quantity: 50,\n price_id: 'price_1PYktlFlFfXikjZVh2aNHp7i'\n },\n {\n description: 'Mender Basic (Tier 1 at $32.00 / month)',\n amount: 3200,\n currency: 'usd',\n product: 'mender_standard',\n quantity: 0,\n price_id: 'price_1PYktlFlFfXikjZVh2aNHp7i'\n }\n ]\n};\nconst subscriptionBasic = {\n id: 'sub_1RlAjOFlFfXikjZVj5BvpJE4',\n status: 'active',\n plan: 'os',\n products: [\n {\n name: 'mender_standard',\n quantity: 50\n }\n ]\n};\n\nexport const organizationHandlers = [\n http.get('/tags.json', () => HttpResponse.json(tagsSample)),\n http.get('/versions.json', () => HttpResponse.json(releasesSample)),\n http.get(`${tenantadmApiUrlv1}/user/tenant`, () => HttpResponse.json(mockApiResponses.organization.organization)),\n http.put(`${tenantadmApiUrlv2}/tenants/:tenantId/child`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/cancel`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${tenantadmApiUrlv2}/tenants/trial`, signupHandler),\n http.post(`${tenantadmApiUrlv2}/tenants`, async ({ request }) => {\n const { users } = await request.json();\n const { email } = users[0];\n if (email.includes('bad')) {\n return new HttpResponse(null, { status: 553 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.post(`https://hosted.mender.io${tenantadmApiUrlv2}/tenants/trial`, signupHandler),\n http.get(`${tenantadmApiUrlv2}/tenants`, () => HttpResponse.json(tenants)),\n http.get(`${tenantadmApiUrlv2}/billing`, () => HttpResponse.json({ card: { last4: '7890', exp_month: 1, exp_year: 2024, brand: 'testCorp' } })),\n http.get(`${tenantadmApiUrlv2}/billing/profile`, () =>\n HttpResponse.json({\n name: 'company',\n email: 'test@test.com',\n address: { state: 'OSLO', line1: 'Blindern', country: 'NO', city: 'OSLO', postal_code: '0123' },\n shipping: { address: { state: 'OSLO', line1: 'Blindern', country: 'NO', city: 'OSLO', postal_code: '0123' } }\n })\n ),\n http.post(`${tenantadmApiUrlv2}/billing/card`, () => HttpResponse.json({ intent_id: mockApiResponses.organization.intentId, secret: 'testSecret' })),\n http.post(\n `${tenantadmApiUrlv2}/billing/card/:intentId/confirm`,\n ({ params: { intentId } }) => new HttpResponse(null, { status: intentId == mockApiResponses.organization.intentId ? 200 : 540 })\n ),\n http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/upgrade/:status`, async ({ params: { status, tenantId }, request }) => {\n if (tenantId != mockApiResponses.organization.organization.id || !['cancel', 'complete', 'start'].includes(status)) {\n return new HttpResponse(null, { status: 541 });\n }\n if (status === 'start') {\n return HttpResponse.json({ secret: 'testSecret' });\n }\n let plan;\n try {\n const body = await request.json();\n plan = body.plan;\n } catch {\n // no completion;\n }\n if (plan && !Object.keys(PLANS).includes(plan)) {\n return new HttpResponse(null, { status: 542 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.post(`${tenantadmApiUrlv2}/tenants/:tenantId/plan`, async ({ params: { tenantId }, request }) => {\n const body = await request.json();\n const expectedKeys = ['current_plan', 'requested_plan', 'current_addons', 'requested_addons', 'user_message'];\n if (tenantId != mockApiResponses.organization.organization.id || !Object.keys(body).every(key => expectedKeys.includes(key))) {\n return new HttpResponse(null, { status: 544 });\n }\n if (body.requested_plan && !Object.values(PLANS).some(item => item.name === body.requested_plan)) {\n return new HttpResponse(null, { status: 545 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.post(`${tenantadmApiUrlv2}/contact/support`, async ({ request }) => {\n const { subject, body } = await request.json();\n if (!(subject && body)) {\n return new HttpResponse(null, { status: 543 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.patch(`${tenantadmApiUrlv2}/billing/profile`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${tenantadmApiUrlv2}/billing/profile`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${tenantadmApiUrlv2}/billing/subscription`, () => new HttpResponse(null, { status: 202 })),\n http.post(`${tenantadmApiUrlv2}/billing/subscription/invoices/preview`, () => HttpResponse.json(invoicePreviewBasic)),\n http.get(`${tenantadmApiUrlv2}/billing/subscription`, () => HttpResponse.json(subscriptionBasic)),\n http.get(`${tenantadmApiUrlv2}/billing/products`, () => HttpResponse.json(mockApiResponses.organization.products)),\n http.get(`${auditLogsApiUrl}/logs`, ({ request }) => {\n const { searchParams } = new URL(request.url);\n const perPage = Number(searchParams.get('per_page'));\n if (perPage === 500) {\n return HttpResponse.json([\n { meta: mockApiResponses.organization.auditlog.events[2].meta, time: mockApiResponses.organization.auditlog.events[1].time, action: 'close_terminal' }\n ]);\n }\n return new HttpResponse(JSON.stringify(mockApiResponses.organization.auditlog.events), {\n headers: { [headerNames.total]: mockApiResponses.organization.auditlog.events.length }\n });\n }),\n http.get(`${auditLogsApiUrl}/logs/export`, () =>\n 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\n 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).\n Diff:\n --- Original\n +++ Current\n @@ -9 +9,2 @@\n - \"\"RBAC_ROLE_OBSERVER\"\"\n + \"\"RBAC_ROLE_OBSERVER\"\",\n + \"\"RBAC_ROLE_PERMIT_ALL\"\"\n \"\n `)\n ),\n http.get(`${iotManagerBaseURL}/integrations`, () =>\n HttpResponse.json([\n { connection_string: 'something_else', id: 1, provider: 'iot-hub' },\n { id: 2, provider: 'iot-core', something: 'new' }\n ])\n ),\n http.post(`${iotManagerBaseURL}/integrations`, () => HttpResponse.json([{ connection_string: 'something_else', provider: 'iot-hub' }])),\n http.put(`${iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {\n if (!integrationId) {\n return new HttpResponse(null, { status: 547 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.put(`${iotManagerBaseURL}/integrations/:integrationId/credentials`, ({ params: { integrationId } }) => {\n if (!integrationId) {\n return new HttpResponse(null, { status: 548 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.delete(`${iotManagerBaseURL}/integrations/:integrationId`, ({ params: { integrationId } }) => {\n if (!integrationId) {\n return new HttpResponse(null, { status: 549 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.get(`${iotManagerBaseURL}/events`, ({ request }) => {\n const { searchParams } = new URL(request.url);\n const page = Number(searchParams.get('page'));\n const perPage = Number(searchParams.get('per_page'));\n return HttpResponse.json(webhookEvents.slice(page - 1, page * perPage));\n }),\n http.get(ssoIdpApiUrlv1, () =>\n HttpResponse.json([\n { id: '1', issuer: 'https://samltest.id/saml/idp', valid_until: '2038-08-24T21:14:09Z' },\n { id: '2', issuer: 'https://samltest2.id/saml/idp', valid_until: '2030-10-24T21:14:09Z' }\n ])\n ),\n http.post(ssoIdpApiUrlv1, () => new HttpResponse(null, { status: 200 })),\n http.get(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => {\n if (!configId) {\n return new HttpResponse(null, { status: 550 });\n }\n return HttpResponse.json({ email: 'user@acme.com', password: 'mypass1234', login: { google: 'bob@gmail.com' }, config: '<div>not quite right</div>' });\n }),\n http.put(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new HttpResponse(null, { status: configId ? 200 : 551 })),\n http.delete(`${ssoIdpApiUrlv1}/:configId`, ({ params: { configId } }) => new HttpResponse(null, { status: configId ? 200 : 552 }))\n];\n"],"mappings":";;;;;;;AAcA,SAAS,iBAAiB,aAAa,mBAAmB,gBAAgB,mBAAmB,yBAAyB;AACtH,SAAS,cAAc,YAAY;AAInC,IAAM,QAAQ;AAAA,EACZ,IAAI,EAAE,IAAI,MAAM,MAAM,QAAQ;AAAA,EAC9B,cAAc,EAAE,IAAI,gBAAgB,MAAM,eAAe;AAAA,EACzD,YAAY,EAAE,IAAI,cAAc,MAAM,aAAa;AACrD;AAEA,IAAM,iBAAiB;AAAA,EACrB,KAAK,CAAC,KAAK;AAAA,EACX,UAAU;AAAA,IACR,OAAO;AAAA,MACL,SAAS;AAAA,QACP,cAAc;AAAA,QACd,SAAS;AAAA,QAC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AQ,gBAAgB,GAAG,QAAQ,6BAA6B,CAAC;AAAA,EACvJ,CAAC;AAAA,EACD,KAAK,IAAI,GAAG,cAAc,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,IAAI,aAAa,MAAM,EAAE,QAAQ,WAAW,MAAM,IAAI,CAAC,CAAC;AAAA,EAC9H,KAAK,OAAO,GAAG,cAAc,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,IAAI,aAAa,MAAM,EAAE,QAAQ,WAAW,MAAM,IAAI,CAAC,CAAC;AACnI;","names":[]}
@@ -1,318 +0,0 @@
1
- import {
2
- defaultCreationDate,
3
- defaultMacAddress,
4
- mockApiResponses
5
- } from "./chunk-GQLNLYEI.js";
6
-
7
- // src/requestHandlers/deviceHandlers.ts
8
- import {
9
- DEVICE_FILTERING_OPTIONS,
10
- DEVICE_STATES,
11
- deviceAuthV2,
12
- deviceConfig,
13
- deviceConnect,
14
- headerNames,
15
- inventoryApiUrl,
16
- inventoryApiUrlV2,
17
- iotManagerBaseURL,
18
- reportingApiUrl
19
- } from "@northern.tech/utils/constants";
20
- import { HttpResponse, http } from "msw";
21
- var defaultDeviceId = "a1";
22
- var deviceAuthDevice = {
23
- id: defaultDeviceId,
24
- identity_data: { mac: defaultMacAddress },
25
- status: "accepted",
26
- decommissioning: false,
27
- created_ts: defaultCreationDate,
28
- updated_ts: "2019-01-01T09:25:00.000Z",
29
- auth_sets: [
30
- {
31
- id: "auth1",
32
- identity_data: { mac: defaultMacAddress },
33
- pubkey: "-----BEGIN PUBLIC KEY-----\nMIIBojWELzgJ62hcXIhAfqfoNiaB1326XZByZwcnHr5BuSPAgMBAAE=\n-----END PUBLIC KEY-----\n",
34
- ts: defaultCreationDate,
35
- status: "accepted"
36
- }
37
- ]
38
- };
39
- var checkInTimeExact = "2019-01-01T10:25:00.000Z";
40
- var updatedTime = "2019-01-01T09:25:00.000Z";
41
- var inventoryDevice = {
42
- id: defaultDeviceId,
43
- attributes: [
44
- { name: "network_interfaces", value: ["eth0", "wlan0"], scope: "inventory" },
45
- { name: "kernel", value: "Linux version 4.19.75-v7l+", scope: "inventory" },
46
- { name: "artifact_name", value: "raspotifyInstaller", scope: "inventory" },
47
- { name: "ipv6_wlan0", value: "fe80::68d9:8453:3e9c:7c80/64", scope: "inventory" },
48
- { name: "mac_eth0", value: defaultMacAddress, scope: "inventory" },
49
- { name: "rootfs_type", value: "ext4", scope: "inventory" },
50
- { name: "mender_bootloader_integration", value: "unknown", scope: "inventory" },
51
- { name: "cpu_model", value: "ARMv7 Processor rev 3 (v7l)", scope: "inventory" },
52
- { name: "hostname", value: "raspberrypi", scope: "inventory" },
53
- { name: "mender_client_version", value: "2.1.0", scope: "inventory" },
54
- { name: "ipv4_wlan0", value: "192.168.10.141/24", scope: "inventory" },
55
- { name: "device_type", value: "raspberrypi4", scope: "inventory" },
56
- { name: "mem_total_kB", value: "1986024", scope: "inventory" },
57
- { name: "mac_wlan0", value: "dc:a6:32:12:ad:c0", scope: "inventory" },
58
- { name: "os", value: "Raspbian GNU/Linux 10 (buster)", scope: "inventory" },
59
- { name: "created_ts", value: defaultCreationDate, scope: "system" },
60
- { name: "updated_ts", value: updatedTime, scope: "system" },
61
- { name: "status", value: "accepted", scope: "identity" },
62
- { name: "mac", value: defaultMacAddress, scope: "identity" },
63
- { name: "group", value: "test", scope: "system" }
64
- ],
65
- check_in_time: checkInTimeExact,
66
- updated_ts: updatedTime
67
- };
68
- var deviceAttributes = [
69
- { name: "status", scope: "identity", count: 5 },
70
- { name: "created_ts", scope: "system", count: 5 },
71
- { name: "updated_ts", scope: "system", count: 5 },
72
- { name: "mac", scope: "identity", count: 1 },
73
- { name: "artifact_name", scope: "inventory", count: 1 },
74
- { name: "cpu_model", scope: "inventory", count: 1 },
75
- { name: "device_type", scope: "inventory", count: 1 },
76
- { name: "hostname", scope: "inventory", count: 1 },
77
- { name: "ipv4_wlan0", scope: "inventory", count: 1 },
78
- { name: "ipv6_wlan0", scope: "inventory", count: 1 },
79
- { name: "kernel", scope: "inventory", count: 1 },
80
- { name: "mac_eth0", scope: "inventory", count: 1 },
81
- { name: "mac_wlan0", scope: "inventory", count: 1 },
82
- { name: "mem_total_kB", scope: "inventory", count: 1 },
83
- { name: "mender_bootloader_integration", scope: "inventory", count: 1 },
84
- { name: "mender_client_version", scope: "inventory", count: 1 },
85
- { name: "network_interfaces", scope: "inventory", count: 1 },
86
- { name: "os", scope: "inventory", count: 1 },
87
- { name: "rootfs_type", scope: "inventory", count: 1 },
88
- { name: "group", scope: "system", count: 1 }
89
- ];
90
- var searchHandler = async ({ request }) => {
91
- const { page, per_page, filters } = await request.json();
92
- if ([page, per_page, filters].some((item) => !item)) {
93
- return new HttpResponse(null, { status: 509 });
94
- }
95
- const filter = filters.find((filter2) => filter2.scope === "identity" && filter2.attribute === "status" && Object.values(DEVICE_STATES).includes(filter2.value));
96
- const status = filter?.value || "";
97
- if (!status || filters.length > 1) {
98
- if (filters.find((filter2) => filter2.attribute === "group" && filter2.value.includes(Object.keys(mockApiResponses.devices.groups.byId)[0]))) {
99
- return new HttpResponse(JSON.stringify([inventoryDevice, { ...inventoryDevice, id: "b1" }]), {
100
- headers: { [headerNames.total]: 2 }
101
- });
102
- }
103
- if (filters.find((filter2) => filter2.scope === "monitor" && ["failed_last_update", "alerts", "auth_request"].includes(filter2.attribute))) {
104
- return new HttpResponse(JSON.stringify([inventoryDevice]), { headers: { [headerNames.total]: 4 } });
105
- }
106
- return new HttpResponse(JSON.stringify([]), { headers: { [headerNames.total]: 0 } });
107
- }
108
- let deviceList = Array.from({ length: mockApiResponses.devices.byStatus[status].total }, (_, index) => ({
109
- ...inventoryDevice,
110
- attributes: [...inventoryDevice.attributes, { name: "test-count", value: index, scope: "system" }],
111
- id: `${String.fromCharCode("a".charCodeAt(0) + index)}1`
112
- }));
113
- deviceList = deviceList.slice((page - 1) * per_page, page * per_page);
114
- return new HttpResponse(JSON.stringify(deviceList), { headers: { [headerNames.total]: mockApiResponses.devices.byStatus[status].total } });
115
- };
116
- var deviceHandlers = [
117
- http.delete(`${deviceAuthV2}/devices/:deviceId/auth/:authId`, ({ params: { authId, deviceId } }) => {
118
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId)) {
119
- return new HttpResponse(null, { status: 200 });
120
- }
121
- return new HttpResponse(null, { status: 501 });
122
- }),
123
- http.delete(`${deviceAuthV2}/devices/:deviceId`, ({ params: { deviceId } }) => {
124
- if (mockApiResponses.devices.byId[deviceId]) {
125
- return new HttpResponse(null, { status: 200 });
126
- }
127
- return new HttpResponse(null, { status: 502 });
128
- }),
129
- http.delete(`${inventoryApiUrl}/groups/:group`, ({ params: { group } }) => {
130
- if (mockApiResponses.devices.groups.byId[group]) {
131
- return new HttpResponse(null, { status: 200 });
132
- }
133
- return new HttpResponse(null, { status: 515 });
134
- }),
135
- http.delete(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
136
- const deviceIds = await request.json();
137
- if (mockApiResponses.devices.groups.byId[group] && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
138
- return new HttpResponse(null, { status: 200 });
139
- }
140
- return new HttpResponse(null, { status: 503 });
141
- }),
142
- http.delete(`${inventoryApiUrlV2}/filters/:filterId`, ({ params: { filterId } }) => {
143
- if (Object.values(mockApiResponses.devices.groups.byId).find((group) => group.id === filterId)) {
144
- return new HttpResponse(null, { status: 200 });
145
- }
146
- return new HttpResponse(null, { status: 504 });
147
- }),
148
- http.get(`${deviceAuthV2}/devices`, ({ request }) => {
149
- const { searchParams } = new URL(request.url);
150
- const deviceIds = searchParams.getAll("id");
151
- if (deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
152
- return HttpResponse.json(deviceIds.map((id) => ({ ...deviceAuthDevice, id })));
153
- }
154
- return new HttpResponse(null, { status: 505 });
155
- }),
156
- http.get(`${deviceAuthV2}/limits/devices`, () => HttpResponse.json(mockApiResponses.devices.limits)),
157
- http.get(`${inventoryApiUrl}/devices/:deviceId`, ({ params: { deviceId } }) => {
158
- if (mockApiResponses.devices.byId[deviceId]) {
159
- return HttpResponse.json(inventoryDevice);
160
- }
161
- return new HttpResponse(null, { status: 506 });
162
- }),
163
- http.put(`${inventoryApiUrl}/devices/:deviceId/tags`, async ({ params: { deviceId }, request }) => {
164
- const tags = await request.json();
165
- if (!mockApiResponses.devices.byId[deviceId] && !Array.isArray(tags) && !tags.every((item) => item.name && item.value)) {
166
- return new HttpResponse(null, { status: 506 });
167
- }
168
- return HttpResponse.json(tags);
169
- }),
170
- http.get(`${inventoryApiUrl}/groups`, () => {
171
- const groups = Object.entries(mockApiResponses.devices.groups.byId).reduce((accu, [groupName, group]) => {
172
- if (!group.id) {
173
- accu.push(groupName);
174
- }
175
- return accu;
176
- }, []);
177
- return HttpResponse.json(groups);
178
- }),
179
- http.get(`${inventoryApiUrlV2}/filters/attributes`, () => HttpResponse.json(deviceAttributes)),
180
- http.get(`${reportingApiUrl}/devices/attributes`, () => HttpResponse.json({ attributes: deviceAttributes, count: deviceAttributes.length, limit: 100 })),
181
- http.get(`${reportingApiUrl}/devices/search/attributes`, () => HttpResponse.json(deviceAttributes)),
182
- http.post(
183
- `${reportingApiUrl}/devices/aggregate`,
184
- () => HttpResponse.json([
185
- {
186
- name: "*",
187
- items: [
188
- { key: "test", count: 6 },
189
- { key: "original", count: 1 }
190
- ],
191
- other_count: 42
192
- }
193
- ])
194
- ),
195
- http.get(
196
- `${inventoryApiUrlV2}/filters`,
197
- () => HttpResponse.json([
198
- {
199
- id: "filter1",
200
- name: "testGroupDynamic",
201
- terms: [
202
- { scope: "identity", attribute: "id", type: "$in", value: [defaultDeviceId] },
203
- { scope: "identity", attribute: "mac", type: "$exists", value: false },
204
- { scope: "identity", attribute: "kernel", type: "$exists", value: true }
205
- ]
206
- }
207
- ])
208
- ),
209
- http.patch(`${inventoryApiUrl}/groups/:group/devices`, async ({ params: { group }, request }) => {
210
- const deviceIds = await request.json();
211
- if (!!group && deviceIds.every((id) => !!mockApiResponses.devices.byId[id])) {
212
- return new HttpResponse(null, { status: 200 });
213
- }
214
- return new HttpResponse(null, { status: 508 });
215
- }),
216
- http.post(`${deviceAuthV2}/devices`, async ({ request }) => {
217
- const authset = await request.json();
218
- if (Object.values(mockApiResponses.devices.byId).some(
219
- (device) => device.auth_sets.some((deviceAuthSet) => deviceAuthSet.pubkey == authset.pubkey || deviceAuthSet.identity_data == authset.identity_data)
220
- )) {
221
- return new HttpResponse(null, { status: 409 });
222
- }
223
- return new HttpResponse(null, { status: 200 });
224
- }),
225
- http.post(`${inventoryApiUrlV2}/filters/search`, searchHandler),
226
- http.post(`${reportingApiUrl}/filters/search`, searchHandler),
227
- http.post(`${inventoryApiUrlV2}/filters`, async ({ request }) => {
228
- const { name, terms } = await request.json();
229
- if ([name, terms].some((item) => !item) || mockApiResponses.devices.groups[name] || !terms.every((term) => DEVICE_FILTERING_OPTIONS[term.type] && ["identity", "inventory", "system"].includes(term.scope) && !!term.value && !!term.attribute)) {
230
- return new HttpResponse(null, { status: 510 });
231
- }
232
- return new HttpResponse(JSON.stringify({}), { headers: { location: "find/me/here/createdFilterId" } });
233
- }),
234
- http.get(
235
- `${inventoryApiUrlV2}/statistics`,
236
- async () => HttpResponse.json({
237
- devices_by_status: {
238
- accepted: { standard: mockApiResponses.devices.byStatus.accepted.total, micro: 0, system: 0 },
239
- pending: { standard: mockApiResponses.devices.byStatus.pending.total, micro: 0, system: 0 }
240
- }
241
- })
242
- ),
243
- http.put(`${deviceAuthV2}/devices/:deviceId/auth/:authId/status`, async ({ params: { authId, deviceId }, request }) => {
244
- const { status } = await request.json();
245
- if (mockApiResponses.devices.byId[deviceId].auth_sets.find((authSet) => authSet.id === authId) && DEVICE_STATES[status]) {
246
- return new HttpResponse(null, { status: 200 });
247
- }
248
- return new HttpResponse(null, { status: 511 });
249
- }),
250
- http.get(`${deviceConfig}/:deviceId`, ({ params: { deviceId } }) => {
251
- if (deviceId === "testId") {
252
- return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
253
- }
254
- if (mockApiResponses.devices.byId[deviceId]) {
255
- return HttpResponse.json({
256
- configured: { test: true, something: "else", aNumber: 42 },
257
- deployment_id: "config1",
258
- reported: { test: true, something: "else", aNumber: 42 },
259
- updated_ts: updatedTime,
260
- reported_ts: "2019-01-01T09:25:01.000Z"
261
- });
262
- }
263
- return new HttpResponse(null, { status: 512 });
264
- }),
265
- http.put(`${deviceConfig}/:deviceId`, async ({ params: { deviceId }, request }) => {
266
- const body = await request.text();
267
- if (body.includes("evilValue")) {
268
- return new HttpResponse(null, { status: 418 });
269
- }
270
- return new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 201 : 513 });
271
- }),
272
- http.post(`${deviceConfig}/:deviceId/deploy`, ({ params: { deviceId } }) => {
273
- if (mockApiResponses.devices.byId[deviceId]) {
274
- return HttpResponse.json({ deployment_id: "config1" });
275
- }
276
- return new HttpResponse(null, { status: 514 });
277
- }),
278
- http.get(`${deviceConnect}/devices/:deviceId`, ({ params: { deviceId } }) => {
279
- if (deviceId === "testId") {
280
- return new HttpResponse(JSON.stringify({ error: { status_code: 404 } }), { status: 404 });
281
- }
282
- if (mockApiResponses.devices.byId[deviceId]) {
283
- return HttpResponse.json({ status: "connected", updated_ts: mockApiResponses.devices.byId[deviceId].updated_ts });
284
- }
285
- return new HttpResponse(null, { status: 512 });
286
- }),
287
- http.post(`${deviceConnect}/devices/:deviceId/:action`, ({ params: { deviceId, action } }) => {
288
- if (["check-update", "send-inventory"].includes(action) && mockApiResponses.devices.byId[deviceId]) {
289
- return new HttpResponse(null, { status: 202 });
290
- }
291
- return new HttpResponse(null, { status: 518 });
292
- }),
293
- http.get(`${iotManagerBaseURL}/devices/:deviceId/state`, ({ params: { deviceId } }) => {
294
- if (mockApiResponses.devices.byId[deviceId]) {
295
- return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
296
- }
297
- return new HttpResponse(null, { status: 515 });
298
- }),
299
- http.put(`${iotManagerBaseURL}/devices/:deviceId/state/:integrationId`, async ({ params: { deviceId }, request }) => {
300
- const body = await request.json();
301
- if (mockApiResponses.devices.byId[deviceId] && body) {
302
- return HttpResponse.json({ deployment_id: mockApiResponses.deployments.byId.d1.id });
303
- }
304
- return new HttpResponse(null, { status: 516 });
305
- }),
306
- http.put(
307
- `${deviceConnect}/devices/:deviceId/upload`,
308
- ({ params: { deviceId } }) => new HttpResponse(null, { status: mockApiResponses.devices.byId[deviceId] ? 200 : 517 })
309
- ),
310
- http.get(`${deviceAuthV2}/license`, () => HttpResponse.text("test,report"))
311
- ];
312
-
313
- export {
314
- defaultDeviceId,
315
- inventoryDevice,
316
- deviceHandlers
317
- };
318
- //# sourceMappingURL=chunk-CGSW2XF4.js.map