<commit_before>'use strict';
var chai = require('chai');
var should = chai.should();

var SignatureValidator = require('../lib/SignatureValidator');

describe('SignatureValidator', function() {
  var config = {
    channelID: '1441301333',
    channelSecret: 'testsecret',
    channelMID: 'u0a556cffd4da0dd89c94fb36e36e1cdc'
  };

  var json = {
    result: [
      {
        from: 'u206d25c2ea6bd87c17655609a1c37cb8',
        fromChannel: '1341301815',
        to: ['u0cc15697597f61dd8b01cea8b027050e'],
        toChannel: '1441301333',
        eventType: '138311609000106303',
        id: 'ABCDEF-12345678901',
        content: {
          id: '325708',
          createdTime: 1332394961610,
          from: 'uff2aec188e58752ee1fb0f9507c6529a',
          to: ['u0a556cffd4da0dd89c94fb36e36e1cdc'],
          toType: 1,
          contentType: 1,
          text: 'hello'
        }
      },
      {
        from: 'u206d25c2ea6bd87c17655609a1c37cb8',
        fromChannel: '1341301815',
        to: ['u0cc15697597f61dd8b01cea8b027050e'],
        toChannel: '1441301333',
        eventType: '138311609100106403',
        id: 'ABCDEF-12345678902',
        content: {
          revision: 2469,
          opType: 4,
          params: [
            'u0f3bfc598b061eba02183bfc5280886a',
            null,
            null
          ]
        }
      }
    ]
  };

  var signature = 'kPXp0nPWSzfWAapWHiesbcztpKnXJoX8krCa1CcTghk=';

  it('should be able to validate signature', function(done) {
    SignatureValidator.validateSignature(JSON.stringify(json), config.channelSecret, signature).should.be.true;
    SignatureValidator.validateSignature(JSON.stringify(json), config.channelSecret, 'XXX').should.be.false;

    done();
  });
});<commit_msg>fix tests<commit_after>'use strict';
var chai = require('chai');
var should = chai.should();

var SignatureValidator = require('../lib/SignatureValidator');

describe('SignatureValidator', function() {
  var config = {
    channelID: '1441301333',
    channelSecret: 'testsecret',
    channelMID: 'u0a556cffd4da0dd89c94fb36e36e1cdc'
  };
  var json = '{\n\
  "result":[\n\
    {\n\
      "from":"u206d25c2ea6bd87c17655609a1c37cb8",\n\
      "fromChannel":"1341301815",\n\
      "to":["u0cc15697597f61dd8b01cea8b027050e"],\n\
      "toChannel":"1441301333",\n\
      "eventType":"138311609000106303",\n\
      "id":"ABCDEF-12345678901",\n\
      "content":{\n\
        "id":"325708",\n\
        "createdTime":1332394961610,\n\
        "from":"uff2aec188e58752ee1fb0f9507c6529a",\n\
        "to":["u0a556cffd4da0dd89c94fb36e36e1cdc"],\n\
        "toType":1,\n\
        "contentType":1,\n\
        "text":"hello"\n\
      }\n\
    },\n\
    {\n\
      "from":"u206d25c2ea6bd87c17655609a1c37cb8",\n\
      "fromChannel":"1341301815",\n\
      "to":["u0cc15697597f61dd8b01cea8b027050e"],\n\
      "toChannel":"1441301333",\n\
      "eventType":"138311609100106403",\n\
      "id":"ABCDEF-12345678902",\n\
      "content":{\n\
        "revision":2469,\n\
        "opType":4,\n\
        "params":[\n\
          "u0f3bfc598b061eba02183bfc5280886a",\n\
          null,\n\
          null\n\
        ]\n\
      }\n\
    }\n\
  ]\n\
}';

  var signature = 'kPXp0nPWSzfWAapWHiesbcztpKnXJoX8krCa1CcTghk=';

  it('should be able to validate signature', function(done) {
    SignatureValidator.validateSignature(json, config.channelSecret, signature).should.be.true;
    SignatureValidator.validateSignature(json, config.channelSecret, 'XXX').should.be.false;
    done();
  });
});
{'fraction_non_alphanumeric': 0.1506849315068493, 'fraction_numerical': 0.16552511415525115, 'mean_word_length': 2.7326943556975505, 'pattern_counts': {'":': 25, '<': 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': '2244794', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1332, 'n_words': 167}