Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
expect(error).toBeNull();
expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
expect(sess.user.name).toBe('guest');
sess.user.name = 'test';
// set session
sut.setSession(sess, function (error, result) {
expect(error).toBeNull();
expect(result).toBe(true);
// get session with new params
sut.getSession(cookie, function (error, session) {
expect(error).toBeNull();
baboon.session.getSessionById(socket.request.sessionID, function (error, session) {
if (error || !session) {
return next(null, false);
} else {
// save session in socket
socket.request.session = new Session(socket.request, session);
// restricted socket connection for users with session
// connect successfully or failed
return next(null, !!session.user);
}
});
});
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
sess.regenerate = function (callback) {
callback();
};
request = {
sessionID: sess.id,
session: sess,
setSession: function (callback) {
callback(null, null);
},
headers: {}
};
sut.setActivity({}, request, function (error, result) {
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
expect(error).toBeNull();
expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
expect(sess.user.name).toBe('guest');
done();
});
});
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
sess.user = {
name: 'testUser'
};
sess.loggedIn = true;
request = {
sessionID: sess.id,
session: sess
};
sut.getUserDataForClient(null, request, function (error, result) {
expect(error).toBeNull();
expect(result.isLoggedIn).toBe(true);
expect(result.username).toBe('testUser');
done();
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
request = {
sessionID: sess.id,
session: sess,
setSession: function (callback) {
callback(null, true);
},
headers: {}
};
sut.setActivity({}, request, function (error, result) {
expect(error).toBeNull();
expect(result).toBe(true);
done();
});
});
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
delete sess.activity;
request = {
sessionID: sess.id,
session: sess
};
sut.getLastActivity({}, request, function (error, result) {
expect(error.message).toBe('Property activity not found in session');
expect(result).toBeUndefined();
done();
});
});
});
sut.getSession(cookie, function (error, session) {
var data = {
sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
sessionStore: sessionStore
};
var sess = new Session(data, session);
delete sess.data;
request = {
sessionID: sess.id,
session: sess
};
sut.getData({}, request, function (error, result) {
expect(error).toBeNull();
expect(result).toEqual({});
done();
});
});
});
sut.getSession(cookie, function (error, session) {
expect(error).toBeNull();
var sess = new Session({sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt'}, session);
expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
expect(sess.user.name).toBe('test');
done();
});
});
args.app.sessionStore.get(data.sessionID, function (err, session) {
if (err || !session) return accept('Bad session / session has expired', false);
data.session = new sessionModule.Session(data, session);
accept(null, true);
});
});