fix: support variables in auth urls (#5913)

This commit is contained in:
John
2020-06-11 07:45:02 +10:00
committed by GitHub
parent 01fb5c07ab
commit 21f51494a2
2 changed files with 23 additions and 6 deletions

View File

@@ -156,7 +156,8 @@ export const authorizeRequest = ( data ) => ( { fn, getConfigs, authActions, err
let parsedUrl let parsedUrl
if (specSelectors.isOAS3()) { if (specSelectors.isOAS3()) {
parsedUrl = parseUrl(url, oas3Selectors.selectedServer(), true) const server = oas3Selectors.selectedServer()
parsedUrl = parseUrl(url, oas3Selectors.serverEffectiveValue({ server }), true)
} else { } else {
parsedUrl = parseUrl(url, specSelectors.url(), true) parsedUrl = parseUrl(url, specSelectors.url(), true)
} }

View File

@@ -14,6 +14,18 @@ describe("auth plugin - actions", () => {
{ {
oas3: true, oas3: true,
server: "https://host/resource", server: "https://host/resource",
effectiveServer: "https://host/resource",
scheme: "http",
host: null,
url: "http://specs/file",
},
"https://host/authorize"
],
[
{
oas3: true,
server: "https://{selected_host}/resource",
effectiveServer: "https://host/resource",
scheme: "http", scheme: "http",
host: null, host: null,
url: "http://specs/file", url: "http://specs/file",
@@ -24,6 +36,7 @@ describe("auth plugin - actions", () => {
{ {
oas3: false, oas3: false,
server: null, server: null,
effectiveServer: null,
scheme: "https", scheme: "https",
host: undefined, host: undefined,
url: "https://specs/file", url: "https://specs/file",
@@ -34,13 +47,14 @@ describe("auth plugin - actions", () => {
{ {
oas3: false, oas3: false,
server: null, server: null,
effectiveServer: null,
scheme: "https", scheme: "https",
host: "host", host: "host",
url: "http://specs/file", url: "http://specs/file",
}, },
"http://specs/authorize" "http://specs/authorize"
], ],
].forEach(([{oas3, server, scheme, host, url}, expectedFetchUrl]) => { ].forEach(([{oas3, server, effectiveServer, scheme, host, url}, expectedFetchUrl]) => {
it("should resolve authorization endpoint against the server URL", () => { it("should resolve authorization endpoint against the server URL", () => {
// Given // Given
@@ -56,7 +70,8 @@ describe("auth plugin - actions", () => {
getConfigs: () => ({}) getConfigs: () => ({})
}, },
oas3Selectors: { oas3Selectors: {
selectedServer: () => server selectedServer: () => server,
serverEffectiveValue: () => effectiveServer || server
}, },
specSelectors: { specSelectors: {
isOAS3: () => oas3, isOAS3: () => oas3,
@@ -130,7 +145,8 @@ describe("auth plugin - actions", () => {
}) })
}, },
oas3Selectors: { oas3Selectors: {
selectedServer: () => "http://google.com" selectedServer: () => "http://google.com",
serverEffectiveValue: () => "http://google.com"
}, },
specSelectors: { specSelectors: {
isOAS3: () => true, isOAS3: () => true,