test: fix ACL integration tests

Change the tests creating new users so that they send valid user data,
in order to prevent 422 "validation failed" responses.

Upgrade loopback-testing to 0.2.0.
This commit is contained in:
Miroslav Bajtoš 2014-06-09 09:53:05 +02:00
parent ad347e517c
commit 3deadcd180
2 changed files with 15 additions and 3 deletions

View File

@ -52,7 +52,7 @@
"strong-task-emitter": "0.0.x", "strong-task-emitter": "0.0.x",
"supertest": "~0.12.1", "supertest": "~0.12.1",
"chai": "~1.9.1", "chai": "~1.9.1",
"loopback-testing": "~0.1.2", "loopback-testing": "~0.2.0",
"browserify": "~4.1.5", "browserify": "~4.1.5",
"grunt": "~0.4.5", "grunt": "~0.4.5",
"grunt-browserify": "~2.1.0", "grunt-browserify": "~2.1.0",

View File

@ -69,8 +69,11 @@ describe('access control - integration', function () {
lt.it.shouldBeDeniedWhenCalledUnauthenticated('GET', urlForUser); lt.it.shouldBeDeniedWhenCalledUnauthenticated('GET', urlForUser);
lt.it.shouldBeDeniedWhenCalledByUser(CURRENT_USER,'GET', urlForUser); lt.it.shouldBeDeniedWhenCalledByUser(CURRENT_USER,'GET', urlForUser);
lt.it.shouldBeAllowedWhenCalledAnonymously('POST', '/api/users'); lt.it.shouldBeAllowedWhenCalledAnonymously(
lt.it.shouldBeAllowedWhenCalledByUser(CURRENT_USER, 'POST', '/api/users'); 'POST', '/api/users', newUserData());
lt.it.shouldBeAllowedWhenCalledByUser(
CURRENT_USER, 'POST', '/api/users', newUserData());
lt.it.shouldBeAllowedWhenCalledByUser(CURRENT_USER, 'POST', '/api/users/logout'); lt.it.shouldBeAllowedWhenCalledByUser(CURRENT_USER, 'POST', '/api/users/logout');
@ -112,6 +115,15 @@ describe('access control - integration', function () {
function urlForUser() { function urlForUser() {
return '/api/users/' + this.randomUser.id; return '/api/users/' + this.randomUser.id;
} }
var userCounter;
function newUserData() {
userCounter = userCounter ? ++userCounter : 1;
return {
email: 'new-' + userCounter + '@test.test',
password: 'test'
};
}
}); });
describe('/banks', function () { describe('/banks', function () {