I'm writing tests, trying to use TDD with Mocha on an application that uses JWT for authentication. Basically admin and common users share the same User model, with a boolean admin field.
These are the routes:
app.post('/register', controllers.auth.create);
app.post('/login', controllers.auth.login);
router.get('/admin', function (req, res) {..[render admin login tpl]..});
router.post('/admin', isAuthenticated, isAuthorized, controllers.admin.index);
My question is, how to test an Admin user, I can't create on DB directly because i'm checking the token too (isAuthenticated). What's the best way to test it in Mocha?
Aucun commentaire:
Enregistrer un commentaire