No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

100 líneas
3.4 KiB

  1. const clickTryItOutAndExecute = () => {
  2. return cy
  3. .get(".btn.try-out__btn") // expand "try it out"
  4. .click()
  5. .get(".btn.execute") // execute request
  6. .click()
  7. }
  8. const fillInApiKeyAndAuthorise = apiKey => () => {
  9. return cy
  10. .get("section>input") // type api key into input
  11. .type(apiKey)
  12. .get(".auth-btn-wrapper > .authorize") // authorise button
  13. .click()
  14. }
  15. const clickLogoutAndReauthorise = () => {
  16. return cy
  17. .get(".auth-btn-wrapper button:nth-child(1)") // logout button
  18. .click()
  19. .get(".auth-btn-wrapper > .authorize") // authorise button
  20. .click()
  21. }
  22. describe("#4641: The Logout button in Authorize popup not clearing API Key", () => {
  23. beforeEach(() => {
  24. cy.server()
  25. cy
  26. .route({
  27. url: "/4641*",
  28. response: "OK",
  29. })
  30. .as("request")
  31. })
  32. it("should include the given api key in requests", () => {
  33. cy
  34. .visit("/?url=/documents/bugs/4641.yaml")
  35. .get("button.btn.authorize") // open authorize popup
  36. .click()
  37. .get(".modal-ux-content > :nth-child(1)") // only deal with api_key_1 for this test
  38. .within(fillInApiKeyAndAuthorise("my_api_key"))
  39. .get(".close-modal") // close authorise popup button
  40. .click()
  41. .get("#operations-default-get_4641_1") // expand the route details onClick
  42. .click()
  43. .within(clickTryItOutAndExecute)
  44. .wait("@request")
  45. .its("request")
  46. .then((req) => {
  47. expect(req.headers, "request headers").to.have.property("api_key_1", "my_api_key")
  48. })
  49. })
  50. it("should not remember the previous auth value when you logout and reauthorise", () => {
  51. cy
  52. .visit("/?url=/documents/bugs/4641.yaml")
  53. .get("button.btn.authorize") // open authorize popup
  54. .click()
  55. .get(".modal-ux-content > :nth-child(1)") // only deal with api_key_1 for this test
  56. .within(fillInApiKeyAndAuthorise("my_api_key"))
  57. .get(".modal-ux-content > :nth-child(1)") // only deal with api_key_1 for this test
  58. .within(clickLogoutAndReauthorise)
  59. .get(".close-modal") // close authorise popup button
  60. .click()
  61. .get("#operations-default-get_4641_1") // expand the route details onClick
  62. .click()
  63. .within(clickTryItOutAndExecute)
  64. .wait("@request")
  65. .its("request")
  66. .then((req) => {
  67. expect(req.headers, "request headers").not.to.have.property("api_key_1")
  68. })
  69. })
  70. it("should only forget the value of the auth the user logged out from", () => {
  71. cy
  72. .visit("/?url=/documents/bugs/4641.yaml")
  73. .get("button.btn.authorize") // open authorize popup
  74. .click()
  75. .get(".modal-ux-content > :nth-child(1)") // deal with api_key_1
  76. .within(fillInApiKeyAndAuthorise("my_api_key"))
  77. .get(".modal-ux-content > :nth-child(2)") // deal with api_key_2
  78. .within(fillInApiKeyAndAuthorise("my_second_api_key"))
  79. .get(".modal-ux-content > :nth-child(1)") // deal with api_key_1 again
  80. .within(clickLogoutAndReauthorise)
  81. .get(".close-modal") // close authorise popup button
  82. .click()
  83. .get("#operations-default-get_4641_2") // expand the route details onClick
  84. .click()
  85. .within(clickTryItOutAndExecute)
  86. .wait("@request")
  87. .its("request")
  88. .then((req) => {
  89. expect(req.headers, "request headers").not.to.have.property("api_key_1")
  90. expect(req.headers, "request headers").to.have.property("api_key_2", "my_second_api_key")
  91. })
  92. })
  93. })