@budibase/worker 2.4.44-alpha.4 → 2.4.44-alpha.6
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/package.json +6 -8
- package/scripts/dev/manage.js +1 -0
- package/src/api/routes/global/tests/scim.spec.ts +63 -3
- package/src/environment.ts +0 -1
- package/src/index.ts +2 -7
- package/src/tests/jestEnv.ts +0 -1
- package/src/tests/jestSetup.ts +0 -2
- package/src/elasticApm.ts +0 -10
- package/src/tests/logging.ts +0 -34
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.4.44-alpha.
|
|
4
|
+
"version": "2.4.44-alpha.6",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"author": "Budibase",
|
|
37
37
|
"license": "GPL-3.0",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@budibase/backend-core": "2.4.44-alpha.
|
|
40
|
-
"@budibase/pro": "2.4.44-alpha.
|
|
41
|
-
"@budibase/string-templates": "2.4.44-alpha.
|
|
42
|
-
"@budibase/types": "2.4.44-alpha.
|
|
39
|
+
"@budibase/backend-core": "2.4.44-alpha.6",
|
|
40
|
+
"@budibase/pro": "2.4.44-alpha.5",
|
|
41
|
+
"@budibase/string-templates": "2.4.44-alpha.6",
|
|
42
|
+
"@budibase/types": "2.4.44-alpha.6",
|
|
43
43
|
"@koa/router": "8.0.8",
|
|
44
44
|
"@sentry/node": "6.17.7",
|
|
45
45
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"koa-body": "4.2.0",
|
|
57
57
|
"koa-compress": "4.0.1",
|
|
58
58
|
"koa-passport": "4.1.4",
|
|
59
|
-
"koa-pino-logger": "3.0.0",
|
|
60
59
|
"koa-send": "5.0.1",
|
|
61
60
|
"koa-session": "5.13.1",
|
|
62
61
|
"koa-static": "5.0.0",
|
|
@@ -66,7 +65,6 @@
|
|
|
66
65
|
"passport-google-oauth": "2.0.0",
|
|
67
66
|
"passport-jwt": "4.0.0",
|
|
68
67
|
"passport-local": "1.0.0",
|
|
69
|
-
"pino-pretty": "4.8.0",
|
|
70
68
|
"pouchdb": "7.3.0",
|
|
71
69
|
"pouchdb-all-dbs": "1.1.1",
|
|
72
70
|
"server-destroy": "1.0.1"
|
|
@@ -103,5 +101,5 @@
|
|
|
103
101
|
"typescript": "4.7.3",
|
|
104
102
|
"update-dotenv": "1.1.1"
|
|
105
103
|
},
|
|
106
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "8b025af96934f9fb1d8389ec7aaddfa33466dbda"
|
|
107
105
|
}
|
package/scripts/dev/manage.js
CHANGED
|
@@ -2,6 +2,7 @@ import tk from "timekeeper"
|
|
|
2
2
|
import _ from "lodash"
|
|
3
3
|
import { mocks, structures } from "@budibase/backend-core/tests"
|
|
4
4
|
import {
|
|
5
|
+
ScimCreateUserRequest,
|
|
5
6
|
ScimGroupResponse,
|
|
6
7
|
ScimUpdateRequest,
|
|
7
8
|
ScimUserResponse,
|
|
@@ -176,7 +177,9 @@ describe("scim", () => {
|
|
|
176
177
|
const response = await getScimUsers({
|
|
177
178
|
params: {
|
|
178
179
|
filter: encodeURI(
|
|
179
|
-
`emails[type eq "work"].value eq "${
|
|
180
|
+
`emails[type eq "work"].value eq "${
|
|
181
|
+
userToFetch?.emails![0].value
|
|
182
|
+
}"`
|
|
180
183
|
),
|
|
181
184
|
},
|
|
182
185
|
})
|
|
@@ -259,6 +262,61 @@ describe("scim", () => {
|
|
|
259
262
|
|
|
260
263
|
expect(events.user.created).toBeCalledTimes(1)
|
|
261
264
|
})
|
|
265
|
+
|
|
266
|
+
it("if the username is an email, the user name will be used as email", async () => {
|
|
267
|
+
const email = structures.generator.email()
|
|
268
|
+
|
|
269
|
+
const body: ScimCreateUserRequest = structures.scim.createUserRequest(
|
|
270
|
+
{ username: email }
|
|
271
|
+
)
|
|
272
|
+
delete body.emails
|
|
273
|
+
|
|
274
|
+
await postScimUser({ body })
|
|
275
|
+
|
|
276
|
+
const user = await config.getUser(email)
|
|
277
|
+
expect(user).toBeDefined()
|
|
278
|
+
expect(user.email).toEqual(email)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it("if multiple emails are provided, the first primary one is used as email", async () => {
|
|
282
|
+
const email = structures.generator.email()
|
|
283
|
+
|
|
284
|
+
const body: ScimCreateUserRequest = {
|
|
285
|
+
...structures.scim.createUserRequest(),
|
|
286
|
+
emails: [
|
|
287
|
+
{
|
|
288
|
+
primary: false,
|
|
289
|
+
type: "work",
|
|
290
|
+
value: structures.generator.email(),
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
primary: true,
|
|
294
|
+
type: "work",
|
|
295
|
+
value: email,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
primary: true,
|
|
299
|
+
type: "work",
|
|
300
|
+
value: structures.generator.email(),
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
await postScimUser({ body })
|
|
306
|
+
|
|
307
|
+
const user = await config.getUser(email)
|
|
308
|
+
expect(user).toBeDefined()
|
|
309
|
+
expect(user.email).toEqual(email)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it("if no email is provided and the user name is not an email, an exception is thrown", async () => {
|
|
313
|
+
const body: ScimCreateUserRequest = structures.scim.createUserRequest(
|
|
314
|
+
{ username: structures.generator.name() }
|
|
315
|
+
)
|
|
316
|
+
delete body.emails
|
|
317
|
+
|
|
318
|
+
await postScimUser({ body }, { expect: 500 })
|
|
319
|
+
})
|
|
262
320
|
})
|
|
263
321
|
})
|
|
264
322
|
|
|
@@ -392,21 +450,23 @@ describe("scim", () => {
|
|
|
392
450
|
)
|
|
393
451
|
|
|
394
452
|
it("supports updating unmapped fields", async () => {
|
|
453
|
+
const value = structures.generator.letter()
|
|
395
454
|
const body: ScimUpdateRequest = {
|
|
396
455
|
schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
|
|
397
456
|
Operations: [
|
|
398
457
|
{
|
|
399
458
|
op: "Add",
|
|
400
459
|
path: "preferredLanguage",
|
|
401
|
-
value
|
|
460
|
+
value,
|
|
402
461
|
},
|
|
403
462
|
],
|
|
404
463
|
}
|
|
405
464
|
|
|
406
465
|
const response = await patchScimUser({ id: user.id, body })
|
|
407
466
|
|
|
408
|
-
const expectedScimUser
|
|
467
|
+
const expectedScimUser = {
|
|
409
468
|
...user,
|
|
469
|
+
preferredLanguage: value,
|
|
410
470
|
}
|
|
411
471
|
expect(response).toEqual(expectedScimUser)
|
|
412
472
|
|
package/src/environment.ts
CHANGED
|
@@ -47,7 +47,6 @@ const environment = {
|
|
|
47
47
|
// flags
|
|
48
48
|
NODE_ENV: process.env.NODE_ENV,
|
|
49
49
|
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED || ""),
|
|
50
|
-
LOG_LEVEL: process.env.LOG_LEVEL,
|
|
51
50
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
52
51
|
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
|
53
52
|
SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
|
package/src/index.ts
CHANGED
|
@@ -2,10 +2,6 @@ if (process.env.DD_APM_ENABLED) {
|
|
|
2
2
|
require("./ddApm")
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
if (process.env.ELASTIC_APM_ENABLED) {
|
|
6
|
-
require("./elasticApm")
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
// need to load environment first
|
|
10
6
|
import env from "./environment"
|
|
11
7
|
import { Scope } from "@sentry/node"
|
|
@@ -31,7 +27,6 @@ import api from "./api"
|
|
|
31
27
|
import * as redis from "./utilities/redis"
|
|
32
28
|
const Sentry = require("@sentry/node")
|
|
33
29
|
const koaSession = require("koa-session")
|
|
34
|
-
const logger = require("koa-pino-logger")
|
|
35
30
|
const { userAgent } = require("koa-useragent")
|
|
36
31
|
|
|
37
32
|
import destroyable from "server-destroy"
|
|
@@ -60,8 +55,8 @@ app.use(handleScimBody)
|
|
|
60
55
|
app.use(koaBody({ multipart: true }))
|
|
61
56
|
|
|
62
57
|
app.use(koaSession(app))
|
|
63
|
-
app.use(middleware.
|
|
64
|
-
app.use(
|
|
58
|
+
app.use(middleware.correlation)
|
|
59
|
+
app.use(middleware.pino)
|
|
65
60
|
app.use(userAgent)
|
|
66
61
|
|
|
67
62
|
// authentication
|
package/src/tests/jestEnv.ts
CHANGED
|
@@ -2,7 +2,6 @@ process.env.SELF_HOSTED = "0"
|
|
|
2
2
|
process.env.NODE_ENV = "jest"
|
|
3
3
|
process.env.JWT_SECRET = "test-jwtsecret"
|
|
4
4
|
process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error"
|
|
5
|
-
process.env.ENABLE_4XX_HTTP_LOGGING = "0"
|
|
6
5
|
process.env.MULTI_TENANCY = "1"
|
|
7
6
|
process.env.MINIO_URL = "http://localhost"
|
|
8
7
|
process.env.MINIO_ACCESS_KEY = "test"
|
package/src/tests/jestSetup.ts
CHANGED
package/src/elasticApm.ts
DELETED
package/src/tests/logging.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export enum LogLevel {
|
|
2
|
-
TRACE = "trace",
|
|
3
|
-
DEBUG = "debug",
|
|
4
|
-
INFO = "info",
|
|
5
|
-
WARN = "warn",
|
|
6
|
-
ERROR = "error",
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const LOG_INDEX: { [key in LogLevel]: number } = {
|
|
10
|
-
[LogLevel.TRACE]: 1,
|
|
11
|
-
[LogLevel.DEBUG]: 2,
|
|
12
|
-
[LogLevel.INFO]: 3,
|
|
13
|
-
[LogLevel.WARN]: 4,
|
|
14
|
-
[LogLevel.ERROR]: 5,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel]
|
|
18
|
-
|
|
19
|
-
if (setIndex > LOG_INDEX.trace) {
|
|
20
|
-
global.console.trace = jest.fn()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (setIndex > LOG_INDEX.debug) {
|
|
24
|
-
global.console.debug = jest.fn()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (setIndex > LOG_INDEX.info) {
|
|
28
|
-
global.console.info = jest.fn()
|
|
29
|
-
global.console.log = jest.fn()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (setIndex > LOG_INDEX.warn) {
|
|
33
|
-
global.console.warn = jest.fn()
|
|
34
|
-
}
|