Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

122 rindas
2.9 KiB

  1. describe("OAuth2 Password flow", function() {
  2. beforeEach(() => {
  3. cy.server()
  4. cy.route({
  5. url: "**/oauth/*",
  6. method: "POST"
  7. }).as("tokenRequest")
  8. })
  9. it("should make a password flow Authorization header request", () => {
  10. cy
  11. .visit("/?url=http://localhost:3231/swagger.yaml")
  12. .get(".btn.authorize")
  13. .click()
  14. .get("#oauth_username")
  15. .type("swagger")
  16. .get("#oauth_password")
  17. .type("password")
  18. .get("#password_type")
  19. .select("basic")
  20. .get("#client_id")
  21. .clear()
  22. .type("application")
  23. .get("#client_secret")
  24. .clear()
  25. .type("secret")
  26. .get("div.modal-ux-content > div:nth-child(1) > div > div:nth-child(2) > div > div.auth-btn-wrapper > button.btn.modal-btn.auth.authorize.button")
  27. .click()
  28. .get("button.close-modal")
  29. .click()
  30. .get("#operations-default-get_password")
  31. .click()
  32. .get(".btn.try-out__btn")
  33. .click()
  34. .get(".btn.execute")
  35. .click()
  36. cy.get("@tokenRequest")
  37. .its("request")
  38. .its("body")
  39. .should("include", "grant_type=password")
  40. .should("include", "username=swagger")
  41. .should("include", "password=password")
  42. .should("not.include", "client_id")
  43. .should("not.include", "client_secret")
  44. cy.get("@tokenRequest")
  45. .its("request")
  46. .its("headers")
  47. .its("authorization")
  48. .should("equal", "Basic YXBwbGljYXRpb246c2VjcmV0")
  49. .get(".live-responses-table .response-col_status")
  50. .contains("200")
  51. })
  52. it("should make a Password flow request-body request", () => {
  53. cy
  54. .visit("/?url=http://localhost:3231/swagger.yaml")
  55. .get(".btn.authorize")
  56. .click()
  57. .get("#oauth_username")
  58. .type("swagger")
  59. .get("#oauth_password")
  60. .type("password")
  61. .get("#password_type")
  62. .select("request-body")
  63. .get("#client_id")
  64. .clear()
  65. .type("application")
  66. .get("#client_secret")
  67. .clear()
  68. .type("secret")
  69. .get("div.modal-ux-content > div:nth-child(1) > div > div:nth-child(2) > div > div.auth-btn-wrapper > button.btn.modal-btn.auth.authorize.button")
  70. .click()
  71. .get("button.close-modal")
  72. .click()
  73. .get("#operations-default-get_password")
  74. .click()
  75. .get(".btn.try-out__btn")
  76. .click()
  77. .get(".btn.execute")
  78. .click()
  79. cy.get("@tokenRequest")
  80. .its("request")
  81. .its("body")
  82. .should("include", "grant_type=password")
  83. .should("include", "username=swagger")
  84. .should("include", "password=password")
  85. .should("include", "client_id=application")
  86. .should("include", "client_secret=secret")
  87. cy.get("@tokenRequest")
  88. .its("request")
  89. .its("headers")
  90. .should("not.have.property", "authorization")
  91. .get(".live-responses-table .response-col_status")
  92. .contains("200")
  93. })
  94. })