Skip to content

Commit

Permalink
Fix inconsistency for results associated to skipped blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Aug 3, 2024
1 parent d90b704 commit 8512efc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const parseSecurity = (operation, spec, securityHandlers) => {
const blockHasMissingValues = Object.keys(block).some(name => readSchemeValue(name) == null);

if (blockHasMissingValues) {
report.push({ schemes: {}, status: 'skipped' });
report.push({ ok: false, schemes: {} });
continue;
}

Expand Down
19 changes: 18 additions & 1 deletion src/parser/security.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,29 @@ describe('parseSecurity()', () => {

const onRequest = parseSecurity(operation, spec, securityHandlers);

expect.assertions(2);
expect.assertions(3);

await onRequest(request);

expect(securityHandlers.ApiKey).not.toHaveBeenCalled();
expect(securityHandlers.OAuth2).toHaveBeenCalledTimes(1);
expect(request[DECORATOR_NAME].securityReport).toMatchInlineSnapshot(`
[
{
"ok": false,
"schemes": {},
},
{
"ok": true,
"schemes": {
"OAuth2": {
"data": "OAuth2 data",
"ok": true,
},
},
},
]
`);
});

it('should validate scopes', async () => {
Expand Down

0 comments on commit 8512efc

Please sign in to comment.