forked from bcgov/common-hosted-form-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use cryptr library for encryption/decryption.
remove db encryption configuration. update tests Signed-off-by: Jason Sherman <[email protected]>
- Loading branch information
1 parent
1749b91
commit 00f115f
Showing
10 changed files
with
46 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ const { MockModel } = require('../../common/dbHelper'); | |
const { encryptionService, ENCRYPTION_ALGORITHMS, ENCRYPTION_KEYS } = require('../../../src/components/encryptionService'); | ||
|
||
// change these as appropriate after adding new default keys/algos... | ||
const KEY_COUNT = 2; | ||
const KEY_COUNT = 1; | ||
const ALGO_COUNT = 1; | ||
|
||
beforeEach(() => { | ||
|
@@ -42,30 +42,13 @@ describe('encryptionService', () => { | |
expect(data).toEqual(dec); | ||
}); | ||
|
||
it('should encrypt/decrypt db data (object)', () => { | ||
const data = { username: 'unittest', email: '[email protected]' }; | ||
const enc = encryptionService.encryptDb(data); | ||
expect(enc).toBeTruthy(); | ||
const dec = encryptionService.decryptDb(enc); | ||
expect(dec).toBeTruthy(); | ||
expect(data).toMatchObject(JSON.parse(dec)); | ||
}); | ||
|
||
it('should encrypt/decrypt db data (string)', () => { | ||
const data = 'this is my string value'; | ||
const enc = encryptionService.encryptDb(data); | ||
expect(enc).toBeTruthy(); | ||
const dec = encryptionService.decryptDb(enc); | ||
expect(dec).toBeTruthy(); | ||
expect(data).toEqual(dec); | ||
}); | ||
|
||
it('should not decrypt a proxy encryption with db key', () => { | ||
it('should not decrypt a proxy encryption with external key', () => { | ||
const externalKey = 'e9eb43121581f1877e2b8135c8d9079b91c04aab6c717799196630a685b2c6c0'; | ||
const data = 'this is my string value'; | ||
const enc = encryptionService.encryptProxy(data); | ||
expect(enc).toBeTruthy(); | ||
expect(() => { | ||
encryptionService.decryptDb(enc); | ||
encryptionService.decryptExternal(ENCRYPTION_ALGORITHMS.AES_256_GCM, externalKey, enc); | ||
}).toThrowError(); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters