1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-04 00:18:40 +01:00

fix: return 400 on invalid JSON instead of 404 (#1897)

This commit is contained in:
olav 2022-08-08 14:44:57 +02:00 committed by GitHub
parent d4b9ca443c
commit df910cc20c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -59,7 +59,7 @@ export class OpenApiService {
validation: err.validationErrors, validation: err.validationErrors,
}); });
} else { } else {
next(); next(err);
} }
}); });
} }

View File

@ -340,6 +340,15 @@ test('require new feature toggle to have a name', async () => {
.expect(400); .expect(400);
}); });
test('should return 400 on invalid JSON data', async () => {
expect.assertions(0);
return app.request
.post('/api/admin/features')
.send(`{ invalid-json }`)
.set('Content-Type', 'application/json')
.expect(400);
});
test('can not change status of feature toggle that does not exist', async () => { test('can not change status of feature toggle that does not exist', async () => {
expect.assertions(0); expect.assertions(0);
return app.request return app.request