Fixed broken spam prevention test (#10281)

* Fixed broken spam prevention test

closes #10280

* Improved spam prevention test
This commit is contained in:
Fabien O'Carroll 2018-12-13 18:44:32 +07:00 committed by GitHub
parent 7cce71d997
commit 43ce1f02c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,13 +87,18 @@ describe('Spam Prevention API', function () {
it('Ensure reset works: password grant type', function () {
return executeRequests(userAllowedAttempts - 1, loginAttempt, owner.email, incorrectPassword)
.then(() => loginAttempt(owner.email, correctPassword))
.then(() => {
return db.knex('brute').select()
.then(function (rows) {
// if reset works, the key is deleted and only one key remains in the database
// the one key is the key for global block
rows.length.should.eql(1);
});
// CASE: login in with bad credentials twice - which would
// take us over the limit if the block hasn't been reset
.then(() => loginAttempt(owner.email, incorrectPassword))
.then(() => loginAttempt(owner.email, incorrectPassword))
.then((res) => {
// CASE: the reset means that we should be able to attempt to log in again
// and not get a too many requests error
const error = res.body.errors[0];
should.exist(error.errorType);
res.statusCode.should.eql(422);
error.errorType.should.eql('ValidationError');
error.message.should.eql('Your password is incorrect.');
});
});
});