<commit_before>'use strict';
const Code = require('code');
const Hoek = require('hoek');
const Lab = require('lab');

// Internals
const Suite = require('../test/user.suite');
const Forger = require('forger');
const Sinon = require('sinon');

// Helpers
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const before = lab.before;
const beforeEach = lab.beforeEach;
const afterEach = lab.afterEach;
const after = lab.after;
const it = lab.it;
const expect = Code.expect;

before(Suite.setupServer);
before(Suite.db.connect);
after(Suite.db.dropDatabase);
after(Suite.db.disconnect);

describe('POST /auth/register', () => {

	beforeEach(Suite.db.resetDatabase);

	it('should reply successfully (200) with token', (done) => {
		Suite.server.inject({
			url: '/auth/register',
			method: 'POST',
			payload: {
				email: '<EMAIL>',
				displayName: 'IndieForger',
				password: '<PASSWORD>'
			}
		}, (res) => {
			expect(res.statusCode).to.equal(200);

			done();
		});
	});

	it('should reply with bad request (400) if payload is missing', (done) => {
		Suite.server.inject({
			url: '/auth/register',
			method: 'POST'
		}, (res) => {
			expect(res.statusCode).to.equal(400);
			done();
		});
	});

	it('should reply with bad request (400) if payload is partially missing', (done) => {
		const sendRequest = function ( payload, next ) {
			Suite.server.inject({ url: '/auth/register', method: 'POST', payload: payload }, (res) => {
				expect(res.statusCode).to.equal(400);
				done();
			});
		};

		Forger.sequence(
			(next) => { sendRequest( { /*email: '<EMAIL>',*/ displayName: 'IndieForger', password: '<PASSWORD>' }, next )},
			(next) => { sendRequest( { email: '<EMAIL>', /*displayName: 'IndieForger',*/ password: '<PASSWORD>' }, next )},
			(next) => { sendRequest( { email: '<EMAIL>', displayName: 'IndieForger'/*, password: '<PASSWORD>'*/ }, next )}
		)
		.then(() => done())
		.catch((err) => done(err));

	});<commit_msg>auth.register bugfix<commit_after>'use strict';
const Code = require('code');
const Hoek = require('hoek');
const Lab = require('lab');

// Internals
const Suite = require('../test/user.suite');
const Forger = require('forger');
const Sinon = require('sinon');

// Helpers
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const before = lab.before;
const beforeEach = lab.beforeEach;
const afterEach = lab.afterEach;
const after = lab.after;
const it = lab.it;
const expect = Code.expect;

before(Suite.setupServer);
before(Suite.db.connect);
after(Suite.db.dropDatabase);
after(Suite.db.disconnect);

describe('POST /auth/register', () => {

	beforeEach(Suite.db.resetDatabase);

	it('should reply successfully (200) with token', (done) => {
		Suite.server.inject({
			url: '/auth/register',
			method: 'POST',
			payload: {
				email: '<EMAIL>',
				displayName: 'IndieForger',
				password: '<PASSWORD>'
			}
		}, (res) => {
			expect(res.statusCode).to.equal(200);

			done();
		});
	});

	it('should reply with bad request (400) if payload is missing', (done) => {
		Suite.server.inject({
			url: '/auth/register',
			method: 'POST'
		}, (res) => {
			expect(res.statusCode).to.equal(400);
			done();
		});
	});

	it('should reply with bad request (400) if payload is partially missing', (done) => {
		const sendRequest = function ( payload, next ) {
			Suite.server.inject({ url: '/auth/register', method: 'POST', payload: payload }, (res) => {
				expect(res.statusCode).to.equal(400);
				next();
			});
		};

		Forger.sequence(
			(next) => { sendRequest( { /*email: '<EMAIL>',*/ displayName: 'IndieForger', password: '<PASSWORD>' }, next )},
			(next) => { sendRequest( { email: '<EMAIL>', /*displayName: 'IndieForger',*/ password: '<PASSWORD>' }, next )},
			(next) => { sendRequest( { email: '<EMAIL>', displayName: 'IndieForger'/*, password: '<PASSWORD>'*/ }, next )}
		)
		.then(() => done())
		.catch((err) => done(err));

	});
{'fraction_non_alphanumeric': 0.20428462127008415, 'fraction_numerical': 0.009181331293037491, 'mean_word_length': 4.073738680465718, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 43, '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': '356898', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1294, 'n_words': 309}