mirror of
https://github.com/better-auth/better-auth.git
synced 2026-07-26 22:42:35 -05:00
test: adapt merged mcp and two-factor tests to next's breaking APIs
The merge auto-combined these test files without textual conflict, but they referenced APIs next changed, so type checking failed: - mcp.test.ts drove one (skipped) confidential-client test through the removed generic-oauth client (genericOAuthClient + signIn.oauth2). It now uses signIn.social like the surrounding tests. - two-factor.security.test.ts read enrollment.totpURI directly; next's #9057 made the enable response a discriminated { method } union, so the tests now narrow on method === "totp" before reading totpURI. tsc --build is clean across the workspace. (cherry picked from commit d3cd3c2eb39f0c7209f45ff27ac4b943250b93be)
This commit is contained in:
@@ -369,18 +369,17 @@ describe("mcp", async () => {
|
||||
});
|
||||
const oAuthHeaders = new Headers();
|
||||
const client = createAuthClient({
|
||||
plugins: [genericOAuthClient()],
|
||||
baseURL: "http://localhost:5004",
|
||||
fetchOptions: { customFetchImpl: customFetchImplRP },
|
||||
});
|
||||
|
||||
const data = await client.signIn.oauth2(
|
||||
{ providerId: "test-confidential", callbackURL: "/dashboard" },
|
||||
const data = await client.signIn.social(
|
||||
{ provider: "test-confidential", callbackURL: "/dashboard" },
|
||||
{ throw: true, onSuccess: cookieSetter(oAuthHeaders) },
|
||||
);
|
||||
|
||||
let redirectURI = "";
|
||||
await serverClient.$fetch(data.url, {
|
||||
await serverClient.$fetch(data.url!, {
|
||||
method: "GET",
|
||||
onError(context: any) {
|
||||
redirectURI = context.response.headers.get("Location") || "";
|
||||
|
||||
@@ -113,7 +113,7 @@ describe("two-factor security: sign-in does not leak session cookies (cookieCach
|
||||
body: { password: testUser.password },
|
||||
headers,
|
||||
});
|
||||
if (!enrollment.totpURI) {
|
||||
if (enrollment.method !== "totp") {
|
||||
throw new Error("expected totp enrollment");
|
||||
}
|
||||
const row = await db.findOne<TwoFactorTable>({
|
||||
@@ -225,7 +225,7 @@ describe("two-factor security: sign-in does not leak session cookies (cookieCach
|
||||
body: { password: testUser.password },
|
||||
headers,
|
||||
});
|
||||
if (!enrollment.totpURI) {
|
||||
if (enrollment.method !== "totp") {
|
||||
throw new Error("expected totp enrollment");
|
||||
}
|
||||
const dbUser = await db.findOne<User>({
|
||||
@@ -327,7 +327,7 @@ describe("two-factor security: chunked session_data is fully scrubbed on 2FA-req
|
||||
body: { password: testUser.password },
|
||||
headers,
|
||||
});
|
||||
if (!enrollment.totpURI) {
|
||||
if (enrollment.method !== "totp") {
|
||||
throw new Error("expected totp enrollment");
|
||||
}
|
||||
const row = await db.findOne<TwoFactorTable>({
|
||||
|
||||
Reference in New Issue
Block a user