Skip to content

Commit 2e6188f

Browse files
committed
test(stack-supabase): assert the ciphertext error log omits jsonb keys
The refusal message is logged as well as returned, so the regression test now checks the logger output carries the location but not the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Jmn7npvR2b5FZLdXNNmCN
1 parent 818168d commit 2e6188f

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎languages/typescript/packages/stack-supabase/__tests__/supabase-plaintext-table.test.ts‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { EncryptionClient } from '@cipherstash/stack/encryption'
22
import type { AnyV3Table } from '@cipherstash/stack/eql/v3'
33
import { encryptedTable, types } from '@cipherstash/stack/eql/v3'
4-
import { describe, expect, it } from 'vitest'
4+
import { describe, expect, it, vi } from 'vitest'
55
import type { EncryptionFactory, Introspector } from '../src/create'
66
import { makeEncryptedSupabase } from '../src/create'
77
import type { IntrospectionData } from '../src/introspect'
@@ -253,12 +253,24 @@ describe('plaintext table rows that carry ciphertext', () => {
253253
})
254254

255255
it('never names a key inside a jsonb document', async () => {
256-
const rows = [{ id: 1, meta: { 'ssn-078-05-1120': envelope } }]
257-
const { es } = await introspectedClient(rows)
258-
const { error } = await es.from('audit_log').select('id, meta')
256+
const { logger } = await import('@cipherstash/stack/adapter-kit')
257+
const logged = vi.spyOn(logger, 'error').mockImplementation(() => {})
258+
try {
259+
const rows = [{ id: 1, meta: { 'ssn-078-05-1120': envelope } }]
260+
const { es } = await introspectedClient(rows)
261+
const { error } = await es.from('audit_log').select('id, meta')
259262

260-
expect(error?.message).toContain('"[0].meta"')
261-
expect(error?.message).not.toContain('ssn-078-05-1120')
263+
expect(error?.message).toContain('"[0].meta"')
264+
expect(error?.message).not.toContain('ssn-078-05-1120')
265+
// The message reaches the logger too, so the log must not carry it either.
266+
expect(logged).toHaveBeenCalled()
267+
for (const args of logged.mock.calls) {
268+
expect(args.join(' ')).toContain('"[0].meta"')
269+
expect(args.join(' ')).not.toContain('ssn-078-05-1120')
270+
}
271+
} finally {
272+
logged.mockRestore()
273+
}
262274
})
263275

264276
it('refuses a single row the same way', async () => {

0 commit comments

Comments
 (0)