<commit_before>var chai = require('chai');
var Strategy = require('../lib/strategy');

describe('Strategy', function() {
  describe('that encounters an error during verification', function() {
    var strategy = new Strategy(function(token, done) {
      return done(new Error('something went wrong'));
    });

    describe('handling a request', function() {
      var err;

      before(function(done) {
        chai.passport.use(strategy)
          .error(function(e) {
            err = e;
            done();
          })
          .req(function(req) {
            req.headers.authorization = 'Hmac bad_public_key:<KEY>';
          })
          .authenticate();
      });

      it('should error', function() {
        expect(err).to.be.an.instanceOf(Error);
        expect(err.message).to.equal('something went wrong');
      });
    });
  });
});<commit_msg>test for exception during verification<commit_after>var chai = require('chai');
var Strategy = require('../lib/strategy');

describe('Strategy', function() {
  describe('that encounters an error during verification', function() {
    var strategy = new Strategy(function(publicKey, done) {
      return done(new Error('something went wrong'));
    });

    var err;

    before(function(done) {
      chai.passport.use(strategy)
        .error(function(e) {
          err = e;
          done();
        })
        .req(function(req) {
          req.headers.authorization = 'Hmac bad_public_key:<KEY>';
        })
        .authenticate();
    });

    it('should error', function() {
      expect(err).to.be.an.instanceOf(Error);
      expect(err.message).to.equal('something went wrong');
    });
  });

  describe('that encounters an exception during verification', function() {
    var strategy = new Strategy(function(publicKey, done) {
      throw new Error('something went horribly wrong');
    });

    var err;

    before(function(done) {
      chai.passport.use(strategy)
        .error(function(e) {
          err = e;
          done();
        })
        .req(function(req) {
          req.headers.authorization = 'Hmac bad_public_key:<KEY>';
        })
        .authenticate();
    });

    it('should error', function() {
      expect(err).to.be.an.instanceOf(Error);
      expect(err.message).to.equal('something went horribly wrong');
    });
  });
});
{'fraction_non_alphanumeric': 0.15566037735849056, 'fraction_numerical': 0.0, 'mean_word_length': 2.4769001490312967, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5258102', 'n_tokens_mistral': 685, 'n_tokens_neox': 660, 'n_words': 137}