application.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. describe("OAuth2 Application flow", function() {
  2. beforeEach(() => {
  3. cy.server()
  4. cy.route({
  5. url: "**/oauth/*",
  6. method: "POST"
  7. }).as("tokenRequest")
  8. })
  9. // https://github.com/swagger-api/swagger-ui/issues/6395
  10. it("should have first authorization input autofocused", () => {
  11. cy
  12. .visit("/?url=http://localhost:3231/swagger.yaml")
  13. .get(".btn.authorize")
  14. .click()
  15. cy.focused()
  16. .should("have.id", "oauth_username")
  17. })
  18. it("should make an application flow Authorization header request", () => {
  19. cy
  20. .visit("/?url=http://localhost:3231/swagger.yaml")
  21. .get(".btn.authorize")
  22. .click()
  23. .get("div.modal-ux-content > div:nth-child(2)").within(() => {
  24. cy.get("#client_id")
  25. .clear()
  26. .type("confidentialApplication")
  27. .get("#client_secret")
  28. .clear()
  29. .type("topSecret")
  30. .get("button.btn.modal-btn.auth.authorize.button")
  31. .click()
  32. })
  33. cy.get("button.close-modal")
  34. .click()
  35. .get("#operations-default-get_application")
  36. .click()
  37. .get(".btn.try-out__btn")
  38. .click()
  39. .get(".btn.execute")
  40. .click()
  41. cy.get("@tokenRequest")
  42. .its("request")
  43. .its("body")
  44. .should("equal", "grant_type=client_credentials")
  45. cy.get("@tokenRequest")
  46. .its("request")
  47. .its("headers")
  48. .its("authorization")
  49. .should("equal", "Basic Y29uZmlkZW50aWFsQXBwbGljYXRpb246dG9wU2VjcmV0")
  50. .get(".live-responses-table .response-col_status")
  51. .contains("200")
  52. })
  53. })