Skip to content

Commit f4c52c4

Browse files
Bill Leoutsakoscursoragent
authored andcommitted
fix(e2e): override auth endpoint rate limits
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 50b1605 commit f4c52c4

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

apps/sim/e2e/settings/smoke/authenticated.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,18 @@ test('billing-enabled signup, login, and settings use real Sim boundaries', asyn
4343

4444
await page.getByLabel('Email').fill(email)
4545
await page.getByRole('textbox', { name: 'Password' }).fill(password)
46-
await page.getByRole('button', { name: 'Sign in' }).click()
46+
const [signInResponse] = await Promise.all([
47+
page.waitForResponse((response) => {
48+
const url = new URL(response.url())
49+
return (
50+
response.request().method() === 'POST' &&
51+
url.origin === new URL(page.url()).origin &&
52+
url.pathname === '/api/auth/sign-in/email'
53+
)
54+
}),
55+
page.getByRole('button', { name: 'Sign in', exact: true }).click(),
56+
])
57+
expect(signInResponse.status(), signInResponse.statusText()).toBe(200)
4758
await expect(page).toHaveURL(/\/workspace(?:\/|$)/)
4859

4960
await page.context().storageState({ path: storageStatePath })

apps/sim/lib/auth/auth.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,19 @@ export const auth = betterAuth({
211211
disabledPaths: [...SSO_DISABLED_PATHS],
212212
// Full browser contracts intentionally exercise many isolated sessions from loopback.
213213
// Keep Better Auth's limiter enabled while raising only the hermetic profile's ceiling.
214-
...(usesGuardedE2eAuthRateLimit ? { rateLimit: { max: 10_000 } } : {}),
214+
// Better Auth's built-in sign-in/sign-up rules override the base maximum, so they
215+
// require explicit custom rules for the shared loopback IP used by Playwright.
216+
...(usesGuardedE2eAuthRateLimit
217+
? {
218+
rateLimit: {
219+
max: 10_000,
220+
customRules: {
221+
'/sign-in/*': { window: 10, max: 10_000 },
222+
'/sign-up/*': { window: 10, max: 10_000 },
223+
},
224+
},
225+
}
226+
: {}),
215227
trustedOrigins: [
216228
getBaseUrl(),
217229
...(env.NEXT_PUBLIC_SOCKET_URL ? [env.NEXT_PUBLIC_SOCKET_URL] : []),

0 commit comments

Comments
 (0)