Do not allow undefined names on request

This commit is contained in:
Adria Navarro 2023-05-08 12:41:48 +02:00
parent e74462a687
commit 752790f3c9
3 changed files with 11 additions and 3 deletions

@ -1 +1 @@
Subproject commit 79bc94b17baba885eb20e72f9abba3ac8b9c0eab
Subproject commit 151e785f0ac38054f3930ca4b04e191a31c733f5

View File

@ -24,6 +24,14 @@ describe("/api/global/groups", () => {
expect(events.group.updated).not.toBeCalled()
expect(events.group.permissionsEdited).not.toBeCalled()
})
it("should not allow undefined names", async () => {
const group = { ...structures.groups.UserGroup(), name: undefined } as any
const response = await config.api.groups.saveGroup(group, { expect: 400 })
expect(JSON.parse(response.text).message).toEqual(
'Invalid body - "name" is required'
)
})
})
describe("update", () => {

View File

@ -7,13 +7,13 @@ export class GroupsAPI extends TestAPI {
super(config)
}
saveGroup = (group: UserGroup) => {
saveGroup = (group: UserGroup, { expect } = { expect: 200 }) => {
return this.request
.post(`/api/global/groups`)
.send(group)
.set(this.config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(200)
.expect(expect)
}
deleteGroup = (id: string, rev: string) => {