Skip to content

Commit 7dacbaf

Browse files
committed
Refactoring of the test to use a test data file
1 parent fefb939 commit 7dacbaf

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

test/functional/secret.spec.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
const request = require('request');
22
const { expect } = require('chai');
33
const config = require('../../src/config/config.json');
4-
5-
// Configuration
6-
const id = 'test-01';
7-
const encryptionKey = 'p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C';
8-
const secret = {
9-
first_name: 'firstname',
10-
last_name: 'lastname',
11-
email: 'email@email.com',
12-
password: 'app123',
13-
password_confirmation: 'app123',
14-
};
15-
4+
const testData = require('../testData.json');
165

176
// Add Secret
187
describe('Add Secret endpoint response', () => {
@@ -25,9 +14,9 @@ describe('Add Secret endpoint response', () => {
2514
'Content-Type': 'application/json',
2615
},
2716
body: {
28-
id,
29-
encryption_key: encryptionKey,
30-
value: secret,
17+
id: testData.id,
18+
encryption_key: testData.encryptionKey,
19+
value: testData.secret,
3120
},
3221
json: true,
3322
};
@@ -51,8 +40,8 @@ describe('Get Secret(s) endpoint response', () => {
5140
'Content-Type': 'application/json',
5241
},
5342
body: {
54-
id,
55-
encryption_key: encryptionKey,
43+
id: testData.id,
44+
encryption_key: testData.encryptionKey,
5645
},
5746
json: true,
5847
};

test/testData.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"id": "test-01",
3+
"encryptionKey": "p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C",
4+
"secret": {
5+
"first_name": "firstname",
6+
"last_name": "lastname",
7+
"email": "email@email.com",
8+
"password": "app123",
9+
"password_confirmation": "app123"
10+
},
11+
"encryptedSecret": "8b207a4408fec28e4d985b80c66a0e74:b5245d5149a6cba15ee6f597a3b1fc5fcaca4ccdd7f8ed0865f0358002a74a90d17ee7ddb55bc295ae4a6e71ff13d86466790641cc61cbe728bb4014e3acd0ceef654ca7f14bd4e2875a0158c1ca669b8fee1ebbf9a47cbdfe1668568c4d295fdc00b4fb07196452c05ae465a11146738cf9a9e9827b8ab75a817e94780a759e56ccb5b26ac2a79716d0ec3a0784ad6b"
12+
}

0 commit comments

Comments
 (0)