Skip to content

Commit

Permalink
Key rotation test improved
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmx committed Dec 13, 2024
1 parent 1a4304e commit 85845d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/rotate-key.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
7 changes: 7 additions & 0 deletions test/testfiles/config-test-plain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"database": {
"host": "127.0.0.1",
"username": "SecretDbUser",
"password": "SecretDbPassword"
}
}

0 comments on commit 85845d7

Please sign in to comment.