Skip to content

Commit 28628b2

Browse files
fix CI regressions after staging merge
1 parent 7f383d0 commit 28628b2

26 files changed

Lines changed: 304 additions & 298 deletions

File tree

apps/sim/app/api/chat/manage/[id]/route.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ import {
2323
import { NextRequest } from 'next/server'
2424
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
2525

26-
const { mockCheckChatAccess, mockValidateChatDeployAuth } = vi.hoisted(() => ({
27-
mockCheckChatAccess: vi.fn(),
28-
mockValidateChatDeployAuth: vi.fn(),
29-
}))
26+
const { mockCheckChatAccess, mockCheckNeedsRedeployment, mockValidateChatDeployAuth } = vi.hoisted(
27+
() => ({
28+
mockCheckChatAccess: vi.fn(),
29+
mockCheckNeedsRedeployment: vi.fn(),
30+
mockValidateChatDeployAuth: vi.fn(),
31+
})
32+
)
3033

3134
const mockCreateSuccessResponse = workflowsApiUtilsMockFns.mockCreateSuccessResponse
3235
const mockCreateErrorResponse = workflowsApiUtilsMockFns.mockCreateErrorResponse
33-
const mockCheckNeedsRedeployment = workflowsApiUtilsMockFns.mockCheckNeedsRedeployment
3436
const mockEncryptSecret = encryptionMockFns.mockEncryptSecret
3537
const mockPerformFullDeploy = workflowsOrchestrationMockFns.mockPerformFullDeploy
3638
const mockPerformChatUndeploy = workflowsOrchestrationMockFns.mockPerformChatUndeploy
@@ -56,6 +58,9 @@ vi.mock('@/ee/access-control/utils/permission-check', () => {
5658
})
5759
vi.mock('@/lib/workflows/persistence/utils', () => workflowsPersistenceUtilsMock)
5860
vi.mock('@/lib/workflows/orchestration', () => workflowsOrchestrationMock)
61+
vi.mock('@/lib/workflows/deployment-status', () => ({
62+
checkNeedsRedeployment: mockCheckNeedsRedeployment,
63+
}))
5964

6065
import { DELETE, GET, PATCH } from '@/app/api/chat/manage/[id]/route'
6166
import { ChatDeployAuthNotAllowedError } from '@/ee/access-control/utils/permission-check'

apps/sim/app/api/tools/file/manage/route.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ vi.mock('@/lib/realtime/notify', () => ({
5454
notifyWorkspaceFilesChanged: vi.fn(async () => undefined),
5555
}))
5656

57+
vi.mock('@/lib/public-shares/share-manager', () => ({
58+
getShareForResource: vi.fn().mockResolvedValue(null),
59+
getSharesForResources: vi.fn().mockResolvedValue(new Map()),
60+
ShareValidationError: class ShareValidationError extends Error {},
61+
}))
62+
5763
vi.mock('@sim/platform-authz/workspace', () => ({
5864
permissionSatisfies: (permission: string | null, required: string) =>
5965
permission === 'admin' ||
@@ -439,7 +445,9 @@ describe('POST /api/tools/file/manage content provenance', () => {
439445
'new.txt',
440446
'text/plain',
441447
{
448+
exactName: false,
442449
folderId: null,
450+
folderPath: undefined,
443451
secretProvenance: { status: 'unknown' },
444452
}
445453
)
@@ -619,7 +627,9 @@ describe('POST /api/tools/file/manage content provenance', () => {
619627
'child.txt',
620628
'text/plain',
621629
{
630+
exactName: true,
622631
folderId: null,
632+
folderPath: undefined,
623633
secretProvenance: { status: 'unknown' },
624634
}
625635
)

apps/sim/app/api/v1/knowledge/[id]/documents/route.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,17 @@ describe('v1 knowledge document upload route', () => {
228228
expect(mockResolveBillingAttribution).not.toHaveBeenCalled()
229229
expect(mockCheckAttributedUsageLimits).toHaveBeenCalledWith(SYSTEM_BILLING_ATTRIBUTION)
230230
expect(mockCreateSingleDocument).toHaveBeenCalledWith(
231-
expect.any(Object),
231+
{
232+
filename: 'file.txt',
233+
fileUrl: 'https://example.com/file.txt',
234+
fileSize: 11,
235+
mimeType: 'text/plain',
236+
},
232237
'kb-1',
233238
'req-1',
234-
'owner-after-transfer'
239+
'owner-after-transfer',
240+
undefined,
241+
undefined
235242
)
236243
expect(mockProcessDocumentsWithQueue).toHaveBeenCalledWith(
237244
expect.any(Array),

apps/sim/app/api/v2/files/[fileId]/share/route.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ describe('GET /api/v2/files/[fileId]/share', () => {
157157
expect(mocks.getShare).not.toHaveBeenCalled()
158158
})
159159

160-
it('conceals authorization failures as not found', async () => {
160+
it('preserves generic authorization failures as forbidden', async () => {
161161
mocks.getShare.mockRejectedValueOnce(new OrchestrationError('forbidden', 'Access denied'))
162162

163163
const response = await callGet()
164164
const body = await response.json()
165165

166-
expect(response.status).toBe(404)
167-
expect(body.error.code).toBe('NOT_FOUND')
166+
expect(response.status).toBe(403)
167+
expect(body.error.code).toBe('FORBIDDEN')
168168
expect(mocks.getShare).toHaveBeenCalledWith({
169169
principal: PRINCIPAL,
170170
input: { fileId: FILE_ID, assertedWorkspaceId: WORKSPACE_ID },
@@ -251,13 +251,13 @@ describe('PUT /api/v2/files/[fileId]/share', () => {
251251
})
252252
})
253253

254-
it('conceals forbidden updates as not found', async () => {
254+
it('preserves generic forbidden updates as forbidden', async () => {
255255
mocks.updateShare.mockRejectedValueOnce(new OrchestrationError('forbidden', 'Access denied'))
256256

257257
const response = await callPut({ workspaceId: WORKSPACE_ID, isActive: true })
258258

259-
expect(response.status).toBe(404)
260-
expect((await response.json()).error.code).toBe('NOT_FOUND')
259+
expect(response.status).toBe(403)
260+
expect((await response.json()).error.code).toBe('FORBIDDEN')
261261
})
262262

263263
it('returns the rate-limit response when denied', async () => {

apps/sim/app/api/v2/tables/[tableId]/groups/route.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ describe('/api/v2/tables/[tableId]/groups', () => {
143143
})
144144
})
145145

146-
it('conceals denied table access on group mutations', async () => {
146+
it('preserves generic denied table access on group mutations as forbidden', async () => {
147147
mocks.update.mockRejectedValueOnce(new OrchestrationError('forbidden', 'Forbidden'))
148148

149149
const response = await PATCH(
150150
writeRequest('PATCH', { workspaceId: WORKSPACE_ID, groupId: 'group-1', name: 'Renamed' }),
151151
context
152152
)
153153

154-
expect(response.status).toBe(404)
155-
expect((await response.json()).error.message).toBe('Table not found')
154+
expect(response.status).toBe(403)
155+
expect((await response.json()).error.message).toBe('Forbidden')
156156
})
157157

158158
it('returns authoritative surviving columns after deletion', async () => {

apps/sim/app/api/v2/tables/[tableId]/rows/[rowId]/route.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ describe('/api/v2/tables/[tableId]/rows/[rowId]', () => {
153153
)
154154
})
155155

156-
it('conceals a forbidden canonical lookup as not found', async () => {
156+
it('preserves a generic forbidden canonical lookup as forbidden', async () => {
157157
mocks.readRow.mockRejectedValue(new OrchestrationError('forbidden', 'Forbidden'))
158158

159159
const response = await GET(request('GET'), CONTEXT)
160160

161-
expect(response.status).toBe(404)
162-
expect((await response.json()).error.code).toBe('NOT_FOUND')
161+
expect(response.status).toBe(403)
162+
expect((await response.json()).error.code).toBe('FORBIDDEN')
163163
})
164164
})

apps/sim/app/api/v2/workflows/[id]/export/route.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { describe, expect, it, vi } from 'vitest'
66
const mocks = vi.hoisted(() => ({ defineRoute: vi.fn((definition) => definition) }))
77

88
vi.mock('@/lib/api/server/routes', () => ({
9+
createInternalSessionOrExecutorAuth: vi.fn(() => ({ authenticate: vi.fn() })),
10+
createV2ResourceConcealmentPolicy: vi.fn((options) => options),
911
defineV2JsonRoute: mocks.defineRoute,
1012
v2ApiKeyAuth: { kind: 'v2-api-key' },
1113
v2RateLimits: { publicApi: { kind: 'public-api' } },

apps/sim/app/api/v2/workflows/[id]/runs/[runId]/resume/route.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@ const mocks = vi.hoisted(() => ({
1111

1212
vi.mock('@/lib/api/server/routes', () => {
1313
class V2RouteInfrastructureError extends Error {}
14+
const renderOrchestrationError = (error: unknown) => {
15+
const candidate = error as { code?: string; message?: string; name?: string }
16+
if (candidate.code === 'not_found') {
17+
return Response.json(
18+
{ error: { code: 'NOT_FOUND', message: candidate.message ?? 'Not found' } },
19+
{ status: 404 }
20+
)
21+
}
22+
if (candidate.name === 'PersonalApiKeysDisabledError') {
23+
return Response.json(
24+
{
25+
error: {
26+
code: 'FORBIDDEN',
27+
message: candidate.message ?? 'Personal API keys are not allowed for this workspace',
28+
},
29+
},
30+
{ status: 403 }
31+
)
32+
}
33+
return null
34+
}
1435
return {
1536
admitV2Request: mocks.admit,
37+
createInternalSessionOrExecutorAuth: vi.fn(() => ({ authenticate: vi.fn() })),
38+
createV2ResourceConcealmentPolicy: vi.fn(() => ({ render: renderOrchestrationError })),
1639
V2RouteInfrastructureError,
1740
v2ApiKeyAuth: { kind: 'v2-api-key' },
1841
v2RateLimits: { publicApi: { kind: 'public-api' } },
19-
v2OrchestrationErrorPolicy: { render: () => null },
42+
v2OrchestrationErrorPolicy: { render: renderOrchestrationError },
2043
}
2144
})
2245

apps/sim/app/api/v2/workflows/folders/route.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { describe, expect, it, vi } from 'vitest'
66
const mocks = vi.hoisted(() => ({ defineRoute: vi.fn((definition) => definition) }))
77

88
vi.mock('@/lib/api/server/routes', () => ({
9+
createInternalSessionOrExecutorAuth: vi.fn(() => ({ authenticate: vi.fn() })),
10+
createV2ResourceConcealmentPolicy: vi.fn((options) => options),
911
defineV2JsonRoute: mocks.defineRoute,
1012
v2ApiKeyAuth: { kind: 'v2-api-key' },
1113
v2RateLimits: { publicApi: { kind: 'public-api' } },

apps/sim/app/api/v2/workflows/import/route.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { describe, expect, it, vi } from 'vitest'
66
const mocks = vi.hoisted(() => ({ defineRoute: vi.fn((definition) => definition) }))
77

88
vi.mock('@/lib/api/server/routes', () => ({
9+
createInternalSessionOrExecutorAuth: vi.fn(() => ({ authenticate: vi.fn() })),
10+
createV2ResourceConcealmentPolicy: vi.fn((options) => options),
911
defineV2JsonRoute: mocks.defineRoute,
1012
v2ApiKeyAuth: { kind: 'v2-api-key' },
1113
v2RateLimits: { publicApi: { kind: 'public-api' } },

0 commit comments

Comments
 (0)