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
if (specSelectors.isOAS3()) {
parsedUrl = parseUrl(url, oas3Selectors.selectedServer(), true)
const server = oas3Selectors.selectedServer()
parsedUrl = parseUrl(url, oas3Selectors.serverEffectiveValue({ server }), true)
} else {
parsedUrl = parseUrl(url, specSelectors.url(), true)
}

View File

@@ -14,6 +14,18 @@ describe("auth plugin - actions", () => {
{
oas3: true,
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",
host: null,
url: "http://specs/file",
@@ -24,6 +36,7 @@ describe("auth plugin - actions", () => {
{
oas3: false,
server: null,
effectiveServer: null,
scheme: "https",
host: undefined,
url: "https://specs/file",
@@ -34,13 +47,14 @@ describe("auth plugin - actions", () => {
{
oas3: false,
server: null,
effectiveServer: null,
scheme: "https",
host: "host",
url: "http://specs/file",
},
"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", () => {
// Given
@@ -56,7 +70,8 @@ describe("auth plugin - actions", () => {
getConfigs: () => ({})
},
oas3Selectors: {
selectedServer: () => server
selectedServer: () => server,
serverEffectiveValue: () => effectiveServer || server
},
specSelectors: {
isOAS3: () => oas3,
@@ -130,7 +145,8 @@ describe("auth plugin - actions", () => {
})
},
oas3Selectors: {
selectedServer: () => "http://google.com"
selectedServer: () => "http://google.com",
serverEffectiveValue: () => "http://google.com"
},
specSelectors: {
isOAS3: () => true,