test(update-auth-client): cover HTTP 422 response
This commit is contained in:
@@ -2,10 +2,8 @@ import { renderObject } from '../../../../../helpers/renderer.js';
|
||||
import AppAuthClient from '../../../../../models/app-auth-client.js';
|
||||
|
||||
export default async (request, response) => {
|
||||
const id = request.params.appAuthClientId;
|
||||
|
||||
const appAuthClient = await AppAuthClient.query()
|
||||
.findById(id)
|
||||
.findById(request.params.appAuthClientId)
|
||||
.throwIfNotFound();
|
||||
|
||||
await appAuthClient.$query().patchAndFetch(appAuthClientParams(request));
|
||||
|
@@ -77,4 +77,28 @@ describe('PATCH /api/v1/admin/apps/:appKey/auth-clients', () => {
|
||||
.set('Authorization', token)
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
it('should return HTTP 422 for invalid payload', async () => {
|
||||
const appAuthClient = {
|
||||
formattedAuthDefaults: 'invalid input',
|
||||
};
|
||||
|
||||
const existingAppAuthClient = await createAppAuthClient({
|
||||
appKey: 'gitlab',
|
||||
name: 'First auth client',
|
||||
});
|
||||
|
||||
const response = await request(app)
|
||||
.patch(
|
||||
`/api/v1/admin/apps/gitlab/auth-clients/${existingAppAuthClient.id}`
|
||||
)
|
||||
.set('Authorization', token)
|
||||
.send(appAuthClient)
|
||||
.expect(422);
|
||||
|
||||
expect(response.body.meta.type).toBe('ModelValidation');
|
||||
expect(response.body.errors).toMatchObject({
|
||||
formattedAuthDefaults: ['must be object'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user