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
147 lines
3.8 KiB
TypeScript
147 lines
3.8 KiB
TypeScript
// Copyright © 2023 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { appPrefix, gen, website } from "../../../../helpers"
|
|
import { routes as express } from "../../../../helpers/express"
|
|
import { routes as react } from "../../../../helpers/react"
|
|
|
|
context("Testing logout flows", () => {
|
|
;[
|
|
{
|
|
route: express.login,
|
|
app: "express" as "express",
|
|
profile: "email",
|
|
settings: express.settings,
|
|
welcome: express.welcome,
|
|
},
|
|
{
|
|
route: react.login,
|
|
app: "react" as "react",
|
|
profile: "spa",
|
|
settings: react.settings,
|
|
welcome: "",
|
|
},
|
|
].forEach(({ route, profile, app, settings, welcome }) => {
|
|
describe(`for app ${app}`, () => {
|
|
let email: string
|
|
let password: string
|
|
|
|
before(() => {
|
|
cy.proxy(app)
|
|
|
|
email = gen.email()
|
|
password = gen.password()
|
|
|
|
cy.useConfigProfile(profile)
|
|
cy.registerApi({
|
|
email,
|
|
password,
|
|
fields: { "traits.website": website },
|
|
})
|
|
})
|
|
|
|
beforeEach(() => {
|
|
cy.clearAllCookies()
|
|
cy.login({ email, password, cookieUrl: route })
|
|
cy.visit(route)
|
|
})
|
|
|
|
// playwright:migrated
|
|
it("should sign out and be able to sign in again", () => {
|
|
cy.getSession()
|
|
cy.getCookie("ory_kratos_session").should("not.be.null")
|
|
if (app === "express") {
|
|
cy.get(
|
|
`${appPrefix(app)} [data-testid="logout"] a:not(.disabled)`,
|
|
).click()
|
|
} else {
|
|
cy.get(
|
|
`${appPrefix(app)} [data-testid="logout"]:not(.disabled)`,
|
|
).click()
|
|
}
|
|
cy.getCookie("ory_kratos_session").should("be.null")
|
|
cy.noSession()
|
|
cy.url().should("include", "/login")
|
|
})
|
|
|
|
// playwright:migrated
|
|
it("should be able to sign out on settings page", () => {
|
|
if (app === "react") {
|
|
return
|
|
}
|
|
cy.sessionRequiresNo2fa()
|
|
cy.useLaxAal()
|
|
|
|
cy.getSession({ expectAal: "aal1" })
|
|
cy.getCookie("ory_kratos_session").should("not.be.null")
|
|
|
|
cy.visit(settings, {
|
|
qs: {
|
|
return_to: "https://www.example.org",
|
|
},
|
|
})
|
|
|
|
cy.get("a[href*='logout']").click()
|
|
cy.location("host").should("eq", "www.example.org")
|
|
})
|
|
|
|
// playwright:migrated
|
|
it("should be able to sign out on welcome page", () => {
|
|
if (app === "react") {
|
|
return
|
|
}
|
|
cy.sessionRequiresNo2fa()
|
|
cy.useLaxAal()
|
|
|
|
cy.getSession({ expectAal: "aal1" })
|
|
|
|
cy.visit(welcome, {
|
|
qs: {
|
|
return_to: "https://www.example.org",
|
|
},
|
|
})
|
|
|
|
cy.get("a[href*='logout']").click()
|
|
cy.location("host").should("eq", "www.example.org")
|
|
})
|
|
|
|
it("should be able to sign out at 2fa page", () => {
|
|
if (app === "react") {
|
|
return
|
|
}
|
|
cy.useLookupSecrets(true)
|
|
cy.sessionRequires2fa()
|
|
cy.getSession({ expectAal: "aal1" })
|
|
cy.getCookie("ory_kratos_session").should("not.be.null")
|
|
|
|
// add 2fa to account
|
|
cy.visit(settings)
|
|
cy.get(
|
|
appPrefix(app) + 'button[name="lookup_secret_regenerate"]',
|
|
).click()
|
|
cy.get('button[name="lookup_secret_confirm"]').click()
|
|
cy.expectSettingsSaved()
|
|
|
|
cy.logout()
|
|
cy.visit(route, {
|
|
qs: {
|
|
return_to: "https://www.example.org",
|
|
},
|
|
})
|
|
|
|
cy.get('[name="identifier"]').clear().type(email)
|
|
|
|
cy.reauth({
|
|
expect: { email, success: false },
|
|
type: { password: password },
|
|
})
|
|
|
|
cy.get("a[href*='logout']").click()
|
|
|
|
cy.location("host").should("eq", "www.example.org")
|
|
cy.useLookupSecrets(false)
|
|
})
|
|
})
|
|
})
|
|
})
|