@budibase/worker 2.3.15 → 2.3.17-alpha.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/__mocks__/node-fetch.ts +23 -0
- package/jest-testcontainers-config.js +8 -0
- package/jest.config.ts +3 -2
- package/package.json +8 -6
- package/src/api/controllers/global/auth.ts +5 -2
- package/src/api/routes/global/tests/auth.spec.ts +30 -22
- package/src/api/routes/global/tests/configs.spec.ts +114 -94
- package/src/api/routes/global/tests/roles.spec.ts +19 -14
- package/src/api/routes/global/tests/users.spec.ts +33 -34
- package/src/ddApm.ts +7 -0
- package/src/elasticApm.ts +10 -0
- package/src/index.ts +6 -7
- package/src/sdk/users/users.ts +0 -1
- package/src/tests/TestConfiguration.ts +41 -11
- package/src/tests/api/auth.ts +7 -3
- package/src/tests/api/configs.ts +2 -2
- package/src/tests/api/users.ts +2 -2
- package/src/tests/jestSetup.ts +9 -2
- package/src/tests/structures/index.ts +0 -2
- package/coverage/clover.xml +0 -2196
- package/coverage/coverage-final.json +0 -84
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -431
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +0 -925
- package/coverage/lcov-report/src/api/controllers/global/configs.ts.html +0 -1348
- package/coverage/lcov-report/src/api/controllers/global/email.ts.html +0 -196
- package/coverage/lcov-report/src/api/controllers/global/events.ts.html +0 -136
- package/coverage/lcov-report/src/api/controllers/global/index.html +0 -251
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +0 -187
- package/coverage/lcov-report/src/api/controllers/global/roles.ts.html +0 -283
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +0 -577
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +0 -316
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +0 -838
- package/coverage/lcov-report/src/api/controllers/global/workspaces.ts.html +0 -244
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +0 -148
- package/coverage/lcov-report/src/api/controllers/system/environment.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/index.html +0 -191
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/status.ts.html +0 -133
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +0 -154
- package/coverage/lcov-report/src/api/index.html +0 -116
- package/coverage/lcov-report/src/api/index.ts.html +0 -595
- package/coverage/lcov-report/src/api/routes/global/auth.ts.html +0 -349
- package/coverage/lcov-report/src/api/routes/global/configs.ts.html +0 -457
- package/coverage/lcov-report/src/api/routes/global/email.ts.html +0 -193
- package/coverage/lcov-report/src/api/routes/global/events.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/global/index.html +0 -251
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +0 -124
- package/coverage/lcov-report/src/api/routes/global/roles.ts.html +0 -133
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +0 -139
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +0 -196
- package/coverage/lcov-report/src/api/routes/global/users.ts.html +0 -475
- package/coverage/lcov-report/src/api/routes/global/workspaces.ts.html +0 -196
- package/coverage/lcov-report/src/api/routes/index.html +0 -116
- package/coverage/lcov-report/src/api/routes/index.ts.html +0 -202
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +0 -142
- package/coverage/lcov-report/src/api/routes/system/environment.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/index.html +0 -191
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +0 -142
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/status.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/tenants.ts.html +0 -124
- package/coverage/lcov-report/src/api/routes/validation/index.html +0 -131
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +0 -88
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +0 -235
- package/coverage/lcov-report/src/constants/index.html +0 -116
- package/coverage/lcov-report/src/constants/index.ts.html +0 -637
- package/coverage/lcov-report/src/constants/templates/index.html +0 -116
- package/coverage/lcov-report/src/constants/templates/index.ts.html +0 -316
- package/coverage/lcov-report/src/db/index.html +0 -116
- package/coverage/lcov-report/src/db/index.ts.html +0 -115
- package/coverage/lcov-report/src/environment.ts.html +0 -388
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/index.ts.html +0 -394
- package/coverage/lcov-report/src/middleware/cloudRestricted.ts.html +0 -139
- package/coverage/lcov-report/src/middleware/index.html +0 -116
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +0 -145
- package/coverage/lcov-report/src/migrations/functions/index.html +0 -116
- package/coverage/lcov-report/src/migrations/index.html +0 -116
- package/coverage/lcov-report/src/migrations/index.ts.html +0 -271
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +0 -262
- package/coverage/lcov-report/src/sdk/accounts/index.html +0 -131
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +0 -88
- package/coverage/lcov-report/src/sdk/index.html +0 -116
- package/coverage/lcov-report/src/sdk/index.ts.html +0 -106
- package/coverage/lcov-report/src/sdk/users/events.ts.html +0 -601
- package/coverage/lcov-report/src/sdk/users/index.html +0 -146
- package/coverage/lcov-report/src/sdk/users/index.ts.html +0 -88
- package/coverage/lcov-report/src/sdk/users/users.ts.html +0 -1999
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +0 -1075
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +0 -160
- package/coverage/lcov-report/src/tests/api/auth.ts.html +0 -220
- package/coverage/lcov-report/src/tests/api/base.ts.html +0 -133
- package/coverage/lcov-report/src/tests/api/configs.ts.html +0 -226
- package/coverage/lcov-report/src/tests/api/email.ts.html +0 -148
- package/coverage/lcov-report/src/tests/api/environment.ts.html +0 -130
- package/coverage/lcov-report/src/tests/api/groups.ts.html +0 -163
- package/coverage/lcov-report/src/tests/api/index.html +0 -356
- package/coverage/lcov-report/src/tests/api/index.ts.html +0 -238
- package/coverage/lcov-report/src/tests/api/license.ts.html +0 -136
- package/coverage/lcov-report/src/tests/api/migrations.ts.html +0 -151
- package/coverage/lcov-report/src/tests/api/restore.ts.html +0 -127
- package/coverage/lcov-report/src/tests/api/roles.ts.html +0 -181
- package/coverage/lcov-report/src/tests/api/self.ts.html +0 -163
- package/coverage/lcov-report/src/tests/api/status.ts.html +0 -121
- package/coverage/lcov-report/src/tests/api/templates.ts.html +0 -175
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +0 -130
- package/coverage/lcov-report/src/tests/api/users.ts.html +0 -514
- package/coverage/lcov-report/src/tests/controllers.ts.html +0 -100
- package/coverage/lcov-report/src/tests/index.html +0 -146
- package/coverage/lcov-report/src/tests/index.ts.html +0 -103
- package/coverage/lcov-report/src/tests/mocks/email.ts.html +0 -115
- package/coverage/lcov-report/src/tests/mocks/index.html +0 -131
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +0 -106
- package/coverage/lcov-report/src/tests/structures/configs.ts.html +0 -313
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +0 -118
- package/coverage/lcov-report/src/tests/structures/index.html +0 -161
- package/coverage/lcov-report/src/tests/structures/index.ts.html +0 -151
- package/coverage/lcov-report/src/tests/structures/users.ts.html +0 -196
- package/coverage/lcov-report/src/utilities/appService.ts.html +0 -208
- package/coverage/lcov-report/src/utilities/email.ts.html +0 -850
- package/coverage/lcov-report/src/utilities/fileSystem.ts.html +0 -100
- package/coverage/lcov-report/src/utilities/index.html +0 -206
- package/coverage/lcov-report/src/utilities/index.ts.html +0 -112
- package/coverage/lcov-report/src/utilities/redis.ts.html +0 -424
- package/coverage/lcov-report/src/utilities/templates.ts.html +0 -232
- package/coverage/lcov-report/src/utilities/users.ts.html +0 -133
- package/coverage/lcov.info +0 -4184
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { InviteUsersResponse, User } from "@budibase/types"
|
|
2
2
|
|
|
3
3
|
jest.mock("nodemailer")
|
|
4
|
-
import {
|
|
5
|
-
TestConfiguration,
|
|
6
|
-
mocks,
|
|
7
|
-
structures,
|
|
8
|
-
TENANT_1,
|
|
9
|
-
} from "../../../../tests"
|
|
4
|
+
import { TestConfiguration, mocks, structures } from "../../../../tests"
|
|
10
5
|
const sendMailMock = mocks.email.mock()
|
|
11
|
-
import { events, tenancy } from "@budibase/backend-core"
|
|
6
|
+
import { context, events, tenancy } from "@budibase/backend-core"
|
|
12
7
|
|
|
13
8
|
describe("/api/global/users", () => {
|
|
14
9
|
const config = new TestConfiguration()
|
|
@@ -27,16 +22,18 @@ describe("/api/global/users", () => {
|
|
|
27
22
|
|
|
28
23
|
describe("invite", () => {
|
|
29
24
|
it("should be able to generate an invitation", async () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
await context.doInTenant(config.tenant1User!.tenantId, async () => {
|
|
26
|
+
const email = structures.users.newEmail()
|
|
27
|
+
const { code, res } = await config.api.users.sendUserInvite(
|
|
28
|
+
sendMailMock,
|
|
29
|
+
email
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
expect(res.body).toEqual({ message: "Invitation has been sent." })
|
|
33
|
+
expect(sendMailMock).toHaveBeenCalled()
|
|
34
|
+
expect(code).toBeDefined()
|
|
35
|
+
expect(events.user.invited).toBeCalledTimes(1)
|
|
36
|
+
})
|
|
40
37
|
})
|
|
41
38
|
|
|
42
39
|
it("should not be able to generate an invitation for existing user", async () => {
|
|
@@ -53,20 +50,22 @@ describe("/api/global/users", () => {
|
|
|
53
50
|
})
|
|
54
51
|
|
|
55
52
|
it("should be able to create new user from invite", async () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
await context.doInTenant(config.tenant1User!.tenantId, async () => {
|
|
54
|
+
const email = structures.users.newEmail()
|
|
55
|
+
const { code } = await config.api.users.sendUserInvite(
|
|
56
|
+
sendMailMock,
|
|
57
|
+
email
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
const res = await config.api.users.acceptInvite(code)
|
|
61
|
+
|
|
62
|
+
expect(res.body._id).toBeDefined()
|
|
63
|
+
const user = await config.getUser(email)
|
|
64
|
+
expect(user).toBeDefined()
|
|
65
|
+
expect(user._id).toEqual(res.body._id)
|
|
66
|
+
expect(events.user.inviteAccepted).toBeCalledTimes(1)
|
|
67
|
+
expect(events.user.inviteAccepted).toBeCalledWith(user)
|
|
68
|
+
})
|
|
70
69
|
})
|
|
71
70
|
})
|
|
72
71
|
|
|
@@ -118,7 +117,7 @@ describe("/api/global/users", () => {
|
|
|
118
117
|
const user = await config.createUser()
|
|
119
118
|
jest.clearAllMocks()
|
|
120
119
|
|
|
121
|
-
await tenancy.doInTenant(
|
|
120
|
+
await tenancy.doInTenant(config.getTenantId(), async () => {
|
|
122
121
|
const response = await config.api.users.bulkCreateUsers([user])
|
|
123
122
|
|
|
124
123
|
expect(response.created?.successful.length).toBe(0)
|
|
@@ -231,7 +230,7 @@ describe("/api/global/users", () => {
|
|
|
231
230
|
const user = await config.createUser()
|
|
232
231
|
jest.clearAllMocks()
|
|
233
232
|
|
|
234
|
-
await tenancy.doInTenant(
|
|
233
|
+
await tenancy.doInTenant(config.getTenantId(), async () => {
|
|
235
234
|
delete user._id
|
|
236
235
|
const response = await config.api.users.saveUser(user, 400)
|
|
237
236
|
|
|
@@ -444,7 +443,7 @@ describe("/api/global/users", () => {
|
|
|
444
443
|
})
|
|
445
444
|
|
|
446
445
|
it("should not be able to update email address", async () => {
|
|
447
|
-
const email =
|
|
446
|
+
const email = structures.email()
|
|
448
447
|
const user = await config.createUser(structures.users.user({ email }))
|
|
449
448
|
user.email = "new@test.com"
|
|
450
449
|
|
package/src/ddApm.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
if (process.env.DD_APM_ENABLED) {
|
|
2
|
+
require("./ddApm")
|
|
3
|
+
}
|
|
3
4
|
|
|
4
|
-
// enable APM if configured
|
|
5
5
|
if (process.env.ELASTIC_APM_ENABLED) {
|
|
6
|
-
|
|
7
|
-
serviceName: process.env.SERVICE,
|
|
8
|
-
environment: process.env.BUDIBASE_ENVIRONMENT,
|
|
9
|
-
})
|
|
6
|
+
require("./elasticApm")
|
|
10
7
|
}
|
|
11
8
|
|
|
9
|
+
// need to load environment first
|
|
10
|
+
import env from "./environment"
|
|
12
11
|
import { Scope } from "@sentry/node"
|
|
13
12
|
import { Event } from "@sentry/types/dist/event"
|
|
14
13
|
import Application from "koa"
|
package/src/sdk/users/users.ts
CHANGED
|
@@ -264,7 +264,6 @@ export const save = async (
|
|
|
264
264
|
builtUser._rev = response.rev
|
|
265
265
|
|
|
266
266
|
await eventHelpers.handleSaveEvents(builtUser, dbUser)
|
|
267
|
-
await addTenant(tenantId, _id, email)
|
|
268
267
|
await cache.user.invalidateUser(response.id)
|
|
269
268
|
|
|
270
269
|
// let server know to sync user
|
|
@@ -20,22 +20,44 @@ import {
|
|
|
20
20
|
auth,
|
|
21
21
|
constants,
|
|
22
22
|
env as coreEnv,
|
|
23
|
+
DEFAULT_TENANT_ID,
|
|
23
24
|
} from "@budibase/backend-core"
|
|
24
|
-
import structures, { TENANT_ID,
|
|
25
|
+
import structures, { TENANT_ID, CSRF_TOKEN } from "./structures"
|
|
25
26
|
import { CreateUserResponse, User, AuthToken } from "@budibase/types"
|
|
26
27
|
import API from "./api"
|
|
28
|
+
import sdk from "../sdk"
|
|
27
29
|
|
|
28
30
|
enum Mode {
|
|
29
31
|
CLOUD = "cloud",
|
|
30
32
|
SELF = "self",
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
async function retry<T extends (...arg0: any[]) => any>(
|
|
36
|
+
fn: T,
|
|
37
|
+
maxTry: number = 5,
|
|
38
|
+
retryCount = 1
|
|
39
|
+
): Promise<Awaited<ReturnType<T>>> {
|
|
40
|
+
const currRetry = typeof retryCount === "number" ? retryCount : 1
|
|
41
|
+
try {
|
|
42
|
+
const result = await fn()
|
|
43
|
+
return result
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.log(`Retry ${currRetry} failed.`)
|
|
46
|
+
if (currRetry > maxTry) {
|
|
47
|
+
console.log(`All ${maxTry} retry attempts exhausted`)
|
|
48
|
+
throw e
|
|
49
|
+
}
|
|
50
|
+
return retry(fn, maxTry, currRetry + 1)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
class TestConfiguration {
|
|
34
55
|
server: any
|
|
35
56
|
request: any
|
|
36
57
|
api: API
|
|
37
58
|
defaultUser?: User
|
|
38
59
|
tenant1User?: User
|
|
60
|
+
#tenantId?: string
|
|
39
61
|
|
|
40
62
|
constructor(
|
|
41
63
|
opts: { openServer: boolean; mode: Mode } = {
|
|
@@ -112,13 +134,21 @@ class TestConfiguration {
|
|
|
112
134
|
// SETUP / TEARDOWN
|
|
113
135
|
|
|
114
136
|
async beforeAll() {
|
|
115
|
-
|
|
116
|
-
|
|
137
|
+
try {
|
|
138
|
+
this.#tenantId = structures.tenant.id()
|
|
117
139
|
|
|
118
|
-
|
|
119
|
-
await this.
|
|
120
|
-
await this.createSession(this.
|
|
121
|
-
|
|
140
|
+
// Running tests in parallel causes issues creating the globaldb twice. This ensures the db is properly created before starting
|
|
141
|
+
await retry(async () => await this.createDefaultUser())
|
|
142
|
+
await this.createSession(this.defaultUser!)
|
|
143
|
+
|
|
144
|
+
await tenancy.doInTenant(this.#tenantId, async () => {
|
|
145
|
+
await this.createTenant1User()
|
|
146
|
+
await this.createSession(this.tenant1User!)
|
|
147
|
+
})
|
|
148
|
+
} catch (e: any) {
|
|
149
|
+
console.log(e)
|
|
150
|
+
throw new Error(e.message)
|
|
151
|
+
}
|
|
122
152
|
}
|
|
123
153
|
|
|
124
154
|
async afterAll() {
|
|
@@ -133,6 +163,8 @@ class TestConfiguration {
|
|
|
133
163
|
// create user / new tenant
|
|
134
164
|
const res = await this.api.users.createAdminUser()
|
|
135
165
|
|
|
166
|
+
await sdk.users.addTenant(res.tenantId, res.userId, res.email)
|
|
167
|
+
|
|
136
168
|
// return the created user
|
|
137
169
|
const userRes = await this.api.users.getUser(res.userId, {
|
|
138
170
|
headers: {
|
|
@@ -152,7 +184,7 @@ class TestConfiguration {
|
|
|
152
184
|
try {
|
|
153
185
|
return tenancy.getTenantId()
|
|
154
186
|
} catch (e: any) {
|
|
155
|
-
return
|
|
187
|
+
return DEFAULT_TENANT_ID
|
|
156
188
|
}
|
|
157
189
|
}
|
|
158
190
|
|
|
@@ -203,7 +235,7 @@ class TestConfiguration {
|
|
|
203
235
|
const tenantId = this.getTenantId()
|
|
204
236
|
if (tenantId === TENANT_ID) {
|
|
205
237
|
return this.authHeaders(this.defaultUser!)
|
|
206
|
-
} else if (tenantId ===
|
|
238
|
+
} else if (tenantId === this.getTenantId()) {
|
|
207
239
|
return this.authHeaders(this.tenant1User!)
|
|
208
240
|
} else {
|
|
209
241
|
throw new Error("could not determine auth headers to use")
|
|
@@ -222,7 +254,6 @@ class TestConfiguration {
|
|
|
222
254
|
|
|
223
255
|
async createDefaultUser() {
|
|
224
256
|
const user = structures.users.adminUser({
|
|
225
|
-
email: "test@test.com",
|
|
226
257
|
password: "test",
|
|
227
258
|
})
|
|
228
259
|
this.defaultUser = await this.createUser(user)
|
|
@@ -230,7 +261,6 @@ class TestConfiguration {
|
|
|
230
261
|
|
|
231
262
|
async createTenant1User() {
|
|
232
263
|
const user = structures.users.adminUser({
|
|
233
|
-
email: "tenant1@test.com",
|
|
234
264
|
password: "test",
|
|
235
265
|
})
|
|
236
266
|
this.tenant1User = await this.createUser(user)
|
package/src/tests/api/auth.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import structures from "../structures"
|
|
1
2
|
import TestConfiguration from "../TestConfiguration"
|
|
2
3
|
import { TestAPI } from "./base"
|
|
3
4
|
|
|
@@ -24,14 +25,17 @@ export class AuthAPI extends TestAPI {
|
|
|
24
25
|
.expect(200)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
requestPasswordReset = async (sendMailMock: any) => {
|
|
28
|
+
requestPasswordReset = async (sendMailMock: any, userEmail: string) => {
|
|
28
29
|
await this.config.saveSmtpConfig()
|
|
29
30
|
await this.config.saveSettingsConfig()
|
|
30
|
-
await this.config.createUser(
|
|
31
|
+
await this.config.createUser({
|
|
32
|
+
...structures.users.user(),
|
|
33
|
+
email: userEmail,
|
|
34
|
+
})
|
|
31
35
|
const res = await this.request
|
|
32
36
|
.post(`/api/global/auth/${this.config.getTenantId()}/reset`)
|
|
33
37
|
.send({
|
|
34
|
-
email:
|
|
38
|
+
email: userEmail,
|
|
35
39
|
})
|
|
36
40
|
.expect("Content-Type", /json/)
|
|
37
41
|
.expect(200)
|
package/src/tests/api/configs.ts
CHANGED
|
@@ -10,8 +10,8 @@ export class ConfigAPI extends TestAPI {
|
|
|
10
10
|
return this.request
|
|
11
11
|
.get(`/api/global/configs/checklist`)
|
|
12
12
|
.set(this.config.defaultHeaders())
|
|
13
|
-
.expect("Content-Type", /json/)
|
|
14
13
|
.expect(200)
|
|
14
|
+
.expect("Content-Type", /json/)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
saveConfig = (data: any) => {
|
|
@@ -19,8 +19,8 @@ export class ConfigAPI extends TestAPI {
|
|
|
19
19
|
.post(`/api/global/configs`)
|
|
20
20
|
.send(data)
|
|
21
21
|
.set(this.config.defaultHeaders())
|
|
22
|
-
.expect("Content-Type", /json/)
|
|
23
22
|
.expect(200)
|
|
23
|
+
.expect("Content-Type", /json/)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
OIDCCallback = (configId: string, preAuthRes: any) => {
|
package/src/tests/api/users.ts
CHANGED
|
@@ -26,8 +26,8 @@ export class UserAPI extends TestAPI {
|
|
|
26
26
|
email,
|
|
27
27
|
})
|
|
28
28
|
.set(this.config.defaultHeaders())
|
|
29
|
-
.expect("Content-Type", /json/)
|
|
30
29
|
.expect(status)
|
|
30
|
+
.expect("Content-Type", /json/)
|
|
31
31
|
|
|
32
32
|
if (status !== 200) {
|
|
33
33
|
return { code: undefined, res }
|
|
@@ -100,7 +100,7 @@ export class UserAPI extends TestAPI {
|
|
|
100
100
|
request = {
|
|
101
101
|
email: structures.email(),
|
|
102
102
|
password: generator.string(),
|
|
103
|
-
tenantId: structures.
|
|
103
|
+
tenantId: structures.tenant.id(),
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
const res = await this.request
|
package/src/tests/jestSetup.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { mocks } from "@budibase/backend-core/tests"
|
|
1
|
+
import { mocks, testContainerUtils } from "@budibase/backend-core/tests"
|
|
2
|
+
|
|
3
|
+
import env from "../environment"
|
|
4
|
+
import { env as coreEnv } from "@budibase/backend-core"
|
|
2
5
|
|
|
3
6
|
// must explicitly enable fetch mock
|
|
4
7
|
mocks.fetch.enable()
|
|
@@ -15,5 +18,9 @@ if (!process.env.DEBUG) {
|
|
|
15
18
|
if (!process.env.CI) {
|
|
16
19
|
// set a longer timeout in dev for debugging
|
|
17
20
|
// 100 seconds
|
|
18
|
-
jest.setTimeout(
|
|
21
|
+
jest.setTimeout(100 * 1000)
|
|
22
|
+
} else {
|
|
23
|
+
jest.setTimeout(10 * 1000)
|
|
19
24
|
}
|
|
25
|
+
|
|
26
|
+
testContainerUtils.setupEnv(env, coreEnv)
|
|
@@ -5,7 +5,6 @@ import * as groups from "./groups"
|
|
|
5
5
|
import { v4 as uuid } from "uuid"
|
|
6
6
|
|
|
7
7
|
export const TENANT_ID = "default"
|
|
8
|
-
export const TENANT_1 = "tenant1"
|
|
9
8
|
export const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
10
9
|
|
|
11
10
|
const pkg = {
|
|
@@ -14,7 +13,6 @@ const pkg = {
|
|
|
14
13
|
configs,
|
|
15
14
|
users,
|
|
16
15
|
TENANT_ID,
|
|
17
|
-
TENANT_1,
|
|
18
16
|
CSRF_TOKEN,
|
|
19
17
|
groups,
|
|
20
18
|
}
|