Files
swagger-ui/test/e2e-cypress/e2e/features/oauth2-flows/application.cy.js
Vladimír Gorej 3e81a4f897 chore(deps-dev): update cypress to v12 (#8889)
This update required changing the configuration
and test directory structure. Some tests needed
to be amended as well to compensate for new
Cypress APIs.
2023-06-07 10:25:32 +02:00

63 lines
1.5 KiB
JavaScript

describe("OAuth2 Application flow", function() {
beforeEach(() => {
cy.intercept("POST", "**/oauth/*").as("tokenRequest")
})
// https://github.com/swagger-api/swagger-ui/issues/6395
it("should have first authorization input autofocused", () => {
cy
.visit("/?url=http://localhost:3231/swagger.yaml")
.get(".btn.authorize")
.click()
cy.focused()
.should("have.id", "oauth_username")
})
it("should make an application flow Authorization header request", () => {
cy
.visit("/?url=http://localhost:3231/swagger.yaml")
.get(".btn.authorize")
.click()
.get("div.modal-ux-content > div:nth-child(2)").within(() => {
cy.get("#client_id")
.clear()
.type("confidentialApplication")
.get("#client_secret")
.clear()
.type("topSecret")
.get("button.btn.modal-btn.auth.authorize.button")
.click()
})
cy.get("button.close-modal")
.click()
.get("#operations-default-get_application")
.click()
.get(".btn.try-out__btn")
.click()
.get(".btn.execute")
.click()
cy.get("@tokenRequest")
.its("request")
.its("body")
.should("equal", "grant_type=client_credentials")
cy.get("@tokenRequest")
.its("request")
.its("headers")
.its("authorization")
.should("equal", "Basic Y29uZmlkZW50aWFsQXBwbGljYXRpb246dG9wU2VjcmV0")
.get(".live-responses-table .response-col_status")
.contains("200")
})
})