diff --git a/cypress/integration/ete/reset_password_1.3.cy.ts b/cypress/integration/ete/reset_password_1.3.cy.ts index 154c4ed22..8e6093667 100644 --- a/cypress/integration/ete/reset_password_1.3.cy.ts +++ b/cypress/integration/ete/reset_password_1.3.cy.ts @@ -8,7 +8,7 @@ const breachCheck = () => { }).as('breachCheck'); }; -describe('Password reset flow in Okta', () => { +describe('Password reset flow in Okta - useOktaClassic', () => { context('Account exists', () => { it("changes the reader's password", () => { const encodedReturnUrl = @@ -30,7 +30,7 @@ describe('Password reset flow in Okta', () => { }) ?.then(({ emailAddress }) => { cy.visit( - `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}`, + `/reset-password?useOktaClassic=true&returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}`, ); const timeRequestWasMade = new Date(); @@ -99,7 +99,7 @@ describe('Password reset flow in Okta', () => { }) ?.then(({ emailAddress }) => { cy.visit( - `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}`, + `/reset-password?useOktaClassic=true&returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}`, ); const timeRequestWasMade = new Date(); @@ -159,7 +159,9 @@ describe('Password reset flow in Okta', () => { isUserEmailValidated: true, }) ?.then(({ emailAddress }) => { - cy.visit(`/reset-password?returnUrl=${encodedReturnUrl}`); + cy.visit( + `/reset-password?useOktaClassic=true&returnUrl=${encodedReturnUrl}`, + ); const timeRequestWasMade = new Date(); cy.contains('Reset password'); @@ -224,7 +226,7 @@ describe('Password reset flow in Okta', () => { }) ?.then(({ emailAddress }) => { cy.visit( - `/reset-password?returnUrl=${encodedReturnUrl}&appClientId=${appClientId1}&fromURI=${fromURI1}`, + `/reset-password?useOktaClassic=true&returnUrl=${encodedReturnUrl}&appClientId=${appClientId1}&fromURI=${fromURI1}`, ); const timeRequestWasMade = new Date(); @@ -270,7 +272,7 @@ describe('Password reset flow in Okta', () => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.STAGED); - cy.visit('/reset-password'); + cy.visit('/reset-password?useOktaClassic=true'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -323,7 +325,7 @@ describe('Password reset flow in Okta', () => { const fromURI = 'fromURI1'; cy.visit( - `/reset-password?appClientId=${appClientId}&fromURI=${fromURI}`, + `/reset-password?useOktaClassic=true&appClientId=${appClientId}&fromURI=${fromURI}`, ); const timeRequestWasMade = new Date(); @@ -376,7 +378,7 @@ describe('Password reset flow in Okta', () => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.PROVISIONED); - cy.visit('/reset-password'); + cy.visit('/reset-password?useOktaClassic=true'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -429,7 +431,7 @@ describe('Password reset flow in Okta', () => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.RECOVERY); - cy.visit('/reset-password'); + cy.visit('/reset-password?useOktaClassic=true'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -481,7 +483,7 @@ describe('Password reset flow in Okta', () => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.PASSWORD_EXPIRED); - cy.visit('/reset-password'); + cy.visit('/reset-password?useOktaClassic=true'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -540,7 +542,7 @@ describe('Password reset flow in Okta', () => { ); cy.get('input[name=email]').type('test@email.com'); cy.get('button[type="submit"]').click(); - cy.contains('Check your inbox'); + cy.contains('Enter your one-time code'); }); }); }); diff --git a/cypress/integration/ete/reset_password_2.5.cy.ts b/cypress/integration/ete/reset_password_2.5.cy.ts index 3be005c2a..a756c7e8d 100644 --- a/cypress/integration/ete/reset_password_2.5.cy.ts +++ b/cypress/integration/ete/reset_password_2.5.cy.ts @@ -52,34 +52,33 @@ describe('Password reset recovery flows', () => { cy.get('input[name=email]').clear().type(emailAddress); cy.get('[data-cy="main-form-submit-button"]').click(); - cy.contains('Check your inbox'); - cy.contains(emailAddress); - cy.checkForEmailAndGetDetails( emailAddress, timeRequestWasMade, - /\/set-password\/([^"]*)/, - ).then(({ links, body }) => { - expect(body).to.have.string('Welcome back'); - - expect(body).to.have.string('Create password'); - expect(links.length).to.eq(2); - const setPasswordLink = links.find((s) => - s.text?.includes('Create password'), - ); - - cy.visit(setPasswordLink?.href as string); - cy.contains('Create password'); - cy.contains(emailAddress); - - cy.get('input[name=password]').type(randomPassword()); - - cy.wait('@breachCheck'); - cy.get('[data-cy="main-form-submit-button"]') - .click() - .should('be.disabled'); - cy.contains('Password created'); - cy.contains(emailAddress.toLowerCase()); + ).then(({ body, codes }) => { + // email + expect(body).to.have.string('Your one-time passcode'); + expect(codes?.length).to.eq(1); + const code = codes?.[0].value; + expect(code).to.match(/^\d{6}$/); + + // passcode page + cy.url().should('include', '/reset-password/email-sent'); + cy.contains('Enter your one-time code'); + + cy.get('input[name=code]').clear().type(code!); + cy.contains('Submit one-time code').click(); + + // password page + cy.url().should('include', '/reset-password/password'); + + cy.get('input[name="password"]').type(randomPassword()); + cy.get('button[type="submit"]').click(); + + // password complete page + cy.url().should('include', '/reset-password/complete'); + + cy.contains('Password updated'); }); }, ); @@ -125,34 +124,33 @@ describe('Password reset recovery flows', () => { cy.get('input[name=email]').clear().type(emailAddress); cy.get('[data-cy="main-form-submit-button"]').click(); - cy.contains('Check your inbox'); - cy.contains(emailAddress); - cy.checkForEmailAndGetDetails( emailAddress, timeRequestWasMade, - /\/set-password\/([^"]*)/, - ).then(({ links, body }) => { - expect(body).to.have.string('Welcome back'); - - expect(body).to.have.string('Create password'); - expect(links.length).to.eq(2); - const setPasswordLink = links.find((s) => - s.text?.includes('Create password'), - ); - - cy.visit(setPasswordLink?.href as string); - cy.contains('Create password'); - cy.contains(emailAddress); - - cy.get('input[name=password]').type(randomPassword()); - - cy.wait('@breachCheck'); - cy.get('[data-cy="main-form-submit-button"]') - .click() - .should('be.disabled'); - cy.contains('Password created'); - cy.contains(emailAddress.toLowerCase()); + ).then(({ body, codes }) => { + // email + expect(body).to.have.string('Your one-time passcode'); + expect(codes?.length).to.eq(1); + const code = codes?.[0].value; + expect(code).to.match(/^\d{6}$/); + + // passcode page + cy.url().should('include', '/reset-password/email-sent'); + cy.contains('Enter your one-time code'); + + cy.get('input[name=code]').clear().type(code!); + cy.contains('Submit one-time code').click(); + + // password page + cy.url().should('include', '/reset-password/password'); + + cy.get('input[name="password"]').type(randomPassword()); + cy.get('button[type="submit"]').click(); + + // password complete page + cy.url().should('include', '/reset-password/complete'); + + cy.contains('Password updated'); }); }); }, diff --git a/cypress/integration/ete/reset_password_passcode.7.cy.ts b/cypress/integration/ete/reset_password_passcode.7.cy.ts index 1770b3a9b..566e3c9e2 100644 --- a/cypress/integration/ete/reset_password_passcode.7.cy.ts +++ b/cypress/integration/ete/reset_password_passcode.7.cy.ts @@ -18,7 +18,7 @@ describe('Password reset recovery flows - with Passcodes', () => { isUserEmailValidated: true, }).then(({ emailAddress }) => { cy.visit( - `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&usePasscodesResetPassword=true`, + `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}`, ); const timeRequestWasMade = new Date(); @@ -104,7 +104,7 @@ describe('Password reset recovery flows - with Passcodes', () => { isUserEmailValidated: true, }).then(({ emailAddress }) => { cy.visit( - `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}&usePasscodesResetPassword=true`, + `/reset-password?returnUrl=${encodedReturnUrl}&ref=${encodedRef}&refViewId=${refViewId}&clientId=${clientId}&appClientId=${appClientId}&fromURI=${fromURI}`, ); const timeRequestWasMade = new Date(); @@ -161,7 +161,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.createTestUser({ isUserEmailValidated: true, }).then(({ emailAddress }) => { - cy.visit(`/reset-password?usePasscodesResetPassword=true`); + cy.visit(`/reset-password`); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -209,7 +209,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.createTestUser({ isUserEmailValidated: true, }).then(({ emailAddress }) => { - cy.visit(`/reset-password?usePasscodesResetPassword=true`); + cy.visit(`/reset-password`); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -257,7 +257,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.createTestUser({ isUserEmailValidated: true, }).then(({ emailAddress }) => { - cy.visit(`/reset-password?usePasscodesResetPassword=true`); + cy.visit(`/reset-password`); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -317,7 +317,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.createTestUser({ isUserEmailValidated: true, }).then(({ emailAddress }) => { - cy.visit(`/reset-password?usePasscodesResetPassword=true`); + cy.visit(`/reset-password`); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -369,56 +369,15 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/register/email-sent'); // make sure we don't use a passcode - // we instead reset their password using the classic flow to set a password + // we instead reset their password using to set a password cy.visit('/reset-password'); - const timeRequestWasMade = new Date(); - - cy.get('button[type="submit"]').click(); - - cy.contains('Check your inbox'); - cy.contains(emailAddress); - cy.contains('send again'); - cy.contains('try another address'); - - cy.checkForEmailAndGetDetails( - emailAddress, - timeRequestWasMade, - /\/set-password\/([^"]*)/, - ).then(({ links, body }) => { - expect(body).to.have.string('Welcome back'); - - expect(body).to.have.string('Create password'); - expect(links.length).to.eq(2); - const setPasswordLink = links.find((s) => - s.text?.includes('Create password'), - ); - cy.visit(setPasswordLink?.href as string); - cy.contains('Create password'); - cy.contains(emailAddress); - - cy.get('input[name=password]').type(randomPassword()); - cy.get('[data-cy="main-form-submit-button"]') - .click() - .should('be.disabled'); - cy.contains('Password created'); - cy.contains(emailAddress.toLowerCase()); - - // once the password is set, we perform reset password for passcodes - cy.visit(`/reset-password?usePasscodesResetPassword=true`); - - const timeRequestWasMade = new Date(); - cy.get('[data-cy="main-form-submit-button"]').click(); - - cy.contains('Enter your one-time code'); - cy.contains(emailAddress); - cy.contains('send again'); - cy.contains('try another address'); + const timeRequestWasMade = new Date(); + cy.get('input[name=email]').clear().type(emailAddress); + cy.get('[data-cy="main-form-submit-button"]').click(); - cy.checkForEmailAndGetDetails( - emailAddress, - timeRequestWasMade, - ).then(({ body, codes }) => { + cy.checkForEmailAndGetDetails(emailAddress, timeRequestWasMade).then( + ({ body, codes }) => { // email expect(body).to.have.string('Your verification code'); expect(codes?.length).to.eq(1); @@ -438,8 +397,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.get('button[type="submit"]').click(); cy.url().should('contain', '/set-password/complete'); - }); - }); + }, + ); }, ); }); @@ -472,7 +431,7 @@ describe('Password reset recovery flows - with Passcodes', () => { expect(oktaUser.status).to.eq(Status.STAGED); // make sure we don't use a passcode // we instead reset their password using passcodes - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.contains('Reset password'); @@ -538,7 +497,7 @@ describe('Password reset recovery flows - with Passcodes', () => { expect(oktaUser.status).to.eq(Status.STAGED); // redirect to reset password with passcodes - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.contains('Reset password'); @@ -581,7 +540,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.createTestUser({ isGuestUser: true })?.then(({ emailAddress }) => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.STAGED); - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -625,7 +584,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.activateTestOktaUser(emailAddress).then(() => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.PROVISIONED); - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -671,7 +630,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.resetOktaUserPassword(emailAddress).then(() => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.RECOVERY); - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -717,7 +676,7 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.expireOktaUserPassword(emailAddress).then(() => { cy.getTestOktaUser(emailAddress).then((oktaUser) => { expect(oktaUser.status).to.eq(Status.PASSWORD_EXPIRED); - cy.visit('/reset-password?usePasscodesResetPassword=true'); + cy.visit('/reset-password'); const timeRequestWasMade = new Date(); cy.get('input[name=email]').type(emailAddress); @@ -760,7 +719,7 @@ describe('Password reset recovery flows - with Passcodes', () => { context('NON_EXISTENT user', () => { it('shows the passcode page with no account info, and using passcode returns error', () => { const emailAddress = randomMailosaurEmail(); - cy.visit(`/reset-password?usePasscodesResetPassword=true`); + cy.visit(`/reset-password`); cy.contains('Reset password'); cy.get('input[name=email]').type(emailAddress);