diff --git a/backend/package.json b/backend/package.json index 28162e3..fb1a3c5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "comment": "added by heartbeat" + "comment": "added by heartbeat", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/backend/src/services/encryption.test.js b/backend/src/services/encryption.test.js new file mode 100644 index 0000000..ce20df1 --- /dev/null +++ b/backend/src/services/encryption.test.js @@ -0,0 +1,23 @@ +import { encryptText, decryptText } from './encryption.js'; + +const TEST_KEY = 'YixWi1MYh77NMEQYSJZR+2IsVotTGIe+zTBEGEiWUfs='; // 32 bytes base64 + +process.env.DATA_ENCRYPTION_KEY = TEST_KEY; + +const run = async () => { + const plain = 'Hello, World! 123'; + const encrypted = encryptText(plain); + const decrypted = decryptText(encrypted); + + if (decrypted !== plain) { + console.error('Decryption mismatch:', { plain, decrypted }); + process.exit(1); + } + + console.log('Encryption tests passed'); +}; + +run().catch((err) => { + console.error('Encryption tests failed:', err.message); + process.exit(1); +}); \ No newline at end of file