mirror of
https://github.com/sasjs/server.git
synced 2026-01-15 09:50:06 +00:00
chore: add spec for invalid principal type
This commit is contained in:
@@ -209,7 +209,9 @@ const createPermission = async ({
|
|||||||
clientId = clientInDB.clientId
|
clientId = clientInDB.clientId
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error('Invalid principal type.')
|
throw new Error(
|
||||||
|
'Invalid principal type. Valid types are user, group and client.'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedPermission = await permission.save()
|
const savedPermission = await permission.save()
|
||||||
|
|||||||
@@ -252,6 +252,22 @@ describe('permission', () => {
|
|||||||
expect(res.text).toEqual('Error: Client not found.')
|
expect(res.text).toEqual('Error: Client not found.')
|
||||||
expect(res.body).toEqual({})
|
expect(res.body).toEqual({})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should respond with forbidden Request (403) if principal type is not valid', async () => {
|
||||||
|
const res = await request(app)
|
||||||
|
.post('/SASjsApi/permission')
|
||||||
|
.auth(adminAccessToken, { type: 'bearer' })
|
||||||
|
.send({
|
||||||
|
...permission,
|
||||||
|
principalType: 'invalid'
|
||||||
|
})
|
||||||
|
.expect(403)
|
||||||
|
|
||||||
|
expect(res.text).toEqual(
|
||||||
|
'Error: Invalid principal type. Valid types are user, group and client.'
|
||||||
|
)
|
||||||
|
expect(res.body).toEqual({})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('update', () => {
|
describe('update', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user