Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should set the cookie when the flag setSessionCookie is set on the request object', function(done) {
req.setSessionCookie = true;
req.session = { uid: 'abc123' };
sandbox.stub(this.pb.SessionHandler, 'getSessionCookie')
.withArgs(req.session).returns();
sandbox.stub(this.pb.log, 'error');
sandbox.stub(Cookies.prototype, 'set')
.withArgs(this.pb.SessionHandler.COOKIE_NAME, req.session.uid, sinon.match.any);
var self = this;
this.pb.Middleware.writeSessionCookie(req, res, function(err) {
should(err).eql(undefined);
self.pb.SessionHandler.getSessionCookie.calledOnce.should.eql(true);
self.pb.log.error.called.should.eql(false);
done();
});
});
});