snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
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

This commit is contained in:
upstream-mirror
2026-09-15 21:19:12 +05:00
commit c60cc7ca75
8092 changed files with 394160 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
import { expect, Page } from "@playwright/test"
import { test } from "../../fixtures"
async function performOidcLogin(popup: Page, username: string) {
await popup.waitForLoadState()
await popup.locator("#username").fill(username)
await popup.getByRole("button", { name: "login" }).click()
await popup.locator("#offline").click()
await popup.locator("#openid").click()
await popup.locator("#website").fill("https://example.com")
await popup.getByRole("button", { name: "login" }).click()
}
async function rejectOidcLogin(popup: Page) {
await popup.waitForLoadState()
await popup.getByRole("button", { name: "reject" }).click()
await popup.close()
}
async function testRegistrationOrLogin(page: Page, username: string) {
const popupPromise = page.waitForEvent("popup")
await page.getByText(/sign (up|in) with ory/i).click()
const popup = await popupPromise
await performOidcLogin(popup, username)
await page.waitForURL("Home")
expect(popup.isClosed()).toBeTruthy()
await expect(page.getByText("Welcome back")).toBeVisible()
}
async function logout(page: Page) {
return page.getByTestId("logout").click()
}
async function testRegistration(page: Page, username: string) {
await page.goto("Registration")
return testRegistrationOrLogin(page, username)
}
async function testLogin(page: Page, username: string) {
await page.goto("Login")
return testRegistrationOrLogin(page, username)
}
test.describe("Registration", () => {
test("register twice", async ({ page }) => {
await testRegistration(page, "registration@example.com")
await logout(page)
await testRegistration(page, "registration@example.com")
})
test("register, then login", async ({ page }) => {
await testRegistration(page, "registration-login@example.com")
await logout(page)
await testLogin(page, "registration-login@example.com")
})
test("register, cancel, register", async ({ page }) => {
await page.goto("Registration")
let popupPromise = page.waitForEvent("popup")
await page.getByText(/sign (up|in) with ory/i).click()
let popup = await popupPromise
await rejectOidcLogin(popup)
await expect(page.getByText("login rejected request")).toBeVisible()
popupPromise = page.waitForEvent("popup")
await page.getByText(/continue/i).click()
popup = await popupPromise
await performOidcLogin(popup, "register-reject-then-accept@example.com")
await page.waitForURL("Home")
expect(popup.isClosed()).toBeTruthy()
await expect(page.getByText("Welcome back")).toBeVisible()
})
})
test.describe("Login", () => {
test("login twice", async ({ page }) => {
await testLogin(page, "login@example.com")
await logout(page)
await testLogin(page, "login@example.com")
})
test("login, then register", async ({ page }) => {
await testLogin(page, "login-registration@example.com")
await logout(page)
await testRegistration(page, "login-registration@example.com")
})
test("login, cancel, login", async ({ page }) => {
await page.goto("Login")
let popupPromise = page.waitForEvent("popup")
await page.getByText(/sign (up|in) with ory/i).click()
let popup = await popupPromise
await rejectOidcLogin(popup)
await expect(page.getByText("login rejected request")).toBeVisible()
popupPromise = page.waitForEvent("popup")
await page.getByText(/sign in with ory/i).click()
popup = await popupPromise
await performOidcLogin(popup, "login-reject-then-accept@example.com")
await page.waitForURL("Home")
expect(popup.isClosed()).toBeTruthy()
await expect(page.getByText("Welcome back")).toBeVisible()
})
})

View File

@@ -0,0 +1,140 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
import { expect } from "@playwright/test"
import { test } from "../../fixtures"
import { search } from "../../actions/mail"
import { extractCode } from "../../lib/helper"
const schemaConfig = {
default_schema_id: "email",
schemas: [
{
id: "email",
url: "file://test/e2e/profiles/email/identity.traits.schema.json",
},
],
}
test.describe("Recovery", () => {
test.use({
configOverride: {
identity: {
...schemaConfig,
},
feature_flags: {
use_continue_with_transitions: true,
},
},
})
test("succeeds with a valid email address", async ({ page, identity }) => {
await page.goto("/Recovery")
await page.getByTestId("email").fill(identity.email)
await page.getByTestId("submit-form").click()
await expect(page.getByTestId("ui/message/1060003")).toBeVisible()
const mails = await search({ query: identity.email, kind: "to" })
expect(mails).toHaveLength(1)
const code = extractCode(mails[0])
const wrongCode = "0" + code
await test.step("enter wrong code", async () => {
await page.getByTestId("code").fill(wrongCode)
await page.getByText("Continue").click()
await expect(page.getByTestId("ui/message/4060006")).toBeVisible()
})
await test.step("enter correct code", async () => {
await page.getByTestId("code").fill(code)
await page.getByText("Continue").click()
await page.waitForURL(/Settings/)
await expect(page.getByTestId("ui/message/1060001").first()).toBeVisible()
})
})
test("wrong email address does not get sent", async ({ page, identity }) => {
await page.goto("/Recovery")
const wrongEmailAddress = "wrong-" + identity.email
await page.getByTestId("email").fill(wrongEmailAddress)
await page.getByTestId("submit-form").click()
await expect(page.getByTestId("ui/message/1060003")).toBeVisible()
try {
await search({ query: identity.email, kind: "to" })
expect(false).toBeTruthy()
} catch (e) {
// this is expected
}
})
test("fails with an invalid code", async ({ page, identity }) => {
await page.goto("/Recovery")
await page.getByTestId("email").fill(identity.email)
await page.getByTestId("submit-form").click()
await page.getByTestId("ui/message/1060003").isVisible()
const mails = await search({ query: identity.email, kind: "to" })
expect(mails).toHaveLength(1)
const code = extractCode(mails[0])
const wrongCode = "0" + code
await test.step("enter wrong repeatedly", async () => {
for (let i = 0; i < 10; i++) {
await page.getByTestId("code").fill(wrongCode)
await page.getByText("Continue", { exact: true }).click()
await expect(page.getByTestId("ui/message/4060006")).toBeVisible()
}
})
await test.step("enter correct code fails", async () => {
await page.getByTestId("code").fill(code)
await page.getByText("Continue", { exact: true }).click()
await expect(page.getByTestId("ui/message/4060006")).toBeVisible()
})
})
test.describe("with short code expiration", () => {
test.use({
configOverride: {
identity: {
...schemaConfig,
},
selfservice: {
methods: {
code: {
config: {
lifespan: "1ms",
},
},
},
},
feature_flags: {
use_continue_with_transitions: true,
},
},
})
test("fails with an expired code", async ({ page, identity }) => {
await page.goto("/Recovery")
await page.getByTestId("email").fill(identity.email)
await page.getByTestId("submit-form").click()
await page.getByTestId("ui/message/1060003").isVisible()
const mails = await search({ query: identity.email, kind: "to" })
expect(mails).toHaveLength(1)
const code = extractCode(mails[0])
await page.getByTestId("code").fill(code)
await page.getByText("Continue", { exact: true }).click()
await expect(page.getByTestId("ui/message/4060006")).toBeVisible()
})
})
})