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 Joi from "joi"
|
||||||
import { BBContext } from "@budibase/types"
|
import { Ctx } from "@budibase/types"
|
||||||
|
|
||||||
function validate(
|
function validate(
|
||||||
schema: Joi.ObjectSchema | Joi.ArraySchema,
|
schema: Joi.ObjectSchema | Joi.ArraySchema,
|
||||||
property: string
|
property: string
|
||||||
) {
|
) {
|
||||||
// Return a Koa middleware function
|
// Return a Koa middleware function
|
||||||
return (ctx: BBContext, next: any) => {
|
return (ctx: Ctx, next: any) => {
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ function validate(
|
||||||
const { error } = schema.validate(params)
|
const { error } = schema.validate(params)
|
||||||
if (error) {
|
if (error) {
|
||||||
ctx.throw(400, `Invalid ${property} - ${error.message}`)
|
ctx.throw(400, `Invalid ${property} - ${error.message}`)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const useCloudFree = () => {
|
||||||
// FEATURES
|
// FEATURES
|
||||||
|
|
||||||
const useFeature = (feature: Feature) => {
|
const useFeature = (feature: Feature) => {
|
||||||
const license = cloneDeep(UNLIMITED_LICENSE)
|
const license = cloneDeep(getCachedLicense() || UNLIMITED_LICENSE)
|
||||||
const opts: UseLicenseOpts = {
|
const opts: UseLicenseOpts = {
|
||||||
features: [feature],
|
features: [feature],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 60e47a8249fd6291a6bc20fe3fe6776b11938fa1
|
Subproject commit 183b35d3acd42433dcb2d32bcd89a36abe13afec
|
|
@ -654,6 +654,26 @@ describe("scim", () => {
|
||||||
totalResults: groupCount,
|
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("Content-Type", /json/)
|
||||||
.expect(200)
|
.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