<commit_before>/// <reference path="../../.types/node/node.d.ts" />
/// <reference path="../../.types/express/express.d.ts" />
/// <reference path="../../.types/mocha/mocha.d.ts" />
/// <reference path="../../.types/supertest/supertest.d.ts" />

var mongoUrl = process.env.MONGO_URL;
if (!mongoUrl) {
  console.log('Using local mongodb instance');
  mongoUrl = process.env.MONGO_URL = 'mongodb://127.0.0.1:27017/valtech_shorties_test?w=1';
}

var request = require('supertest');
var assert = require('chai').assert;

import util = require('util');
import express = require('express');
import mongodb = require('mongodb');
import app = require('../../src/app');

var shortieApp: express.Express = app.App;
var db: mongodb.Db;
var shortiesCollection: mongodb.Collection;

describe('api', function() {
  before(function(done) {
    // bob -> mongohq connection is slow...
    this.timeout(5000);

    // Setup test mongodb connection
    mongodb.MongoClient.connect(mongoUrl, (err: Error, _db: mongodb.Db) => {
      if (err) return done(err);
      db = _db;
      shortiesCollection = db.collection('shorties');

      // Setup app
      app.setup({dbType: 'mongodb'}, done);
    });
  });

  afterEach(function(done) {
    // Remove all shorties
    shortiesCollection.remove({}, { w: 1 }, done);
  });

  after(function(done) {<commit_msg>Stub auth in API tests<commit_after>/// <reference path="../../.types/node/node.d.ts" />
/// <reference path="../../.types/express/express.d.ts" />
/// <reference path="../../.types/mocha/mocha.d.ts" />
/// <reference path="../../.types/supertest/supertest.d.ts" />

var mongoUrl = process.env.MONGO_URL;
if (!mongoUrl) {
  console.log('Using local mongodb instance');
  mongoUrl = process.env.MONGO_URL = 'mongodb://127.0.0.1:27017/valtech_shorties_test?w=1';
}

var request = require('supertest');
var assert = require('chai').assert;

import util = require('util');
import express = require('express');
import mongodb = require('mongodb');
import app = require('../../src/app');
import authMiddleware = require('../../src/auth/middleware');

var shortieApp: express.Express = app.App;
var db: mongodb.Db;
var shortiesCollection: mongodb.Collection;

describe('api', function() {
  before(function(done) {
    // bob -> mongohq connection is slow...
    this.timeout(5000);

    // Setup test mongodb connection
    mongodb.MongoClient.connect(mongoUrl, (err: Error, _db: mongodb.Db) => {
      if (err) return done(err);
      db = _db;
      shortiesCollection = db.collection('shorties');

      // Setup app
      app.setup({dbType: 'mongodb'}, done);
    });

    authMiddleware.requireAuthCookieOrRedirect = function (req, res, next) { next(); };
    authMiddleware.requireAuthOrDeny = function (req, res, next) { next(); };
  });

  afterEach(function(done) {
    // Remove all shorties
    shortiesCollection.remove({}, { w: 1 }, done);
  });

  after(function(done) {
{'fraction_non_alphanumeric': 0.19328307059629884, 'fraction_numerical': 0.011651816312542838, 'mean_word_length': 3.409365558912387, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '203604', 'n_tokens_mistral': 993, 'n_tokens_neox': 939, 'n_words': 197}