<commit_before>var chai = require("chai");
var expect = chai.expect; 
var assert = chai.assert;
var hasher = require("../src/hash.js");
var rsa = require("./../src/rsa.js");
var packer = require("./../src/packer.js");
var Base64 = require("./../src/Base64.js");

var DataPacker = packer.DataPacker;
var AuthKeyPacker = packer.AuthKeyPacker;


const AES_KEY = "put any valid aes_key there";

describe("Packer", function(){

	describe("DataPacker", function() {

		describe("constructor(aesKey)", function() {
			
			it("Should create AES packer wich can pack and unpack data with given aesKey.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				expect(dataPacker).to.have.property("aesKey", AES_KEY);
			});
		});

		describe("pack(data)", function() {
			
			it("Should return packed(compressed and encrypted) data as base64 string.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var packedData = dataPacker.pack({key : "value", array: [1, 2]});

				assert.match(packedData, /^([0-9A-Za-z])+$/g, "packed data is not in base64");
			});

			it("Should return packet containing 'data' and 'hash' fields.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var packet = dataPacker.pack({key : "value", array: [1, 2]});
				var decodedPack = JSON.parse(Base64.decode(packet));

				expect(decodedPack).to.have.property("data");
				expect(decodedPack).to.have.property("hash", hasher.hash(decodedPack.data));
			});
		});

		describe("unpack(rawData)", function() {
			
			it("Should return initial object that had been packed by the same aes_key.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var data = {name:"Alik", Surname: "Khilazhev", courses:["IT", "TCS", "OS", "MPP", "CA"]};
				var packedData = dataPacker.pack(data);
				expect(dataPacker.unpack(packedData)).to.be.equal(data);
			});
		});
	});

	describe("AuthKeyPacker", function() {
<commit_msg>Updates packer-tests.js<commit_after>var chai = require("chai");
var expect = chai.expect; 
var assert = chai.assert;
var hasher = require("../src/hash.js");
var rsa = require("./../src/rsa.js");
var packer = require("./../src/packer.js");
var Base64 = require("./../src/Base64.js");

var DataPacker = packer.DataPacker;
var AuthKeyPacker = packer.AuthKeyPacker;


const AES_KEY = "put any valid aes_key there";

describe("Packer", function(){

	describe("DataPacker", function() {

		describe("constructor(aesKey)", function() {
			
			it("Should create AES packer wich can pack and unpack data with given aesKey.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				expect(dataPacker).to.have.property("aesKey", AES_KEY);
			});
		});

		describe("pack(data)", function() {
			
			it("Should return packed(compressed and encrypted) data as base64 string.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var packedData = dataPacker.pack({key : "value", array: [1, 2]});

				assert.match(packedData, /^([0-9A-Za-z/+//])+$/g, "packed data is not in base64");
			});

			it("Should return packet containing 'data' and 'hash' fields.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var packet = dataPacker.pack({key : "value", array: [1, 2]});
				var decodedPack = JSON.parse(Base64.decode(packet));

				expect(decodedPack).to.have.property("data");
				expect(decodedPack).to.have.property("hash", hasher.hash(decodedPack.data));
			});
		});

		describe("unpack(rawData)", function() {
			
			it("Should return initial object that had been packed by the same aes_key.", function() {
				var dataPacker = new DataPacker(AES_KEY);
				var data = {name:"Alik", Surname: "Khilazhev", courses:["IT", "TCS", "OS", "MPP", "CA"]};
				var packedData = dataPacker.pack(data);
				expect(dataPacker.unpack(packedData)).to.be.equal(data);
			});
		});
	});

	describe("AuthKeyPacker", function() {

{'fraction_non_alphanumeric': 0.1779045643153527, 'fraction_numerical': 0.008298755186721992, 'mean_word_length': 4.163319946452477, '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': '2445415', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1277, 'n_words': 305}