<commit_before>var assert = require('assert');
var request = require('supertest');
var app = request(require('../../'));

describe('GET /auth', function() {
  it('returns 401 for unauthenticated user', function(done) {
    app.get('/auth').expect(401).expect({authenticated: false}, done);
  });

  it('returns 200 for authenticated user');
});

describe('POST /auth/login/turbasen', function() {
  it('returns 400 for no email or password', function(done) {
    app.post('/auth/login/turbasen').expect(400).expect({
      message: 'The fields "email" and "password" are required'
    }, done);
  });

  it('returns 401 for invalid user credentials', function(done) {
    app.post('/auth/login/turbasen')
      .send({email: '<EMAIL>', password: '<PASSWORD>'})
      .expect(401)
      .expect({message: 'Invalid email or password'}, done)
  });

  it('returns 200 for valid user credentials', function(done) {
    this.timeout(5000);

    var email = process.env.NTB_USER_EMAIL;
    var pass = <PASSWORD>.NTB_USER_PASSWORD;

    app.post('/auth/login/turbasen')
      .send({email: email, password: pass})
      .expect(200)
      .expect({
        navn: '<NAME>',
        epost: email,
        gruppe: {
          _id: '52407f3c4ec4a138150001d7',
          navn: '<NAME>'
        }
      }, done)
  });
});<commit_msg>Test authenticated user details endpoint<commit_after>var assert = require('assert');
var request = require('supertest');
var app = request(require('../../'));

var auth = null;
var email = process.env.NTB_USER_EMAIL;
var pass = process.env.NTB_USER_PASSWORD;

before(function(done) {
  this.timeout(5000);

  app.post('/auth/login/turbasen')
    .send({email: email, password: <PASSWORD>})
    .expect(function(res) {
      auth = res.headers['set-cookie'][0].split(' ')[0];
    })
    .end(done);
});

describe('POST /auth/login/turbasen', function() {
  it('returns 400 for no email or password', function(done) {
    app.post('/auth/login/turbasen').expect(400).expect({
      message: 'The fields "email" and "password" are required'
    }, done);
  });

  it('returns 401 for invalid user credentials', function(done) {
    app.post('/auth/login/turbasen')
      .send({email: '<EMAIL>', password: '<PASSWORD>'})
      .expect(401)
      .expect({message: 'Invalid email or password'}, done)
  });

  it('returns 200 for valid user credentials', function(done) {
    this.timeout(5000);

    app.post('/auth/login/turbasen')
      .send({email: email, password: <PASSWORD>})
      .expect(200)
      .expect({
        navn: '<NAME>',
        epost: email,
        gruppe: {
          _id: '52407f3c4ec4a138150001d7',
          navn: 'Destinasjon Trysil'
        }
      }, done);
  });
});

describe.only('GET /auth', function() {
  it('returns 401 for unauthenticated user', function(done) {
    app.get('/auth').expect(401).expect({authenticated: false}, done);
  });

  it('returns 200 for authenticated user', function(done) {
    app.get('/auth')
      .set('cookie', auth)
      .expect(200)
      .expect({
        navn: '<NAME>',
        epost: email,
        gruppe: {
          _id: '52407f3c4ec4a138150001d7',
          navn: 'Destinasjon Trysil'
        }
      }, done);
  });
});
{'fraction_non_alphanumeric': 0.17800559179869524, 'fraction_numerical': 0.03883193538365952, 'mean_word_length': 3.060529634300126, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '5084521', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1047, 'n_words': 231}