You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.2 KiB

  1. /* eslint-env mocha */
  2. import expect, { createSpy } from "expect"
  3. import { fromJS } from "immutable"
  4. import win from "core/window"
  5. import oauth2Authorize from "core/oauth2-authorize"
  6. describe("oauth2", function () {
  7. let mockSchema = {
  8. flow: "accessCode",
  9. authorizationUrl: "https://testAuthorizationUrl"
  10. }
  11. let authConfig = {
  12. auth: { schema: { get: (key)=> mockSchema[key] } },
  13. authActions: {},
  14. errActions: {},
  15. configs: { oauth2RedirectUrl: "" },
  16. authConfigs: {}
  17. }
  18. describe("authorize redirect", function () {
  19. it("should build authorize url", function() {
  20. win.open = createSpy()
  21. oauth2Authorize(authConfig)
  22. expect(win.open.calls.length).toEqual(1)
  23. expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?response_type=code&redirect_uri=&state=")
  24. })
  25. it("should append query paramters to authorizeUrl with query parameters", function() {
  26. win.open = createSpy()
  27. mockSchema.authorizationUrl = "https://testAuthorizationUrl?param=1"
  28. oauth2Authorize(authConfig)
  29. expect(win.open.calls.length).toEqual(1)
  30. expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?param=1&response_type=code&redirect_uri=&state=")
  31. })
  32. })
  33. })