Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions __tests__/api/stellar/activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("GET /api/stellar/activity", () => {
response: NextResponse.json({ message: "Unauthorized" }, { status: 401 }),
})

const response = await GET(buildRequest())
const response = (await GET(buildRequest()))!
expect(response.status).toBe(401)
})

Expand All @@ -75,7 +75,7 @@ describe("GET /api/stellar/activity", () => {
issuerPublicKey: "GD123",
})

const response = await GET(buildRequest())
const response = (await GET(buildRequest()))!
const payload = await response.json()

expect(response.status).toBe(200)
Expand All @@ -93,7 +93,7 @@ describe("GET /api/stellar/activity", () => {
network: "testnet",
})

const response = await GET(buildRequest())
const response = (await GET(buildRequest()))!
const payload = await response.json()

expect(response.status).toBe(200)
Expand Down Expand Up @@ -136,7 +136,7 @@ describe("GET /api/stellar/activity", () => {
}),
})

const response = await GET(buildRequest())
const response = (await GET(buildRequest()))!
const payload = await response.json()

expect(response.status).toBe(200)
Expand Down
4 changes: 2 additions & 2 deletions __tests__/api/stellar/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("POST /api/admin/stellar/sync", () => {
response: NextResponse.json({ message: "Unauthorized" }, { status: 401 }),
})

const response = await POST(buildRequest())
const response = (await POST(buildRequest()))!
expect(response.status).toBe(401)
expect(sync).not.toHaveBeenCalled()
})
Expand All @@ -60,7 +60,7 @@ describe("POST /api/admin/stellar/sync", () => {
lastCursor: "cursor-123",
})

const response = await POST(buildRequest())
const response = (await POST(buildRequest()))!
const payload = await response.json()

expect(response.status).toBe(200)
Expand Down
10 changes: 5 additions & 5 deletions __tests__/auth-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe("requireRecentAuth", () => {

// ── Session revocation ────────────────────────────────────────────────────────

vi.mock("../models/RevokedSession", () => ({ default: { create: vi.fn().mockResolvedValue({}), findOne: vi.fn() } }), { virtual: true })
vi.mock("../models/RevokedSession", () => ({ default: { create: vi.fn().mockResolvedValue({}), findOne: vi.fn() } }))

// Mongoose mock so the schema registration doesn't fail in unit test context.
vi.mock("mongoose", async () => {
Expand Down Expand Up @@ -276,7 +276,7 @@ describe("POST /api/auth/stellar/link — recent-auth enforcement", () => {
getAuthenticatedUser.mockResolvedValue({ user: makeUser(), shouldRefreshSession: false })
mockExtractPrivyToken.mockReturnValue(null)

const response = await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY }))
const response = (await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY })))!
expect(response.status).toBe(401)
const body = await response.json()
expect(body.code).toBe("RECENT_AUTH_REQUIRED")
Expand All @@ -287,7 +287,7 @@ describe("POST /api/auth/stellar/link — recent-auth enforcement", () => {
mockExtractPrivyToken.mockReturnValue("bad-token")
mockVerifyPrivyToken.mockRejectedValue(new Error("JWTExpired"))

const response = await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY }))
const response = (await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY })))!
expect(response.status).toBe(401)
})

Expand All @@ -300,7 +300,7 @@ describe("POST /api/auth/stellar/link — recent-auth enforcement", () => {
iat: Math.floor(Date.now() / 1_000) - 30,
})

const response = await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY }))
const response = (await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY })))!
expect(response.status).toBe(401)
expect(mockLogAuthEvent).toHaveBeenCalledWith(expect.objectContaining({ type: "privy_subject_mismatch" }))
})
Expand All @@ -314,7 +314,7 @@ describe("POST /api/auth/stellar/link — recent-auth enforcement", () => {
iat: Math.floor(Date.now() / 1_000) - (RECENT_AUTH_CRITICAL_MAX_AGE_SECONDS + 30),
})

const response = await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY }))
const response = (await POST(buildRequest({ stellarPublicKey: VALID_STELLAR_KEY })))!
expect(response.status).toBe(401)
expect(mockLogAuthEvent).toHaveBeenCalledWith(
expect.objectContaining({ type: "high_risk_action_denied_recent_auth" }),
Expand Down
Loading
Loading