Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

64 righe
1.8 KiB

  1. const expect = require("expect")
  2. const oauthBlockBuilder = require("../../../docker/configurator/oauth")
  3. const dedent = require("dedent")
  4. describe("docker: env translator - oauth block", function() {
  5. it("should omit the block if there are no valid keys", function () {
  6. const input = {}
  7. expect(oauthBlockBuilder(input)).toEqual(``)
  8. })
  9. it("should omit the block if there are no valid keys", function () {
  10. const input = {
  11. NOT_A_VALID_KEY: "asdf1234"
  12. }
  13. expect(oauthBlockBuilder(input)).toEqual(``)
  14. })
  15. it("should generate a block from empty values", function() {
  16. const input = {
  17. OAUTH_CLIENT_ID: ``,
  18. OAUTH_CLIENT_SECRET: ``,
  19. OAUTH_REALM: ``,
  20. OAUTH_APP_NAME: ``,
  21. OAUTH_SCOPE_SEPARATOR: "",
  22. OAUTH_ADDITIONAL_PARAMS: ``,
  23. OAUTH_USE_PKCE: false
  24. }
  25. expect(oauthBlockBuilder(input)).toEqual(dedent(`
  26. ui.initOAuth({
  27. clientId: "",
  28. clientSecret: "",
  29. realm: "",
  30. appName: "",
  31. scopeSeparator: "",
  32. additionalQueryStringParams: undefined,
  33. usePkceWithAuthorizationCodeGrant: false,
  34. })`))
  35. })
  36. it("should generate a full block", function() {
  37. const input = {
  38. OAUTH_CLIENT_ID: `myId`,
  39. OAUTH_CLIENT_SECRET: `mySecret`,
  40. OAUTH_REALM: `myRealm`,
  41. OAUTH_APP_NAME: `myAppName`,
  42. OAUTH_SCOPE_SEPARATOR: "%21",
  43. OAUTH_ADDITIONAL_PARAMS: `{ "a": 1234, "b": "stuff" }`,
  44. OAUTH_USE_PKCE: true
  45. }
  46. expect(oauthBlockBuilder(input)).toEqual(dedent(`
  47. ui.initOAuth({
  48. clientId: "myId",
  49. clientSecret: "mySecret",
  50. realm: "myRealm",
  51. appName: "myAppName",
  52. scopeSeparator: "%21",
  53. additionalQueryStringParams: { "a": 1234, "b": "stuff" },
  54. usePkceWithAuthorizationCodeGrant: true,
  55. })`))
  56. })
  57. })