|
1 | 1 | const { expect } = require('chai'); |
2 | 2 | const crypto = require('../src/lib/crypto'); |
3 | | - |
4 | | -// Configuration |
5 | | -const encryptionKey = 'p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C'; |
6 | | -const unencrypted = { |
7 | | - first_name: 'firstname', |
8 | | - last_name: 'lastname', |
9 | | - email: 'email@email.com', |
10 | | - password: 'app123', |
11 | | - password_confirmation: 'app123', |
12 | | -}; |
13 | | -const encrypted = '0f80f3912cb30fc0e69c90f6cbf5b79f:906e26046549891c947ff2bac234a24a0a5bbbae448104f8e5ffca710e00629aad1af5dcc03bb09a022441e2f1508609e38b693f574f4229e4d5a6af06a1c816edf06f524b5822fe3f4ed8ccb6b36ad9d73780aeaa885dfad0f9e51a690b986acf7e0219cff6918a0822516a390e803a19a0c3a909f1a55d4d5ef251539e75bed40ddbb4f8a9fb627b3a5c176de96011'; |
| 3 | +const testData = require('./testData.json'); |
14 | 4 |
|
15 | 5 | // Crypto |
16 | 6 | describe('Crypto library', () => { |
17 | 7 | it('expect the "encrypt" function to return a string', (done) => { |
18 | | - expect(crypto.encrypt(JSON.stringify(unencrypted), encryptionKey)).to.be.a('string'); |
| 8 | + expect(crypto.encrypt(JSON.stringify(testData.secret), testData.encryptionKey)).to.be.a('string'); |
19 | 9 | done(); |
20 | 10 | }); |
21 | 11 | it('expect the "decrypt" function to return an object', (done) => { |
22 | | - expect(JSON.parse(crypto.decrypt(encrypted, encryptionKey))).to.be.an('object'); |
| 12 | + expect(JSON.parse(crypto.decrypt(testData.encryptedSecret, testData.encryptionKey))).to.be.an('object'); |
23 | 13 | done(); |
24 | 14 | }); |
25 | 15 | it('expect the "decrypt" function to return the same object as original data', (done) => { |
26 | | - expect(JSON.parse(crypto.decrypt(encrypted, encryptionKey))).to.deep.equals(unencrypted); |
| 16 | + // eslint-disable-next-line max-len |
| 17 | + expect(JSON.parse(crypto.decrypt(testData.encryptedSecret, testData.encryptionKey))).to.deep.equals(testData.secret); |
27 | 18 | done(); |
28 | 19 | }); |
29 | 20 | }); |
0 commit comments