-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
8 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
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 |
---|---|---|
|
@@ -1187,6 +1187,43 @@ describe('testing identity-srv', () => { | |
upUser.activation_code!.should.be.empty(); | ||
upUser.password_hash!.should.not.equal(pwHashA); | ||
}); | ||
|
||
it('should fail to change the password if it was used before', async function changePasswordFail(): Promise<void> { | ||
// store token to Redis as passwordChange looks up the user based on token (as this operation is for logged in user) | ||
let expires_in = new Date(); // set expires_in to +1 day | ||
expires_in.setDate(expires_in.getDate() + 1); | ||
let userWithToken = { | ||
name: 'test.user1', // user registered initially, storing with token in DB | ||
first_name: 'test', | ||
last_name: 'user', | ||
password: 'CNQJrH%43KAayeDpf3h', | ||
email: '[email protected]', | ||
token: 'user-token', | ||
tokens: [{ | ||
token: 'user-token', | ||
expires_in | ||
}] | ||
}; | ||
const redisConfig = cfg.get('redis'); | ||
// for findByToken | ||
redisConfig.database = cfg.get('redis:db-indexes:db-findByToken') || 0; | ||
tokenRedisClient = RedisCreateClient(redisConfig); | ||
tokenRedisClient.on('error', (err) => logger.error('Redis client error in token cache store', err)); | ||
await tokenRedisClient.connect(); | ||
// store user with tokens and role associations to Redis index `db-findByToken` | ||
await tokenRedisClient.set('user-token', JSON.stringify(userWithToken)); | ||
|
||
this.timeout(30000); | ||
const changeResult = await (userService.changePassword({ | ||
password: 'CNQJrH%44KAayeDpf3h', | ||
new_password: 'CNQJrH%43KAayeDpf3h', | ||
subject: { token: 'user-token' } | ||
})); | ||
should.exist(changeResult); | ||
should.exist(changeResult.operation_status); | ||
changeResult.operation_status!.code!.should.equal(400); | ||
changeResult.operation_status!.message!.should.match(/This password has recently been used. User ID .*/); | ||
}); | ||
}); | ||
|
||
describe('calling changeEmail', function changeEmailId(): void { | ||
|