text: 'use strict';
  
  const t = require('tap');
  const test = t.test;
  const Fastify = require('fastify');
  const request = require('request');
  const fastifyCookie = require('fastify-cookie');
  const fastifySession = require('..');
  
  test('should add session object to request', t => {
    t.plan(4);
    const fastify = Fastify();
  
    const options = {
      secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk'
    }
    fastify.register(fastifyCookie);
    fastify.register(fastifySession, options);
    fastify.get('/', (request, reply) => {
      t.ok(request.session);
      reply.send(200);
    })
    fastify.listen(0, err => {
      fastify.server.unref();
      t.error(err);
      request({
        method: 'GET',
        uri: 'http://localhost:' + fastify.server.address().port
      }, (err, response, body) => {
        t.error(err);
        t.strictEqual(response.statusCode, 200);
      })
    });
  });
  
  test('should add session.encryptedSessionId object to request', t => {
    t.plan(4);
    const fastify = Fastify();
  
    const options = {
      secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk'
    }
    fastify.register(fastifyCookie);
    fastify.register(fastifySession, options);
    fastify.get('/', (request, reply) => {
      t.ok(request.session.encryptedSessionId);
      reply.send(200);
    })
    fastify.listen(0, err => {
      fastify.server.unref();
      t.error(err);
      request({
        method: 'GET',
        uri: 'http://localhost:' + fastify.server.address().port
      }, (err, response, body) => {
        t.error(err);
        t.strictEqual(response.statusCode, 200);
      })
    });
  });
  
  test('should add session.cookie object to request', t => {
    t.plan(4);
    const fastify = Fastify();
  
    const options = {
      secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk'
    }
    fastify.register(fastifyCookie);
    fastify.register(fastifySession, options);
    fastify.get('/', (request, reply) => {
      t.ok(request.session.cookie);
      reply.send(200);
    })
    fastify.listen(0, err => {
      fastify.server.unref();
      t.error(err);
      request({
        method: 'GET',
        uri: 'http://localhost:' + fastify.server.address().port
      }, (err, response, body) => {
        t.error(err);
        t.strictEqual(response.statusCode, 200);
      })
    });
  });
  
  test('should add session.expires object to request', t => {
    t.plan(4);
    const fastify = Fastify();
  
    const options = {
      secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk',
      cookie: {
        maxAge: 42
      }
    }
    fastify.register(fastifyCookie);
    fastify.register(fastifySession, options);
    fastify.get('/', (request, reply) => {
      t.ok(request.session.expires);
      reply.send(200);
    })
    fastify.listen(0, err => {
      fastify.server.unref();
      t.error(err);
      request({
        method: 'GET',
        uri: 'http://localhost:' + fastify.server.address().port
      }, (err, response, body) => {
        t.error(err);
        t.strictEqual(response.statusCode, 200);
      })
    });
  });
  
  test('should add session.sessionId object to request', t => {
    t.plan(4);
    const fastify = Fastify();
  
    const options = {
      secret: 'cNaoPYAwF60HZJzkcNaoPYAwF60HZJzk'
    }
    fastify.register(fastifyCookie);
    fastify.register(fastifySession, options);
    fastify.get('/', (request, reply) => {
      t.ok(request.session.sessionId);
      reply.send(200);
    })
    fastify.listen(0, err => {
      fastify.server.unref();
      t.error(err);
      request({
        method: 'GET',
        uri: 'http://localhost:' + fastify.server.address().port
      }, (err, response, body) => {
        t.error(err);
        t.strictEqual(response.statusCode, 200);
      })
    });
  });