Skip to content

Commit 41ec005

Browse files
authored
fix(auth): clean up the anonymous audit row from the malformed sign-in integration test (#10479)
The rejected sign-in is audited with no resourceId, so the user-scoped afterEach cleanup missed it. The test now sends a unique user-agent, waits for its audit row, and deletes it in finally, matching the legacy-collision test in the same file.
1 parent 384c0e0 commit 41ec005

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎apps/sim/lib/auth/lifecycle-audit.integration.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,21 @@ describe('authentication audit history in PostgreSQL', () => {
199199
})
200200

201201
it('answers a non-string email with a validation error instead of crashing the sign-in hook', async () => {
202-
const response = await auth.handler(
203-
request('/sign-in/email', { email: { $ne: null }, password: fixturePassword })
204-
)
205-
expect(response.status).toBe(400)
202+
const agent = `Malformed sign-in fixture ${generateId()}`
203+
const attempt = request('/sign-in/email', { email: { $ne: null }, password: fixturePassword })
204+
attempt.headers.set('user-agent', agent)
205+
try {
206+
const response = await auth.handler(attempt)
207+
expect(response.status).toBe(400)
208+
// The rejection is audited anonymously (no resourceId), which the user-scoped cleanup misses.
209+
await expect
210+
.poll(
211+
async () => (await db.select().from(auditLog).where(eq(auditLog.userAgent, agent))).length
212+
)
213+
.toBe(1)
214+
} finally {
215+
await db.delete(auditLog).where(eq(auditLog.userAgent, agent))
216+
}
206217
})
207218

208219
it('records suspended-account denial without claiming a successful login', async () => {

0 commit comments

Comments
 (0)