47ng / prisma-field-encryption

Transparent field-level encryption at rest for Prisma
https://github.com/franky47/prisma-field-encryption-sandbox
MIT License
223 stars 27 forks source link

fix: mode=strict throws when plaintext in database #107

Open richmirza opened 2 months ago

richmirza commented 2 months ago

Closes https://github.com/47ng/prisma-field-encryption/issues/106

I have a test locally too but I'm not sure of the process to update the test / integration SQLite DBs?

franky47 commented 2 months ago

Regarding testing, you could:

  1. Add a model dedicated to this test, that has two encrypted fields, one in strict mode and one without
  2. Run yarn generate & DATABASE_URL="file:./db.test.sqlite" prisma db push to apply the schema changes to the SQLite template database
  3. In the intergration test file, inject some cleartext data the way you did in #106 (using a raw query)
  4. Check that a read on that table that matches a cleartext strict field throws an error, but that cleartext on the non-strict field doesn't throw

Thanks!