diff --git a/test/rotate-key.test.js b/test/rotate-key.test.js index fea05b5..61efc3c 100644 --- a/test/rotate-key.test.js +++ b/test/rotate-key.test.js @@ -56,9 +56,12 @@ describe('secure-config-tool rotate-key test suite', () => { rotateKey('./test/testfiles/config-test.json'); expect(testOutput.length).toBe(1); let updatedJson = JSON.parse(testOutput[0]); + const originalConfig = require('./testfiles/config-test-plain.json'); expect(updatedJson.database.host).toStrictEqual('127.0.0.1'); expect(updatedJson.database.username).toBeDefined(); + expect(cryptUtils.decrypt(updatedJson.database.username, TEST_KEY_HEX_NEW)).toStrictEqual(originalConfig.database.username); expect(updatedJson.database.password).toBeDefined(); + expect(cryptUtils.decrypt(updatedJson.database.password, TEST_KEY_HEX_NEW)).toStrictEqual(originalConfig.database.password); expect(updatedJson['__hmac']).toBeDefined(); }); diff --git a/test/testfiles/config-test-plain.json b/test/testfiles/config-test-plain.json new file mode 100644 index 0000000..851a8fc --- /dev/null +++ b/test/testfiles/config-test-plain.json @@ -0,0 +1,7 @@ +{ + "database": { + "host": "127.0.0.1", + "username": "SecretDbUser", + "password": "SecretDbPassword" + } + } \ No newline at end of file