Increase unit test coverage of auth code

This commit is contained in:
Nick O'Leary
2015-01-28 22:41:13 +00:00
parent b2aae93fa6
commit fbf7ee50eb
22 changed files with 1251 additions and 178 deletions

View File

@@ -32,6 +32,7 @@ var settings = require("../settings");
var errorHandler = function(err,req,res,next) {
//TODO: standardize json response
console.log(err.stack);
res.send(400,err.toString());
};
@@ -51,18 +52,19 @@ function init(adminApp) {
adminApp.use(express.json());
adminApp.use(express.urlencoded());
//TODO: all passport references ought to be in ./auth
adminApp.use(passport.initialize());
adminApp.use(auth.authenticate);
adminApp.post("/auth/token",
auth.ensureClientSecret,
auth.authenticateClient,
auth.getToken,
auth.errorHandler
);
adminApp.get("/auth/login",auth.login);
adminApp.post("/auth/revoke",auth.revoke);
if (settings.adminAuth) {
//TODO: all passport references ought to be in ./auth
adminApp.use(passport.initialize());
adminApp.use(auth.authenticate);
adminApp.post("/auth/token",
auth.ensureClientSecret,
auth.authenticateClient,
auth.getToken,
auth.errorHandler
);
adminApp.get("/auth/login",auth.login);
adminApp.post("/auth/revoke",auth.revoke);
}
// Flows
adminApp.get("/flows",needsPermission("flows.read"),flows.get);