<commit_before>
process.env.NODE_ENV = 'test'

var assert = require('assert')
var connect = require('connect')
var request = require('supertest')
var session = require('..')

describe('Cookie Session', function () {
  var cookie

  describe('when options.name = my.session', function () {
    it('should use my.session for cookie name', function (done) {
      var app = App({ name: 'my.session' })
      app.use(function (req, res, next) {
        req.session.message = 'hi'
        res.end()
      })

      request(app)
      .get('/')
      .expect(shouldHaveCookie('my.session'))
      .expect(200, done)
    })
  })

  describe('when options.signed = true', function () {
    describe('when options.keys are set', function () {
      it('should work', function (done) {
        var app = connect()<commit_msg>tests: add tests for httpOnly option<commit_after>
process.env.NODE_ENV = 'test'

var assert = require('assert')
var connect = require('connect')
var request = require('supertest')
var session = require('..')

describe('Cookie Session', function () {
  var cookie

  describe('"httpOnly" option', function () {
    it('should default to "true"', function (done) {
      var app = App()
      app.use(function (req, res, next) {
        req.session.message = 'hi'
        res.end(String(req.sessionOptions.httpOnly))
      })

      request(app)
      .get('/')
      .expect('Set-Cookie', /httpOnly/i)
      .expect(200, 'true', done)
    })

    it('should use given "false"', function (done) {
      var app = App({ httpOnly: false })
      app.use(function (req, res, next) {
        req.session.message = 'hi'
        res.end(String(req.sessionOptions.httpOnly))
      })

      request(app)
      .get('/')
      .expect('Set-Cookie', /(?!httpOnly)/i)
      .expect(200, 'false', done)
    })
  })

  describe('when options.name = my.session', function () {
    it('should use my.session for cookie name', function (done) {
      var app = App({ name: 'my.session' })
      app.use(function (req, res, next) {
        req.session.message = 'hi'
        res.end()
      })

      request(app)
      .get('/')
      .expect(shouldHaveCookie('my.session'))
      .expect(200, done)
    })
  })

  describe('when options.signed = true', function () {
    describe('when options.keys are set', function () {
      it('should work', function (done) {
        var app = connect()
{'fraction_non_alphanumeric': 0.16764214046822742, 'fraction_numerical': 0.005016722408026756, 'mean_word_length': 2.687211093990755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '172503', 'n_tokens_mistral': 749, 'n_tokens_neox': 728, 'n_words': 185}