Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit d5a0cc8

Browse files
author
Miroslav Bajtoš
committed
helpers: Improve ACL asserts
Modify `_it.shouldBeAllowed` to include the actual status code in the assertion error. Modify `_it.shouldBeDenied` to assert the exact value of the status code. Expect the status code configured via `app.get('aclErrorStatus')`, add a parameter allowing callers to override this value.
1 parent 25be2d7 commit d5a0cc8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/helpers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ _it.shouldBeAllowed = function() {
211211
it('should be allowed', function() {
212212
assert(this.req);
213213
assert(this.res);
214-
//status 200 -> 399
215-
var status = this.res.statusCode;
216-
assert(status >= 200 && status <= 399);
214+
// expect success - status 2xx or 3xx
215+
expect(this.res.statusCode).to.be.within(100, 399);
217216
});
218217
}
219218

220219
_it.shouldBeDenied = function() {
221220
it('should not be allowed', function() {
222221
assert(this.res);
223-
//if in list
224-
var status = this.res.statusCode;
225-
assert([403,401].indexOf(status) > -1);
222+
var expectedStatus = this.aclErrorStatus ||
223+
this.app && this.app.get('aclErrorStatus') ||
224+
401;
225+
expect(this.res.statusCode).to.equal(expectedStatus);
226226
});
227227
}
228228

0 commit comments

Comments
 (0)