|
1 | 1 | import type { EncryptionClient } from '@cipherstash/stack/encryption' |
2 | 2 | import type { AnyV3Table } from '@cipherstash/stack/eql/v3' |
3 | 3 | import { encryptedTable, types } from '@cipherstash/stack/eql/v3' |
4 | | -import { describe, expect, it } from 'vitest' |
| 4 | +import { describe, expect, it, vi } from 'vitest' |
5 | 5 | import type { EncryptionFactory, Introspector } from '../src/create' |
6 | 6 | import { makeEncryptedSupabase } from '../src/create' |
7 | 7 | import type { IntrospectionData } from '../src/introspect' |
@@ -253,12 +253,24 @@ describe('plaintext table rows that carry ciphertext', () => { |
253 | 253 | }) |
254 | 254 |
|
255 | 255 | 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') |
259 | 262 |
|
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 | + } |
262 | 274 | }) |
263 | 275 |
|
264 | 276 | it('refuses a single row the same way', async () => { |
|
0 commit comments