From 13b1842472fbaee23433e632774e28d7b6c6f8e4 Mon Sep 17 00:00:00 2001 From: Krzysztof Bogacki Date: Fri, 18 Aug 2023 15:48:21 +0200 Subject: [PATCH] test(e2e): ensure there is only one OIDC redirect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jakub FijaƂkowski --- .../oidc/registration/success.spec.ts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/e2e/cypress/integration/profiles/oidc/registration/success.spec.ts b/test/e2e/cypress/integration/profiles/oidc/registration/success.spec.ts index ca2e2700ef7a..58d23cb3f0d0 100644 --- a/test/e2e/cypress/integration/profiles/oidc/registration/success.spec.ts +++ b/test/e2e/cypress/integration/profiles/oidc/registration/success.spec.ts @@ -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),