Skip to content

Commit

Permalink
test(ete): update tests to make passcodes default and change tests fo…
Browse files Browse the repository at this point in the history
…r `useOktaClassic`
  • Loading branch information
coldlink committed Sep 30, 2024
1 parent 3bc2577 commit 5eb3d76
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 123 deletions.
24 changes: 13 additions & 11 deletions cypress/integration/ete/reset_password_1.3.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
});
});
});
98 changes: 48 additions & 50 deletions cypress/integration/ete/reset_password_2.5.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
},
);
Expand Down Expand Up @@ -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');
});
});
},
Expand Down
Loading

0 comments on commit 5eb3d76

Please sign in to comment.