Skip to content

Commit

Permalink
test(e2e): ensure there is only one OIDC redirect
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Fijałkowski <[email protected]>
  • Loading branch information
Saancreed and jakubfijalkowski committed Aug 18, 2023
1 parent 1e9b8cc commit 13b1842
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,50 @@ context("Social Sign Up Successes", () => {
})
})

it("should redirect to oidc provider only once", () => {
const email = gen.email()

cy.registerOidc({
app,
email,
expectSession: false,
route: registration,
})

cy.get(appPrefix(app) + '[name="traits.email"]').should(
"have.value",
email,
)

cy.get('[name="traits.consent"][type="checkbox"]')
.siblings("label")
.click()
cy.get('[name="traits.newsletter"][type="checkbox"]')
.siblings("label")
.click()
cy.get('[name="traits.website"]').type(website)

cy.intercept(
"GET",
"http://*/oauth2/auth*",
{ forceNetworkError: true },
)
.as("additionalRedirect")

cy.triggerOidc(app)

cy.get("@additionalRedirect").should("not.exist")

cy.location("pathname").should((loc) => {
expect(loc).to.be.oneOf(["/welcome", "/", "/sessions"])
})

cy.getSession().should((session) => {
shouldSession(email)(session)
expect(session.identity.traits.consent).to.equal(true)
})
})

it("should pass transient_payload to webhook", () => {
testRegistrationWebhook(
(hooks) => cy.setupHooks("registration", "after", "oidc", hooks),
Expand Down

0 comments on commit 13b1842

Please sign in to comment.