Skip to content

Commit 6ef3b96

Browse files
committed
fix tests
1 parent 8b6796e commit 6ef3b96

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

apps/sim/app/api/auth/oauth/token/route.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('OAuth Token API Routes', () => {
1212
const mockRefreshTokenIfNeeded = vi.fn()
1313
const mockGetOAuthToken = vi.fn()
1414
const mockAuthorizeCredentialUse = vi.fn()
15-
const mockCheckHybridAuth = vi.fn()
15+
const mockCheckSessionOrInternalAuth = vi.fn()
1616

1717
const mockLogger = createMockLogger()
1818

@@ -42,7 +42,7 @@ describe('OAuth Token API Routes', () => {
4242
}))
4343

4444
vi.doMock('@/lib/auth/hybrid', () => ({
45-
checkHybridAuth: mockCheckHybridAuth,
45+
checkSessionOrInternalAuth: mockCheckSessionOrInternalAuth,
4646
}))
4747
})
4848

@@ -235,7 +235,7 @@ describe('OAuth Token API Routes', () => {
235235

236236
describe('credentialAccountUserId + providerId path', () => {
237237
it('should reject unauthenticated requests', async () => {
238-
mockCheckHybridAuth.mockResolvedValueOnce({
238+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
239239
success: false,
240240
error: 'Authentication required',
241241
})
@@ -256,7 +256,7 @@ describe('OAuth Token API Routes', () => {
256256
})
257257

258258
it('should reject API key authentication', async () => {
259-
mockCheckHybridAuth.mockResolvedValueOnce({
259+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
260260
success: true,
261261
authType: 'api_key',
262262
userId: 'test-user-id',
@@ -278,7 +278,7 @@ describe('OAuth Token API Routes', () => {
278278
})
279279

280280
it('should reject internal JWT authentication', async () => {
281-
mockCheckHybridAuth.mockResolvedValueOnce({
281+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
282282
success: true,
283283
authType: 'internal_jwt',
284284
userId: 'test-user-id',
@@ -300,7 +300,7 @@ describe('OAuth Token API Routes', () => {
300300
})
301301

302302
it('should reject requests for other users credentials', async () => {
303-
mockCheckHybridAuth.mockResolvedValueOnce({
303+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
304304
success: true,
305305
authType: 'session',
306306
userId: 'attacker-user-id',
@@ -322,7 +322,7 @@ describe('OAuth Token API Routes', () => {
322322
})
323323

324324
it('should allow session-authenticated users to access their own credentials', async () => {
325-
mockCheckHybridAuth.mockResolvedValueOnce({
325+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
326326
success: true,
327327
authType: 'session',
328328
userId: 'test-user-id',
@@ -345,7 +345,7 @@ describe('OAuth Token API Routes', () => {
345345
})
346346

347347
it('should return 404 when credential not found for user', async () => {
348-
mockCheckHybridAuth.mockResolvedValueOnce({
348+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
349349
success: true,
350350
authType: 'session',
351351
userId: 'test-user-id',
@@ -373,7 +373,7 @@ describe('OAuth Token API Routes', () => {
373373
*/
374374
describe('GET handler', () => {
375375
it('should return access token successfully', async () => {
376-
mockCheckHybridAuth.mockResolvedValueOnce({
376+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
377377
success: true,
378378
authType: 'session',
379379
userId: 'test-user-id',
@@ -402,7 +402,7 @@ describe('OAuth Token API Routes', () => {
402402
expect(response.status).toBe(200)
403403
expect(data).toHaveProperty('accessToken', 'fresh-token')
404404

405-
expect(mockCheckHybridAuth).toHaveBeenCalled()
405+
expect(mockCheckSessionOrInternalAuth).toHaveBeenCalled()
406406
expect(mockGetCredential).toHaveBeenCalledWith(mockRequestId, 'credential-id', 'test-user-id')
407407
expect(mockRefreshTokenIfNeeded).toHaveBeenCalled()
408408
})
@@ -421,7 +421,7 @@ describe('OAuth Token API Routes', () => {
421421
})
422422

423423
it('should handle authentication failure', async () => {
424-
mockCheckHybridAuth.mockResolvedValueOnce({
424+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
425425
success: false,
426426
error: 'Authentication required',
427427
})
@@ -440,7 +440,7 @@ describe('OAuth Token API Routes', () => {
440440
})
441441

442442
it('should handle credential not found', async () => {
443-
mockCheckHybridAuth.mockResolvedValueOnce({
443+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
444444
success: true,
445445
authType: 'session',
446446
userId: 'test-user-id',
@@ -461,7 +461,7 @@ describe('OAuth Token API Routes', () => {
461461
})
462462

463463
it('should handle missing access token', async () => {
464-
mockCheckHybridAuth.mockResolvedValueOnce({
464+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
465465
success: true,
466466
authType: 'session',
467467
userId: 'test-user-id',
@@ -487,7 +487,7 @@ describe('OAuth Token API Routes', () => {
487487
})
488488

489489
it('should handle token refresh failure', async () => {
490-
mockCheckHybridAuth.mockResolvedValueOnce({
490+
mockCheckSessionOrInternalAuth.mockResolvedValueOnce({
491491
success: true,
492492
authType: 'session',
493493
userId: 'test-user-id',

apps/sim/app/api/files/delete/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function setupFileApiMocks(
2929
}
3030

3131
vi.doMock('@/lib/auth/hybrid', () => ({
32-
checkHybridAuth: vi.fn().mockResolvedValue({
32+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
3333
success: authenticated,
3434
userId: authenticated ? 'test-user-id' : undefined,
3535
error: authenticated ? undefined : 'Unauthorized',

apps/sim/app/api/files/parse/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function setupFileApiMocks(
3535
}
3636

3737
vi.doMock('@/lib/auth/hybrid', () => ({
38-
checkHybridAuth: vi.fn().mockResolvedValue({
38+
checkInternalAuth: vi.fn().mockResolvedValue({
3939
success: authenticated,
4040
userId: authenticated ? 'test-user-id' : undefined,
4141
error: authenticated ? undefined : 'Unauthorized',

apps/sim/app/api/files/serve/[...path]/route.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('File Serve API Route', () => {
5555
})
5656

5757
vi.doMock('@/lib/auth/hybrid', () => ({
58-
checkHybridAuth: vi.fn().mockResolvedValue({
58+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
5959
success: true,
6060
userId: 'test-user-id',
6161
}),
@@ -165,7 +165,7 @@ describe('File Serve API Route', () => {
165165
}))
166166

167167
vi.doMock('@/lib/auth/hybrid', () => ({
168-
checkHybridAuth: vi.fn().mockResolvedValue({
168+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
169169
success: true,
170170
userId: 'test-user-id',
171171
}),
@@ -226,7 +226,7 @@ describe('File Serve API Route', () => {
226226
}))
227227

228228
vi.doMock('@/lib/auth/hybrid', () => ({
229-
checkHybridAuth: vi.fn().mockResolvedValue({
229+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
230230
success: true,
231231
userId: 'test-user-id',
232232
}),
@@ -291,7 +291,7 @@ describe('File Serve API Route', () => {
291291
}))
292292

293293
vi.doMock('@/lib/auth/hybrid', () => ({
294-
checkHybridAuth: vi.fn().mockResolvedValue({
294+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
295295
success: true,
296296
userId: 'test-user-id',
297297
}),
@@ -350,7 +350,7 @@ describe('File Serve API Route', () => {
350350
for (const test of contentTypeTests) {
351351
it(`should serve ${test.ext} file with correct content type`, async () => {
352352
vi.doMock('@/lib/auth/hybrid', () => ({
353-
checkHybridAuth: vi.fn().mockResolvedValue({
353+
checkSessionOrInternalAuth: vi.fn().mockResolvedValue({
354354
success: true,
355355
userId: 'test-user-id',
356356
}),

0 commit comments

Comments
 (0)