Skip to content

Commit 6379a71

Browse files
committed
Use the new test data for the crypto lib
1 parent f4fec2f commit 6379a71

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

test/lib.crypto.spec.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
const { expect } = require('chai');
22
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');
144

155
// Crypto
166
describe('Crypto library', () => {
177
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');
199
done();
2010
});
2111
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');
2313
done();
2414
});
2515
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);
2718
done();
2819
});
2920
});

0 commit comments

Comments
 (0)