<commit_before>var async = require('async');
var nano = require('nano')('http://localhost:5984');
var request = require('supertest');

var databaseName = 'a-tmp-db-for-circle-blvd-testing';
var sessionsDatabaseName = databaseName + '-sessions';
process.env.DATABASE_NAME = databaseName;

var unit  = undefined;
var test  = {};

var admin = undefined;
var member = undefined;

var adminEmail = '<EMAIL>';
var adminPassword = '<PASSWORD>?';
var adminSession = {};

var memberEmail = "<EMAIL>";
var memberPassword = '<PASSWORD>!';
var memberSession = {};

var finish = function (test) {
	var fn = function (err) {
		test.ifError(err);
		test.done();
	};
	return fn;
};

test['database setup'] = function (test) {
	var app = require('../app.js');
	unit = app.express;
	// CouchDB is not entirely ready when ready is
	// called. So, work around that until we can
	// fix it.
	var halfSecond = 500;
	app.whenReady(function () {
		setTimeout(function () {
			test.done();
		}, halfSecond);	
	});

	// for a persistent session
	admin = request.agent(unit);
	member = request.agent(unit);
};

// Initialize
test['GET / is 302'] = function (test) {
	request(unit)
	.get('/')
	.expect(302)
	.end(finish(test));
};

test['POST /data/initialize is 200'] = function (test) {
	var data = {};
	data.admin = {
		email: adminEmail,
		password: <PASSWORD>
	};

	request(unit)
	.put('/data/initialize')
	.send(data)
	.expect(200)
	.end(finish(test));
};

// Sign in
test['GET /data/user is 401 at first'] = function (test) {
	admin
	.get('/data/user')
	.expect(401)
	.end(finish(test));
};

test['POST /auth/signin is 401 with bad password'] = function (test) {
	admin
	.post('/auth/signin')
	.type("form")
	.send({ email: adminEmail })
	.send({ password: '<PASSWORD>' })<commit_msg>Test: GET / can return 302 or 200<commit_after>var async = require('async');
var nano = require('nano')('http://localhost:5984');
var request = require('supertest');

var databaseName = 'a-tmp-db-for-circle-blvd-testing';
var sessionsDatabaseName = databaseName + '-sessions';
process.env.DATABASE_NAME = databaseName;

var unit  = undefined;
var test  = {};

var admin = undefined;
var member = undefined;

var adminEmail = '<EMAIL>';
var adminPassword = '<PASSWORD>?';
var adminSession = {};

var memberEmail = "<EMAIL>";
var memberPassword = '<PASSWORD>!';
var memberSession = {};

var finish = function (test) {
	var fn = function (err) {
		test.ifError(err);
		test.done();
	};
	return fn;
};

test['database setup'] = function (test) {
	var app = require('../app.js');
	unit = app.express;
	// CouchDB is not entirely ready when ready is
	// called. So, work around that until we can
	// fix it.
	var halfSecond = 500;
	app.whenReady(function () {
		setTimeout(function () {
			test.done();
		}, halfSecond);	
	});

	// for a persistent session
	admin = request.agent(unit);
	member = request.agent(unit);
};

// Initialize
test['GET / is 200 or 302'] = function (test) {
	request(unit)
	.get('/')
	.expect(function (res) {
		if (res.status === 200 || res.status === 302) {
			return;
		}
		return "Unexpected status code";
	})
	.end(finish(test));
};

test['POST /data/initialize is 200'] = function (test) {
	var data = {};
	data.admin = {
		email: adminEmail,
		password: <PASSWORD>
	};

	request(unit)
	.put('/data/initialize')
	.send(data)
	.expect(200)
	.end(finish(test));
};

// Sign in
test['GET /data/user is 401 at first'] = function (test) {
	admin
	.get('/data/user')
	.expect(401)
	.end(finish(test));
};

test['POST /auth/signin is 401 with bad password'] = function (test) {
	admin
	.post('/auth/signin')
	.type("form")
	.send({ email: adminEmail })
	.send({ password: '<PASSWORD>' })
{'fraction_non_alphanumeric': 0.1837012810029981, 'fraction_numerical': 0.01853366039792859, 'mean_word_length': 3.8998664886515355, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1494987', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1262, 'n_words': 337}