Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/audits/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@ export function serverAudits(opts: ServerAuditOptions): Audit[] {
ressert(res).status.toBe(400);
},
),
audit(
'B7N8',
'SHOULD use 400 status code on JSON parsing failure when accepting application/graphql-response+json',
async () => {
const res = await fetchFn(await getUrl(opts.url), {
method: 'POST',
headers: {
'content-type': 'application/json',
accept: 'application/graphql-response+json',
},
body: '{ "not a JSON',
});
ressert(res).status.toBe(400);
},
),
audit(
'8764',
'MAY use 4xx or 5xx status codes if parameters are invalid',
Expand Down
4 changes: 4 additions & 0 deletions tests/__snapshots__/audits.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ exports[`should not change globally unique audit ids 1`] = `
"id": "BCF8",
"name": "MAY use 400 status code on JSON parsing failure",
},
{
"id": "B7N8",
"name": "SHOULD use 400 status code on JSON parsing failure when accepting application/graphql-response+json",
},
{
"id": "8764",
"name": "MAY use 4xx or 5xx status codes if parameters are invalid",
Expand Down
Loading