Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
124 lines
4.0 KiB
TypeScript
124 lines
4.0 KiB
TypeScript
// Copyright © 2023 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { gen, MOBILE_URL, website } from "../../../../helpers"
|
|
|
|
context("Mobile Profile", () => {
|
|
describe("TOTP 2FA Flow", () => {
|
|
before(() => {
|
|
cy.useConfigProfile("mobile")
|
|
})
|
|
|
|
describe("password", () => {
|
|
let email = gen.email()
|
|
let password = gen.password()
|
|
|
|
before(() => {
|
|
cy.clearAllCookies()
|
|
})
|
|
|
|
beforeEach(() => {
|
|
email = gen.email()
|
|
password = gen.password()
|
|
|
|
cy.registerApi({
|
|
email,
|
|
password,
|
|
fields: { "traits.website": website },
|
|
})
|
|
|
|
cy.loginMobile({ email, password })
|
|
cy.visit(MOBILE_URL + "/Settings")
|
|
})
|
|
|
|
it("should be able to lifecycle through lookup_secret flows", () => {
|
|
cy.get('[data-testid="field/lookup_secret_codes"]').should("not.exist")
|
|
cy.get('[data-testid="field/lookup_secret_confirm/true"]').should(
|
|
"not.exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_reveal/true"]').should(
|
|
"not.exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_regenerate/true"]').click()
|
|
|
|
cy.get('[data-testid="field/lookup_secret_reveal/true"]').should(
|
|
"not.exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_codes"]').should("exist")
|
|
let codes
|
|
cy.get('[data-testid="field/lookup_secret_codes/text"]').then(($e) => {
|
|
codes = $e.text().trim().split(", ")
|
|
})
|
|
cy.get('[data-testid="field/lookup_secret_confirm/true"]').click()
|
|
cy.expectSettingsSaved()
|
|
|
|
cy.get('[data-testid="field/lookup_secret_confirm/true"]').should(
|
|
"not.exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_regenerate/true"]').should(
|
|
"not.exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_codes/true"]').should(
|
|
"not.exist",
|
|
)
|
|
|
|
cy.get('[data-testid="field/lookup_secret_reveal/true"]').click()
|
|
cy.get('[data-testid="field/lookup_secret_regenerate/true"]').should(
|
|
"exist",
|
|
)
|
|
cy.get('[data-testid="field/lookup_secret_codes/text"]').then(($e) => {
|
|
const actualCodes = $e.text().trim().split(", ")
|
|
expect(actualCodes.join(", ")).to.eq(codes.join(", "))
|
|
})
|
|
|
|
let newCodes
|
|
cy.get('[data-testid="field/lookup_secret_regenerate/true"]').click()
|
|
cy.get(
|
|
'[data-testid="field/lookup_secret_regenerate/true"]:disabled',
|
|
).should("not.exist")
|
|
|
|
cy.get('[data-testid="field/lookup_secret_codes/text"]')
|
|
.and(($e) => {
|
|
expect($e.text().trim().split(", ").join(", ")).to.not.eq(
|
|
codes.join(", "),
|
|
)
|
|
})
|
|
.then(($e) => {
|
|
newCodes = $e.text().trim().split(", ")
|
|
})
|
|
|
|
cy.get('[data-testid="field/lookup_secret_confirm/true"]').click()
|
|
cy.expectSettingsSaved()
|
|
|
|
cy.get('[data-testid="field/lookup_secret_reveal/true"]').click()
|
|
cy.get('[data-testid="field/lookup_secret_codes/text"]').and(($e) => {
|
|
const actualCodes = $e.text().trim().split(", ")
|
|
expect(actualCodes.join(", ")).to.eq(newCodes.join(", "))
|
|
})
|
|
|
|
cy.visit(MOBILE_URL + "/Login?aal=aal2&refresh=true")
|
|
|
|
// First use a wrong code
|
|
cy.get("[data-testid=lookup_secret]").then(($e) => {
|
|
console.log(codes)
|
|
cy.wrap($e).type("1234")
|
|
})
|
|
cy.get('[data-testid="field/method/lookup_secret"]').click()
|
|
cy.get('[data-testid="form-messages"]').should(
|
|
"contain.text",
|
|
"The backup recovery code is not valid.",
|
|
)
|
|
cy.get("[data-testid=lookup_secret]").then(($e) => {
|
|
cy.wrap($e).type(newCodes[0])
|
|
})
|
|
cy.get('[data-testid="field/method/lookup_secret"]').click()
|
|
cy.get('[data-testid="session-content"]').should("contain", "aal2")
|
|
cy.get('[data-testid="session-content"]').should(
|
|
"contain",
|
|
"lookup_secret",
|
|
)
|
|
})
|
|
})
|
|
})
|
|
})
|