<commit_before>describe('Resource /auth', function () {

  var savedFirstAccount,

    firstAccount = {
      name: 'Prateek',
      email: '<EMAIL>',
      password: '<PASSWORD>'
    };

  before(function (done) {

    request
      .post('/accounts')
      .send(firstAccount)
      .expect(function (res) {
        savedFirstAccount = res.body;
      })
      .end(done);

  });

  after(function (done) {
    dropTestDb(done);
  });

  describe('POST /auth/login', function () {

    it('authenticates user with correct credentials',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: firstAccount.email,
            password: <PASSWORD>
          })
          .expect('Content-Type', /json/)
          .expect(200)
          .expect({
            status: 200,
            message: "Logged In Successfully"
          })
          .end(done);
      });

    it('returns error with incorrect email',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: 'randomemail',
            password: '<PASSWORD>'
          })
          .expect('Content-Type', /json/)
          .expect(403)
          .expect({
            status: 403,
            error: "Invalid Email/Password"
          })
          .end(done);
      });

    it('returns error with incorrect password',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: firstAccount.email,
            password: '<PASSWORD>'
          })
          .expect('Content-Type', /json/)
          .expect(403)
          .expect({
            status: 403,
            error: "Invalid Email/Password"
          })
          .end(done);
      });

  });

  describe('POST /auth/logout', function () {

    it('login', function () {
      loginUser({
        email: firstAccount.email,
        password: <PASSWORD>
      })
    });

    it('logs out user',
      function (done) {
        request
          .post('/auth/logout')
          .expect('Content-Type', /json/)
          .expect(200)
          .expect({
            status: 200,
            message: "Logged Out Successfully"
          })
          .end(done);
      });

  });

});
<commit_msg>api: when trying to login using wrong credentials send 401 (unauthorized) error instead of 403 (forbidden) error<commit_after>describe('Resource /auth', function () {

  var savedFirstAccount,

    firstAccount = {
      name: 'Prateek',
      email: '<EMAIL>',
      password: '<PASSWORD>'
    };

  before(function (done) {

    request
      .post('/accounts')
      .send(firstAccount)
      .expect(function (res) {
        savedFirstAccount = res.body;
      })
      .end(done);

  });

  after(function (done) {
    dropTestDb(done);
  });

  describe('POST /auth/login', function () {

    it('authenticates user with correct credentials',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: firstAccount.email,
            password: <PASSWORD>
          })
          .expect('Content-Type', /json/)
          .expect(200)
          .expect({
            message: "Logged In Successfully"
          })
          .end(done);
      });

    it('returns error with incorrect email',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: 'randomemail',
            password: '<PASSWORD>'
          })
          .expect('Content-Type', /json/)
          .expect(401)
          .expect({
            status: 401,
            error: "Invalid Email/Password"
          })
          .end(done);
      });

    it('returns error with incorrect password',
      function (done) {
        request
          .post('/auth/login')
          .send({
            email: firstAccount.email,
            password: '<PASSWORD>'
          })
          .expect('Content-Type', /json/)
          .expect(401)
          .expect({
            status: 401,
            error: "Invalid Email/Password"
          })
          .end(done);
      });

  });

  describe('POST /auth/logout', function () {

    it('login', function () {
      loginUser({
        email: firstAccount.email,
        password: <PASSWORD>
      })
    });

    it('logs out user',
      function (done) {
        request
          .post('/auth/logout')
          .expect('Content-Type', /json/)
          .expect(200)
          .expect({
            message: "Logged Out Successfully"
          })
          .end(done);
      });

  });

});

{'fraction_non_alphanumeric': 0.1446706062595754, 'fraction_numerical': 0.010505581089954037, 'mean_word_length': 1.4662709120345385, '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': '822218', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1248, 'n_words': 270}