Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

fix: bug where if no securityschemes were present, we might return valid security #893

Merged
merged 1 commit into from
Aug 24, 2020
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Multiple Securities"
},
"paths": {
"/oauth": {
"post": {
"security": [
{
"oauth": ["write:things"]
}
]
}
}
}
}
11 changes: 11 additions & 0 deletions packages/api-explorer/__tests__/lib/is-auth-ready.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ const Oas = require('@readme/oas-tooling');
const isAuthReady = require('../../src/lib/is-auth-ready');
const authTypesOas = require('../__fixtures__/auth-types/oas');
const multipleSchemes = require('../__fixtures__/multiple-securities/oas');
const noSecuritySchemes = require('../__fixtures__/auth-types/no-security-schemes');

const oas = new Oas(authTypesOas);
const oas2 = new Oas(multipleSchemes);

describe('isAuthReady', () => {
it('should return true if a security type is defined, but no securitySchemes are present', () => {
const operation = new Oas(noSecuritySchemes).operation('/oauth', 'post');

expect(
isAuthReady(operation, {
oauth: 'bearer',
})
).toBe(true);
});

it('should return true if multiple security types required (&&)', () => {
const operation = oas2.operation('/and-security', 'post');

Expand Down
6 changes: 3 additions & 3 deletions packages/api-explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@readme/oas-extensions": "^7.0.0",
"@readme/oas-to-har": "^7.0.0",
"@readme/oas-to-snippet": "^7.0.1",
"@readme/oas-tooling": "^3.5.8",
"@readme/oas-tooling": "^3.5.9",
"@readme/react-jsonschema-form": "^1.2.0",
"@readme/syntax-highlighter": "^7.0.0",
"@readme/variable": "^7.0.0",
Expand Down
30 changes: 0 additions & 30 deletions packages/markdown-magic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/oas-to-har/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"dependencies": {
"@readme/oas-extensions": "^7.0.0",
"@readme/oas-tooling": "^3.5.8",
"@readme/oas-tooling": "^3.5.9",
"parse-data-url": "^2.0.0"
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/oas-to-snippet/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oas-to-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"devDependencies": {
"@readme/eslint-config": "^3.2.0",
"@readme/oas-examples": "^3.4.0",
"@readme/oas-tooling": "^3.5.8",
"@readme/oas-tooling": "^3.5.9",
"datauri": "^3.0.0",
"eslint": "^7.0.0",
"jest": "^26.0.1",
Expand Down