<commit_before>var request = require('supertest'),
  should = require('should');

describe('Authentication', function() {
  var session;
  beforeEach(function(done) {
    app.request.session = new app.session();
    session = app.request.session;
    session.logged_in.should.be.true;
    session.passport.should.be.an.Object;
    done();
  });

  it('should display name and logout link if user is logged in',
      function(done) {
    request(app)
      .get('/')
      .expect(200)
      .end(function (err, res) {
        if (err) return done(err);
        res.text.should.include('Testing Tester');
        res.text.should.include('logout');
        res.text.should.not.include('login');
        done();
    });
  });

  it('should log the user out', function(done) {
    request(app)
      .get('/logout')
      .end(function (err, res) {
        if (err) return done(err);
        // Follow redirect
        request(app)
          .get('/')
          .end(function (err, res) {
            if (err) return done(err);
            res.text.should.not.include('Testing Tester');
            res.text.should.include('login');
            session.logged_in.should.be.false;
            session.passport.should.be.null;
            done();
          });
      });
  });

  // TODO: Move this to an ACL Test
  it('should do something on the admin page', function(done) {
    request(app)
      .get('/admin')
      .expect(200)
      .end(function(err, res) {
        if (err) return done(err);
        res.text.should.include('Administration Portals');
        done();
    });
  });

  // TODO: Move this to an ACL Test
  it('should not let someone access an admin page if not logged in',
  function(done) {
    request(app)
      .get('/logout')
      .end(function(err, res) {
        if (err) return done(err);
        request(app)
          .get('/admin')
          .end(function(err, res) {
            if (err) return done(err);
            session.logged_in.should.be.false;
            res.text.should.not.include('Administration Portals');
            res.text.should.not.include('Testing Tester');
            done();
          });
      });
  });
});<commit_msg>Added a check for a flashed message in auth test.<commit_after>var request = require('supertest'),
  should = require('should');

describe('Authentication', function() {
  var session;
  beforeEach(function(done) {
    app.request.session = new app.session();
    session = app.request.session;
    session.logged_in.should.be.true;
    session.passport.should.be.an.Object;
    done();
  });

  it('should display user\'s name and logout link if user is logged in',
      function(done) {
    request(app)
      .get('/')
      .expect(200)
      .end(function (err, res) {
        if (err) return done(err);
        res.text.should.include('Testing Tester');
        res.text.should.include('logout');
        res.text.should.not.include('login');
        done();
    });
  });

  it('should log the user out', function(done) {
    request(app)
      .get('/logout')
      .end(function (err, res) {
        if (err) return done(err);
        // Follow redirect
        request(app)
          .get('/')
          .end(function (err, res) {
            if (err) return done(err);
            res.text.should.not.include('Testing Tester');
            res.text.should.not.include('logout');
            res.text.should.include('login');
            session.logged_in.should.be.false;
            session.passport.should.be.null;
            done();
          });
      });
  });

  // TODO: Move this to an ACL Test
  it('should do something on the admin page', function(done) {
    request(app)
      .get('/admin')
      .expect(200)
      .end(function(err, res) {
        if (err) return done(err);
        res.text.should.include('Administration Portals');
        done();
    });
  });

  // TODO: Move this to an ACL Test
  it('should not let someone access an admin page if not logged in',
  function(done) {
    request(app)
      .get('/logout')
      .end(function(err, res) {
        if (err) return done(err);
        request(app)
          .get('/admin')
          .end(function(err, res) {
            if (err) return done(err);
            session.logged_in.should.be.false;
            res.text.should.not.include('Administration Portals');
            res.text.should.not.include('Testing Tester');
            // Validate that an error message was flashed.
            request(app)
              .get('/')
              .end(function(err, res) {
                res.text.should.include('You should be logged in...');
                done();
              })
          });
      });
  });
});
{'fraction_non_alphanumeric': 0.1536819637139808, 'fraction_numerical': 0.0025613660618996796, 'mean_word_length': 1.9942492012779554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '801769', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1389, 'n_words': 319}