@budibase/worker 2.5.6-alpha.6 → 2.5.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 +8 -9
- package/scripts/dev/manage.js +0 -1
- package/src/api/controllers/global/users.ts +2 -2
- package/src/api/index.ts +1 -1
- package/src/api/routes/global/configs.ts +1 -9
- package/src/api/routes/global/tests/users.spec.ts +4 -10
- package/src/api/routes/index.ts +6 -4
- package/src/elasticApm.ts +10 -0
- package/src/environment.ts +1 -0
- package/src/index.ts +7 -7
- package/src/sdk/users/users.ts +54 -7
- package/src/tests/TestConfiguration.ts +1 -50
- package/src/tests/api/index.ts +0 -7
- package/src/tests/jestEnv.ts +1 -0
- package/src/tests/jestSetup.ts +2 -0
- package/src/tests/logging.ts +34 -0
- package/src/utilities/appService.ts +46 -0
- package/src/api/routes/global/tests/scim.spec.ts +0 -1029
- package/src/initPro.ts +0 -13
- package/src/middleware/handleScimBody.ts +0 -12
- package/src/tests/api/scim/groups.ts +0 -101
- package/src/tests/api/scim/shared.ts +0 -44
- package/src/tests/api/scim/users.ts +0 -94
package/src/initPro.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { sdk as proSdk } from "@budibase/pro"
|
|
2
|
-
import * as userSdk from "./sdk/users"
|
|
3
|
-
|
|
4
|
-
export const initPro = async () => {
|
|
5
|
-
await proSdk.init({
|
|
6
|
-
scimUserServiceConfig: {
|
|
7
|
-
functions: {
|
|
8
|
-
saveUser: userSdk.save,
|
|
9
|
-
removeUser: (id: string) => userSdk.destroy(id),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Ctx } from "@budibase/types"
|
|
2
|
-
|
|
3
|
-
export const handleScimBody = (ctx: Ctx, next: any) => {
|
|
4
|
-
var type = ctx.req.headers["content-type"] || ""
|
|
5
|
-
type = type.split(";")[0]
|
|
6
|
-
|
|
7
|
-
if (type === "application/scim+json") {
|
|
8
|
-
ctx.req.headers["content-type"] = "application/json"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return next()
|
|
12
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ScimCreateGroupRequest,
|
|
3
|
-
ScimGroupListResponse,
|
|
4
|
-
ScimGroupResponse,
|
|
5
|
-
ScimUpdateRequest,
|
|
6
|
-
} from "@budibase/types"
|
|
7
|
-
import TestConfiguration from "../../TestConfiguration"
|
|
8
|
-
import { RequestSettings, ScimTestAPI } from "./shared"
|
|
9
|
-
|
|
10
|
-
export class ScimGroupsAPI extends ScimTestAPI {
|
|
11
|
-
constructor(config: TestConfiguration) {
|
|
12
|
-
super(config)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get = async (
|
|
16
|
-
requestSettings?: Partial<RequestSettings> & {
|
|
17
|
-
params?: {
|
|
18
|
-
startIndex?: number
|
|
19
|
-
pageSize?: number
|
|
20
|
-
filter?: string
|
|
21
|
-
excludedAttributes?: string
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
) => {
|
|
25
|
-
let url = `/api/global/scim/v2/groups?`
|
|
26
|
-
const params = requestSettings?.params
|
|
27
|
-
if (params?.pageSize) {
|
|
28
|
-
url += `count=${params.pageSize}&`
|
|
29
|
-
}
|
|
30
|
-
if (params?.startIndex) {
|
|
31
|
-
url += `startIndex=${params.startIndex}&`
|
|
32
|
-
}
|
|
33
|
-
if (params?.filter) {
|
|
34
|
-
url += `filter=${params.filter}&`
|
|
35
|
-
}
|
|
36
|
-
if (params?.excludedAttributes) {
|
|
37
|
-
url += `excludedAttributes=${params.excludedAttributes}&`
|
|
38
|
-
}
|
|
39
|
-
const res = await this.call(url, "get", requestSettings)
|
|
40
|
-
return res.body as ScimGroupListResponse
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
post = async (
|
|
44
|
-
{
|
|
45
|
-
body,
|
|
46
|
-
}: {
|
|
47
|
-
body: ScimCreateGroupRequest
|
|
48
|
-
},
|
|
49
|
-
requestSettings?: Partial<RequestSettings>
|
|
50
|
-
) => {
|
|
51
|
-
const res = await this.call(
|
|
52
|
-
`/api/global/scim/v2/groups`,
|
|
53
|
-
"post",
|
|
54
|
-
requestSettings,
|
|
55
|
-
body
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
return res.body as ScimGroupResponse
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
find = async (
|
|
62
|
-
id: string,
|
|
63
|
-
requestSettings?: Partial<RequestSettings> & { qs?: string }
|
|
64
|
-
) => {
|
|
65
|
-
const res = await this.call(
|
|
66
|
-
`/api/global/scim/v2/groups/${id}?${requestSettings?.qs}`,
|
|
67
|
-
"get",
|
|
68
|
-
requestSettings
|
|
69
|
-
)
|
|
70
|
-
return res.body as ScimGroupResponse
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
delete = async (id: string, requestSettings?: Partial<RequestSettings>) => {
|
|
74
|
-
const res = await this.call(
|
|
75
|
-
`/api/global/scim/v2/groups/${id}`,
|
|
76
|
-
"delete",
|
|
77
|
-
requestSettings
|
|
78
|
-
)
|
|
79
|
-
return res.body as ScimGroupResponse
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
patch = async (
|
|
83
|
-
{
|
|
84
|
-
id,
|
|
85
|
-
body,
|
|
86
|
-
}: {
|
|
87
|
-
id: string
|
|
88
|
-
body: ScimUpdateRequest
|
|
89
|
-
},
|
|
90
|
-
requestSettings?: Partial<RequestSettings>
|
|
91
|
-
) => {
|
|
92
|
-
const res = await this.call(
|
|
93
|
-
`/api/global/scim/v2/groups/${id}`,
|
|
94
|
-
"patch",
|
|
95
|
-
requestSettings,
|
|
96
|
-
body
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
return res.body as ScimGroupResponse
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import TestConfiguration from "../../TestConfiguration"
|
|
2
|
-
import { TestAPI } from "../base"
|
|
3
|
-
|
|
4
|
-
const defaultConfig = {
|
|
5
|
-
expect: 200,
|
|
6
|
-
setHeaders: true,
|
|
7
|
-
skipContentTypeCheck: false,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type RequestSettings = typeof defaultConfig
|
|
11
|
-
|
|
12
|
-
export abstract class ScimTestAPI extends TestAPI {
|
|
13
|
-
constructor(config: TestConfiguration) {
|
|
14
|
-
super(config)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
call = (
|
|
18
|
-
url: string,
|
|
19
|
-
method: "get" | "post" | "patch" | "delete",
|
|
20
|
-
requestSettings?: Partial<RequestSettings>,
|
|
21
|
-
body?: object
|
|
22
|
-
) => {
|
|
23
|
-
const { expect, setHeaders } = { ...defaultConfig, ...requestSettings }
|
|
24
|
-
let request = this.request[method](url).expect(expect)
|
|
25
|
-
|
|
26
|
-
request = request.set(
|
|
27
|
-
"content-type",
|
|
28
|
-
"application/scim+json; charset=utf-8"
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
if (method !== "delete" && !requestSettings?.skipContentTypeCheck) {
|
|
32
|
-
request = request.expect("Content-Type", /json/)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (body) {
|
|
36
|
-
request = request.send(body)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (setHeaders) {
|
|
40
|
-
request = request.set(this.config.bearerAPIHeaders())
|
|
41
|
-
}
|
|
42
|
-
return request
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ScimUserListResponse,
|
|
3
|
-
ScimCreateUserRequest,
|
|
4
|
-
ScimUserResponse,
|
|
5
|
-
ScimUpdateRequest,
|
|
6
|
-
} from "@budibase/types"
|
|
7
|
-
import TestConfiguration from "../../TestConfiguration"
|
|
8
|
-
import { RequestSettings, ScimTestAPI } from "./shared"
|
|
9
|
-
|
|
10
|
-
export class ScimUsersAPI extends ScimTestAPI {
|
|
11
|
-
constructor(config: TestConfiguration) {
|
|
12
|
-
super(config)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get = async (
|
|
16
|
-
requestSettings?: Partial<RequestSettings> & {
|
|
17
|
-
params?: {
|
|
18
|
-
startIndex?: number
|
|
19
|
-
pageSize?: number
|
|
20
|
-
filter?: string
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
) => {
|
|
24
|
-
let url = `/api/global/scim/v2/users?`
|
|
25
|
-
const params = requestSettings?.params
|
|
26
|
-
if (params?.pageSize) {
|
|
27
|
-
url += `count=${params.pageSize}&`
|
|
28
|
-
}
|
|
29
|
-
if (params?.startIndex) {
|
|
30
|
-
url += `startIndex=${params.startIndex}&`
|
|
31
|
-
}
|
|
32
|
-
if (params?.filter) {
|
|
33
|
-
url += `filter=${params.filter}&`
|
|
34
|
-
}
|
|
35
|
-
const res = await this.call(url, "get", requestSettings)
|
|
36
|
-
return res.body as ScimUserListResponse
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
find = async (id: string, requestSettings?: Partial<RequestSettings>) => {
|
|
40
|
-
const res = await this.call(
|
|
41
|
-
`/api/global/scim/v2/users/${id}`,
|
|
42
|
-
"get",
|
|
43
|
-
requestSettings
|
|
44
|
-
)
|
|
45
|
-
return res.body as ScimUserResponse
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
post = async (
|
|
49
|
-
{
|
|
50
|
-
body,
|
|
51
|
-
}: {
|
|
52
|
-
body: ScimCreateUserRequest
|
|
53
|
-
},
|
|
54
|
-
requestSettings?: Partial<RequestSettings>
|
|
55
|
-
) => {
|
|
56
|
-
const res = await this.call(
|
|
57
|
-
`/api/global/scim/v2/users`,
|
|
58
|
-
"post",
|
|
59
|
-
requestSettings,
|
|
60
|
-
body
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
return res.body as ScimUserResponse
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
patch = async (
|
|
67
|
-
{
|
|
68
|
-
id,
|
|
69
|
-
body,
|
|
70
|
-
}: {
|
|
71
|
-
id: string
|
|
72
|
-
body: ScimUpdateRequest
|
|
73
|
-
},
|
|
74
|
-
requestSettings?: Partial<RequestSettings>
|
|
75
|
-
) => {
|
|
76
|
-
const res = await this.call(
|
|
77
|
-
`/api/global/scim/v2/users/${id}`,
|
|
78
|
-
"patch",
|
|
79
|
-
requestSettings,
|
|
80
|
-
body
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
return res.body as ScimUserResponse
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
delete = async (id: string, requestSettings?: Partial<RequestSettings>) => {
|
|
87
|
-
const res = await this.call(
|
|
88
|
-
`/api/global/scim/v2/users/${id}`,
|
|
89
|
-
"delete",
|
|
90
|
-
requestSettings
|
|
91
|
-
)
|
|
92
|
-
return res.body as ScimUserResponse
|
|
93
|
-
}
|
|
94
|
-
}
|