OAuth2 authorizationUrl with extra query parameters (should include double '?')
This commit is contained in:
@@ -64,7 +64,8 @@ export default function authorize ( { auth, authActions, errActions, configs, au
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = [schema.get("authorizationUrl"), query.join("&")].join("?")
|
let authorizationUrl = schema.get("authorizationUrl");
|
||||||
|
let url = [authorizationUrl, query.join("&")].join(authorizationUrl.indexOf('?') === -1 ? "?" : "&")
|
||||||
|
|
||||||
// pass action authorizeOauth2 and authentication data through window
|
// pass action authorizeOauth2 and authentication data through window
|
||||||
// to authorize with oauth2
|
// to authorize with oauth2
|
||||||
|
|||||||
39
test/core/oauth2-authorize.js
Normal file
39
test/core/oauth2-authorize.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
import expect, { createSpy } from "expect"
|
||||||
|
import { fromJS } from "immutable"
|
||||||
|
import win from "core/window"
|
||||||
|
import oauth2Authorize from "core/oauth2-authorize"
|
||||||
|
|
||||||
|
describe("OAuth2", function () {
|
||||||
|
|
||||||
|
let mockSchema = {
|
||||||
|
flow: 'accessCode',
|
||||||
|
authorizationUrl: 'https://testAuthorizationUrl'
|
||||||
|
};
|
||||||
|
|
||||||
|
let authConfig = {
|
||||||
|
auth: { schema: { get: (key)=> mockSchema[key] } },
|
||||||
|
authActions: {},
|
||||||
|
errActions: {},
|
||||||
|
configs: { oauth2RedirectUrl: "" },
|
||||||
|
authConfigs: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("authorize redirect", function () {
|
||||||
|
|
||||||
|
it("should build redirectUrl", function() {
|
||||||
|
win.open = createSpy();
|
||||||
|
oauth2Authorize(authConfig);
|
||||||
|
expect(win.open.calls.length).toEqual(1);
|
||||||
|
expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?response_type=code&redirect_uri=&state=");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should build correct redirectUrl from authorizeUrl with query parameters", function() {
|
||||||
|
win.open = createSpy();
|
||||||
|
mockSchema.authorizationUrl = 'https://testAuthorizationUrl?param=1';
|
||||||
|
oauth2Authorize(authConfig);
|
||||||
|
expect(win.open.calls.length).toEqual(1);
|
||||||
|
expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?param=1&response_type=code&redirect_uri=&state=");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user