@budibase/worker 3.20.1 → 3.20.2
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.20.
|
|
4
|
+
"version": "3.20.2",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "3582592cff6b755c0e6f5cf7d04f32be18d7a9a8"
|
|
113
113
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import cloudRestricted from "../../../middleware/cloudRestricted"
|
|
2
1
|
import { auth, EndpointGroupList, middleware } from "@budibase/backend-core"
|
|
2
|
+
import cloudRestricted from "../../../middleware/cloudRestricted"
|
|
3
3
|
|
|
4
4
|
export const endpointGroupList = new EndpointGroupList()
|
|
5
5
|
|
|
6
|
-
export const builderOrAdminRoutes = endpointGroupList.group(
|
|
6
|
+
export const builderOrAdminRoutes = endpointGroupList.group(
|
|
7
|
+
auth.workspaceBuilderOrAdmin
|
|
8
|
+
)
|
|
7
9
|
builderOrAdminRoutes.lockMiddleware()
|
|
8
10
|
|
|
9
11
|
export const builderRoutes = endpointGroupList.group(auth.builderOnly)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as controller from "../../controllers/global/roles"
|
|
2
|
-
import {
|
|
2
|
+
import { builderOrAdminRoutes } from "../endpointGroups"
|
|
3
3
|
|
|
4
4
|
builderOrAdminRoutes
|
|
5
5
|
.get("/api/global/roles", controller.fetch)
|
|
6
6
|
.get("/api/global/roles/:appId", controller.find)
|
|
7
|
-
|
|
8
|
-
adminRoutes.delete("/api/global/roles/:appId", controller.removeAppRole)
|
|
7
|
+
.delete("/api/global/roles/:appId", controller.removeAppRole)
|
|
@@ -144,11 +144,14 @@ describe("/api/global/roles", () => {
|
|
|
144
144
|
})
|
|
145
145
|
|
|
146
146
|
describe("DELETE /api/global/roles/:appId", () => {
|
|
147
|
-
async function createBuilderUser() {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
async function createBuilderUser(forWorkspaces: string[] = []) {
|
|
148
|
+
const builderUser = structures.users.builderUser()
|
|
149
|
+
builderUser.builder.apps = [
|
|
150
|
+
...(builderUser.builder.apps || []),
|
|
151
|
+
...forWorkspaces,
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
const saveResponse = await config.api.users.saveUser(builderUser, 200)
|
|
152
155
|
const { body: user } = await config.api.users.getUser(
|
|
153
156
|
saveResponse.body._id
|
|
154
157
|
)
|
|
@@ -168,13 +171,24 @@ describe("/api/global/roles", () => {
|
|
|
168
171
|
expect(res.body.message).toEqual("App role removed from all users")
|
|
169
172
|
})
|
|
170
173
|
|
|
171
|
-
it("should
|
|
174
|
+
it("should allow creator users to remove app roles for workspaces they owe", async () => {
|
|
175
|
+
const builderUser = await createBuilderUser([workspaceId])
|
|
176
|
+
|
|
177
|
+
const res = await config.withUser(builderUser, () =>
|
|
178
|
+
config.api.roles.remove(workspaceId, { status: 200 })
|
|
179
|
+
)
|
|
180
|
+
expect(res.body).toEqual({ message: "App role removed from all users" })
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it("should not allow creator users to remove app roles for workspaces they don't owe", async () => {
|
|
172
184
|
const builderUser = await createBuilderUser()
|
|
173
185
|
|
|
174
186
|
const res = await config.withUser(builderUser, () =>
|
|
175
187
|
config.api.roles.remove(workspaceId, { status: 403 })
|
|
176
188
|
)
|
|
177
|
-
expect(res.body.message).toBe(
|
|
189
|
+
expect(res.body.message).toBe(
|
|
190
|
+
"Workspace Admin/Builder user only endpoint."
|
|
191
|
+
)
|
|
178
192
|
})
|
|
179
193
|
})
|
|
180
194
|
})
|
|
@@ -195,7 +195,7 @@ describe("/api/global/users", () => {
|
|
|
195
195
|
expect(res.body.info.apps[appId]).toBe(role)
|
|
196
196
|
})
|
|
197
197
|
|
|
198
|
-
it("should allow
|
|
198
|
+
it("should not allow builders to edit invites for any app", async () => {
|
|
199
199
|
const { code } = await config.api.users.sendUserInvite(
|
|
200
200
|
sendMailMock,
|
|
201
201
|
structures.users.newEmail()
|
|
@@ -213,12 +213,11 @@ describe("/api/global/users", () => {
|
|
|
213
213
|
})
|
|
214
214
|
|
|
215
215
|
await config.login(builderUser)
|
|
216
|
-
|
|
216
|
+
await config.withUser(builderUser, async () =>
|
|
217
217
|
config.withApp(appId, () =>
|
|
218
|
-
config.api.users.addWorkspaceIdToInvite(code, role,
|
|
218
|
+
config.api.users.addWorkspaceIdToInvite(code, role, 403)
|
|
219
219
|
)
|
|
220
220
|
)
|
|
221
|
-
expect(res.body.info.apps[appId]).toBe(role)
|
|
222
221
|
})
|
|
223
222
|
})
|
|
224
223
|
|