Merge pull request #13114 from Budibase/fix-scim-group-creation
Fix SCIM group creation
This commit is contained in:
commit
dacec0cf04
|
@ -1,12 +1,12 @@
|
|||
import Joi, { ObjectSchema } from "joi"
|
||||
import { BBContext } from "@budibase/types"
|
||||
import Joi from "joi"
|
||||
import { Ctx } from "@budibase/types"
|
||||
|
||||
function validate(
|
||||
schema: Joi.ObjectSchema | Joi.ArraySchema,
|
||||
property: string
|
||||
) {
|
||||
// Return a Koa middleware function
|
||||
return (ctx: BBContext, next: any) => {
|
||||
return (ctx: Ctx, next: any) => {
|
||||
if (!schema) {
|
||||
return next()
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ function validate(
|
|||
const { error } = schema.validate(params)
|
||||
if (error) {
|
||||
ctx.throw(400, `Invalid ${property} - ${error.message}`)
|
||||
return
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export const useCloudFree = () => {
|
|||
// FEATURES
|
||||
|
||||
const useFeature = (feature: Feature) => {
|
||||
const license = cloneDeep(UNLIMITED_LICENSE)
|
||||
const license = cloneDeep(getCachedLicense() || UNLIMITED_LICENSE)
|
||||
const opts: UseLicenseOpts = {
|
||||
features: [feature],
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 60e47a8249fd6291a6bc20fe3fe6776b11938fa1
|
||||
Subproject commit 183b35d3acd42433dcb2d32bcd89a36abe13afec
|
|
@ -654,6 +654,26 @@ describe("scim", () => {
|
|||
totalResults: groupCount,
|
||||
})
|
||||
})
|
||||
|
||||
it("can fetch groups even if internal groups exist", async () => {
|
||||
mocks.licenses.useGroups()
|
||||
await config.api.groups.saveGroup(structures.userGroups.userGroup())
|
||||
await config.api.groups.saveGroup(structures.userGroups.userGroup())
|
||||
|
||||
const response = await getScimGroups()
|
||||
|
||||
expect(response).toEqual({
|
||||
Resources: expect.arrayContaining(groups),
|
||||
itemsPerPage: 25,
|
||||
schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
|
||||
startIndex: 1,
|
||||
totalResults: groupCount,
|
||||
})
|
||||
|
||||
expect((await config.api.groups.fetch()).body.data).toHaveLength(
|
||||
25 + 2 // scim groups + internal groups
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -53,4 +53,12 @@ export class GroupsAPI extends TestAPI {
|
|||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
}
|
||||
|
||||
fetch = ({ expect } = { expect: 200 }) => {
|
||||
return this.request
|
||||
.get(`/api/global/groups`)
|
||||
.set(this.config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(expect)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue