Skip to content

Commit 82ab95f

Browse files
committed
Fixed test issues.
1 parent d6b74dc commit 82ab95f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

test/startTests.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const _ = require('lodash');
77
const fs = require('fs');
88
const path = require('path');
9+
const crypto = require('crypto');
910
global.chai = require('chai');
1011

1112
chai.use(require('chai-spies'));
@@ -80,6 +81,9 @@ exports.mochaHooks = {
8081
}
8182
},
8283
models: {
84+
dataEncryptionKeys: {
85+
default: crypto.randomBytes(32).toString('base64')
86+
},
8387
migrate: 'drop'
8488
},
8589
globals: {
@@ -92,7 +96,8 @@ exports.mochaHooks = {
9296
session: {
9397
cookie: {
9498
secure: false // can't have secure cookies when testing
95-
}
99+
},
100+
secret: crypto.createHmac('sha256', crypto.randomBytes(42)).update(crypto.randomBytes(42) + new Date()).digest('hex')
96101
},
97102
security: {
98103
checkPwnedPasswords: true

test/unit/helpers/is-password-valid.test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('isPasswordValid Helper', function() {
99

1010
isValid.should.be.an('array');
1111
isValid.length.should.equal(1);
12-
isValid[0].should.equal('Password must be at least 7 characters');
12+
isValid[0].should.equal('Password must be at least 7 characters.');
1313
});
1414

1515
it('should not allow passwords longer than 70 characters', async function() {
@@ -25,39 +25,39 @@ describe('isPasswordValid Helper', function() {
2525

2626
isValid.should.be.an('array');
2727
isValid.length.should.equal(1);
28-
isValid[0].should.equal('Password can not contain 3 or more repeated characters');
28+
isValid[0].should.equal('Password can not contain 3 or more repeated characters.');
2929
});
3030

3131
it('should require at least 1 lowercase character', async function() {
3232
const isValid = await sails.helpers.isPasswordValid('1234ABCD.K', true);
3333

3434
isValid.should.be.an('array');
3535
isValid.length.should.equal(1);
36-
isValid[0].should.equal('Password must have at least 1 lowercase character');
36+
isValid[0].should.equal('Password must have at least 1 lowercase character.');
3737
});
3838

3939
it('should require at least 1 uppercase character', async function() {
4040
const isValid = await sails.helpers.isPasswordValid('1234abcd.k', true);
4141

4242
isValid.should.be.an('array');
4343
isValid.length.should.equal(1);
44-
isValid[0].should.equal('Password must have at least 1 uppercase character');
44+
isValid[0].should.equal('Password must have at least 1 uppercase character.');
4545
});
4646

4747
it('should require at least 1 digit', async function() {
4848
const isValid = await sails.helpers.isPasswordValid('AbcdEfg.k', true);
4949

5050
isValid.should.be.an('array');
5151
isValid.length.should.equal(1);
52-
isValid[0].should.equal('Password must have at least 1 digit');
52+
isValid[0].should.equal('Password must have at least 1 digit.');
5353
});
5454

5555
it('should require at least 1 special character', async function() {
5656
const isValid = await sails.helpers.isPasswordValid('12345Abcd', true);
5757

5858
isValid.should.be.an('array');
5959
isValid.length.should.equal(1);
60-
isValid[0].should.equal('Password must have at least 1 special character');
60+
isValid[0].should.equal('Password must have at least 1 special character.');
6161
});
6262

6363
it('should return true for valid password', async function() {
@@ -90,7 +90,7 @@ describe('isPasswordValid Helper', function() {
9090

9191
isValid.should.be.an('array');
9292
isValid.length.should.equal(1);
93-
isValid[0].should.equal('Password can not contain your email address');
93+
isValid[0].should.equal('Password can not contain your email address.');
9494
});
9595

9696
it('should not allow first name in password', async function() {
@@ -102,7 +102,7 @@ describe('isPasswordValid Helper', function() {
102102

103103
isValid.should.be.an('array');
104104
isValid.length.should.equal(1);
105-
isValid[0].should.equal('Password can not contain your first name');
105+
isValid[0].should.equal('Password can not contain your first name.');
106106
});
107107

108108
it('should not allow last name in password', async function() {
@@ -114,7 +114,7 @@ describe('isPasswordValid Helper', function() {
114114

115115
isValid.should.be.an('array');
116116
isValid.length.should.equal(1);
117-
isValid[0].should.equal('Password can not contain your last name');
117+
isValid[0].should.equal('Password can not contain your last name.');
118118
});
119119
});
120120

0 commit comments

Comments
 (0)