|
3 | 3 | */ |
4 | 4 | import { encryptionMockFns, environmentUtilsMockFns, resetEnvironmentUtilsMock } from '@sim/testing' |
5 | 5 | import { afterEach, describe, expect, it, vi } from 'vitest' |
| 6 | +import { internalKnowledgeSearchBodySchema } from '@/lib/api/contracts/knowledge/search' |
6 | 7 | import { PRIVATE_MODEL_INPUT_PROVENANCE_HEADER } from '@/lib/execution/model-input-provenance' |
7 | 8 | import { |
8 | 9 | RESOLVED_SECRET_PROVENANCE_FIELD, |
@@ -86,6 +87,25 @@ describe('Knowledge model input provenance', () => { |
86 | 87 | expect(environmentUtilsMockFns.mockGetEffectiveEnvironmentSnapshot).not.toHaveBeenCalled() |
87 | 88 | }) |
88 | 89 |
|
| 90 | + it('accepts a verified envelope after the internal route contract parses it', async () => { |
| 91 | + const body = internalKnowledgeSearchBodySchema.parse({ |
| 92 | + knowledgeBaseIds: ['knowledge-base-1'], |
| 93 | + ...verifiedPayload(), |
| 94 | + }) |
| 95 | + |
| 96 | + const result = await prepareKnowledgeModelInputProvenance({ |
| 97 | + headers: verifiedHeaders(), |
| 98 | + payload: body, |
| 99 | + isInternalRequest: true, |
| 100 | + userId: 'user-1', |
| 101 | + workspaceId: 'workspace-1', |
| 102 | + modelInput: body.query, |
| 103 | + }) |
| 104 | + |
| 105 | + expect(result.success).toBe(true) |
| 106 | + expect(result.success && result.registry?.isComplete()).toBe(true) |
| 107 | + }) |
| 108 | + |
89 | 109 | it('does not activate an authenticated entry absent from the exact model input', async () => { |
90 | 110 | environmentUtilsMockFns.mockGetEffectiveEnvironmentSnapshot.mockResolvedValue({ |
91 | 111 | personalEncrypted: { TOKEN: 'encrypted-token' }, |
|
0 commit comments