Skip to content

Commit

Permalink
test(e2e): resolve regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 22, 2021
1 parent 0a8b40b commit aaff34e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
32 changes: 16 additions & 16 deletions test/e2e/cypress/integration/profiles/mfa/lookup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {appPrefix, gen, website} from '../../../helpers'
import {routes as express} from '../../../helpers/express'
import {routes as react} from '../../../helpers/react'
import { appPrefix, gen, website } from '../../../helpers'
import { routes as express } from '../../../helpers/express'
import { routes as react } from '../../../helpers/react'

context('2FA lookup secrets', () => {
;[
Expand All @@ -18,7 +18,7 @@ context('2FA lookup secrets', () => {
app: 'express' as 'express',
profile: 'mfa'
}
].forEach(({settings, login, profile, app, base}) => {
].forEach(({ settings, login, profile, app, base }) => {
describe(`for app ${app}`, () => {
before(() => {
cy.useConfigProfile(profile)
Expand All @@ -36,9 +36,9 @@ context('2FA lookup secrets', () => {
cy.registerApi({
email,
password,
fields: {'traits.website': website}
fields: { 'traits.website': website }
})
cy.login({email, password, cookieUrl: base})
cy.login({ email, password, cookieUrl: base })

cy.longPrivilegedSessionTime()
cy.sessionRequiresNo2fa()
Expand All @@ -58,13 +58,13 @@ context('2FA lookup secrets', () => {
cy.shortPrivilegedSessionTime()
cy.get('button[name="lookup_secret_disable"]').click()
cy.reauth({
expect: {email},
type: {email: email, password: password}
expect: { email },
type: { email: email, password: password }
})
cy.expectSettingsSaved()

cy.clearAllCookies()
cy.login({email: email, password: password, cookieUrl: base})
cy.login({ email: email, password: password, cookieUrl: base })

cy.visit(login + '?aal=aal2')
cy.get('h2').should('contain.text', 'Two-Factor Authentication')
Expand Down Expand Up @@ -242,8 +242,8 @@ context('2FA lookup secrets', () => {
cy.visit(settings)
cy.get('button[name="lookup_secret_regenerate"]').click()
cy.reauth({
expect: {email},
type: {email: email, password: password}
expect: { email },
type: { email: email, password: password }
})

let codes
Expand All @@ -254,22 +254,22 @@ context('2FA lookup secrets', () => {
cy.shortPrivilegedSessionTime()
cy.get('button[name="lookup_secret_confirm"]').click()
cy.reauth({
expect: {email},
type: {email: email, password: password}
expect: { email },
type: { email: email, password: password }
})
cy.expectSettingsSaved()

cy.shortPrivilegedSessionTime()
cy.get('button[name="lookup_secret_reveal"]').click()
cy.reauth({
expect: {email},
type: {email: email, password: password}
expect: { email },
type: { email: email, password: password }
})
cy.getLookupSecrets().should((c) => {
expect(c).to.not.be.empty
})
cy.getSession({
expectAal: 'aal2',
expectAal: 'aal2'
})
})

Expand Down
6 changes: 4 additions & 2 deletions test/e2e/cypress/integration/profiles/mfa/totp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ context('2FA lookup secrets', () => {
// If we visit settings page we still end up at 2fa screen
cy.visit(settings)
cy.location().should((loc) => {
expect(loc.href).to.include('/login')
expect(loc.pathname).to.include('/login')
})

cy.shouldShow2FAScreen()
cy.get('input[name="totp_code"]').then(($e) => {
cy.wrap($e).type(authenticator.generate(secret))
})
cy.get('*[name="method"][value="totp"]').click()
cy.expectSettingsSaved()
cy.location().should((loc) => {
expect(loc.pathname).to.oneOf(['/welcome', '/'])
})
cy.getSession({
expectAal: 'aal2',
expectMethods: ['password', 'totp']
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ declare global {
*/
getSession(opts?: {
expectAal?: 'aal2' | 'aal1'
expectMethods?: Array<'password' | 'webauthn' | 'lookup_secret' | 'totp'>
expectMethods?: Array<
'password' | 'webauthn' | 'lookup_secret' | 'totp'
>
}): Chainable<Session>

/**
Expand Down

0 comments on commit aaff34e

Please sign in to comment.