mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-31 03:02:05 +08:00
removed mdoq patch from tests
This commit is contained in:
@@ -47,6 +47,7 @@ module.exports = function (req, res, next) {
|
||||
|
||||
// default _id to current user when logging out
|
||||
if(!req.isRoot && resource.type === 'UserCollection' && req.url.indexOf('/logout') === req.url.lastIndexOf('/')) {
|
||||
if(!req.session) return next({status: 404});
|
||||
req.query._id = req.session._id;
|
||||
return next();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ describe("Dashboard", function() {
|
||||
});
|
||||
});
|
||||
|
||||
// it('should return a 404 for a bad filename', function(done) {
|
||||
// dashboard.use('/bogus/file').get(function(err, result) {
|
||||
// expect(result).to.not.exist;
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
it('should return a 404 for a bad filename', function(done) {
|
||||
dashboard.use('/bogus/file').get(function(err, result) {
|
||||
expect(result).to.not.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
|
||||
describe('Internal Collections', function(){
|
||||
describe('* /keys', function(){
|
||||
it('should not be available over http without a dpd key', function(done) {
|
||||
var ex = {key: 'foo', secret: 'bar'}
|
||||
, unauthed = require('../lib/client').use(client.url);
|
||||
, unauthed = require('../lib/client').use(client.url)
|
||||
, keys = unauthed.use('/keys')
|
||||
;
|
||||
|
||||
unauthed.use('/keys').post(ex, function (e, r) {
|
||||
unauthed.use('/keys').put(ex, function (err, res) {
|
||||
unauthed.use('/keys').del(function (error, resp) {
|
||||
unauthed.use('/keys').get(function (gerror, gresp) {
|
||||
keys.post(ex, function (e, r) {
|
||||
keys.put(ex, function (err, res) {
|
||||
keys.del(function (error, resp) {
|
||||
keys.get(function (gerror, gresp) {
|
||||
expect(e && err && error && gerror).to.exist;
|
||||
expect(r || res || resp || gresp).to.not.exist;
|
||||
done();
|
||||
@@ -19,6 +19,7 @@ describe('Internal Collections', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('* /resources', function(){
|
||||
it('should not be available over http without a dpd key', function(done) {
|
||||
var ex = {key: 'foo', secret: 'bar'}
|
||||
|
||||
@@ -24,9 +24,9 @@ describe('Users', function(){
|
||||
})
|
||||
|
||||
describe('POST /users/login', function(){
|
||||
var login = users.use('/login');
|
||||
|
||||
it('should login if provided the correct credentials', function(done) {
|
||||
var login = users.use('/login');
|
||||
login.post({email: data.users[0].email, password: data.users[0].password}, function (err, session, req, res) {
|
||||
expect(session._id).to.have.length(24);
|
||||
expect(session.user.password).to.not.exist;
|
||||
@@ -36,6 +36,7 @@ describe('Users', function(){
|
||||
})
|
||||
|
||||
it('should not respond to a GET', function(done) {
|
||||
var login = users.use('/login');
|
||||
login.get(function (err, res) {
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
@@ -46,7 +47,7 @@ describe('Users', function(){
|
||||
describe('GET /users/me', function(){
|
||||
it('should return the current session', function(done) {
|
||||
users.use('/login').post({email: data.users[0].email, password: data.users[0].password}, function (err, session, req, res) {
|
||||
client.use('/users/me').get(function (err, user) {
|
||||
users.use('/me').get(function (err, user) {
|
||||
expect(user).to.exist;
|
||||
expect(user._id).to.have.length(24);
|
||||
expect(user.password).to.not.exist;
|
||||
@@ -59,9 +60,9 @@ describe('Users', function(){
|
||||
describe('POST /users/logout', function(){
|
||||
it('should logout the current user', function(done) {
|
||||
users.use('/login').post({email: data.users[0].email, password: data.users[0].password}, function (err, session, req, res) {
|
||||
unauthed.use('/users/logout').post(function (err, res) {
|
||||
users.use('/logout').post(function (err, res) {
|
||||
expect(err).to.not.exist;
|
||||
unauthed.use('/users/me').get(function (err, res) {
|
||||
users.use('/me').get(function (err, res) {
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
});
|
||||
@@ -71,9 +72,9 @@ describe('Users', function(){
|
||||
|
||||
it('should not respond to DELETE', function(done) {
|
||||
users.use('/login').post({email: data.users[0].email, password: data.users[0].password}, function (err, session, req, res) {
|
||||
unauthed.use('/users/logout').del(function (err, res) {
|
||||
users.use('/logout').del(function (err, res) {
|
||||
expect(err).to.exist;
|
||||
unauthed.use('/users/me').get(function (err, res) {
|
||||
users.use('/me').get(function (err, res) {
|
||||
expect(err).to.not.exist;
|
||||
done();
|
||||
});
|
||||
@@ -82,7 +83,7 @@ describe('Users', function(){
|
||||
})
|
||||
|
||||
it('should return an error if trying to logout twice', function(done) {
|
||||
client.use('/users/logout').post(function (err, body, req, res) {
|
||||
users.use('/logout').post(function (err, body, req, res) {
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
});
|
||||
@@ -91,7 +92,7 @@ describe('Users', function(){
|
||||
|
||||
describe('GET /users', function(){
|
||||
it('should return a user if an id is provided', function(done) {
|
||||
client.use('/users').get({_id: data.users[0]._id}, function (err, user) {
|
||||
users.get({_id: data.users[0]._id}, function (err, user) {
|
||||
expect(user).to.exist;
|
||||
expect(user).to.have.length(1);
|
||||
expect(user[0].password).to.not.exist;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// describe('Cross Domain Support', function(){
|
||||
// describe('OPTIONS /todo', function(){
|
||||
// it('should include Access-Control-Allow-Headers', function(done) {
|
||||
// var hdrs = 'GET, POST, PUT, DELETE'
|
||||
// , req = {method: 'OPTIONS', url: todos.url, headers: {'Access-Control-Request-Headers': hdrs}}
|
||||
// ;
|
||||
// todos.exec(req, function (err, body, req, res) {
|
||||
// expect(body).to.equal('OK');
|
||||
// done(err);
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// describe('* /todos', function(){
|
||||
// it('should include Access-Control-Allow-* headers', function(done) {
|
||||
// todos.get(function (err, body, req, res) {
|
||||
// expect(res.headers['Access-Control-Allow-Origin'.toLowerCase()]).to.equal('*');
|
||||
// expect(res.headers['Access-Control-Allow-Methods'.toLowerCase()]).to.equal('GET, POST, PUT, DELETE, OPTIONS');
|
||||
// expect(res.headers['Access-Control-Allow-Credentials'.toLowerCase()]).to.equal('true');
|
||||
// done(err);
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
Reference in New Issue
Block a user