fixup - Include accessToken in user logout tests

This commit is contained in:
Ritchie Martori 2013-12-17 21:34:30 -08:00
parent 98ed38302a
commit 9f2651578b
1 changed files with 8 additions and 8 deletions

View File

@ -17,6 +17,7 @@ describe('User', function(){
}); });
beforeEach(function (done) { beforeEach(function (done) {
app.use(loopback.token());
app.use(loopback.rest()); app.use(loopback.rest());
app.model(User); app.model(User);
@ -153,7 +154,6 @@ describe('User', function(){
it('Logout a user by providing the current accessToken id (over rest)', function(done) { it('Logout a user by providing the current accessToken id (over rest)', function(done) {
login(logout); login(logout);
function login(fn) { function login(fn) {
request(app) request(app)
.post('/users/login') .post('/users/login')
@ -171,22 +171,22 @@ describe('User', function(){
}); });
} }
function logout(err, sid) { function logout(err, token) {
request(app) request(app)
.post('/users/logout') .post('/users/logout')
.set('Authorization', token)
.expect(204) .expect(204)
.send({sid: sid}) .end(verify(token, done));
.end(verify(sid, done));
} }
}); });
function verify(sid, done) { function verify(token, done) {
assert(sid); assert(token);
return function (err) { return function (err) {
if(err) return done(err); if(err) return done(err);
AccessToken.findById(sid, function (err, accessToken) { AccessToken.findById(token, function (err, accessToken) {
assert(!accessToken, 'accessToken should not exist after logging out'); assert(!accessToken, 'accessToken should not exist after logging out');
done(err); done(err);
}); });