B2G/gecko/toolkit/components/url-classifier/tests/unit/test_streamupdater.js
// Test an update with a valid message authentication code, with forwards.
Test an update with a valid message authentication code, with forwards.
Test an update with a valid message authentication code with forwards .
function testValidForwardMAC() {
  var add1Urls = [ "foo.com/a", "bar.com/c" ];
  var add2Urls = [ "foo.com/b" ];
  var add3Urls = [ "bar.com/d" ];
  var update = "n:1000\n";
  update += "i:test-phish-simple\n";
  var update1 = buildBareUpdate(
    [{ "chunkNum" : 1,
       "urls" : add1Urls }]);
  update += "u:data:," + encodeURIComponent(update1) +
    "," + MAC(update1, gClientKeyRaw) + "\n";
  var update2 = buildBareUpdate(
    [{ "chunkNum" : 2,
       "urls" : add2Urls }]);
  update += "u:data:," + encodeURIComponent(update2) +
    "," + MAC(update2, gClientKeyRaw) + "\n";
  var update3 = buildBareUpdate(
    [{ "chunkNum" : 3,
       "urls" : add3Urls }]);
  update += "u:data:," + encodeURIComponent(update3) +
    "," + MAC(update3, gClientKeyRaw) + "\n";
  var assertions = {
    "tableData" : "test-phish-simple;a:1-3",
    "urlsExist" : add1Urls.concat(add2Urls).concat(add3Urls)
  };
  update = "m:" + MAC(update, gClientKeyRaw) + "\n" + update;
  doTest([update], assertions, false, gClientKey);
}
function testValidForwardMAC ( ) { var add1Urls = [ "foo.com/a" , "bar.com/c" ] ; var add2Urls = [ "foo.com/b" ] ; var add3Urls = [ "bar.com/d" ] ; var update = "n:1000\n" ; update += "i:test-phish-simple\n" ; var update1 = buildBareUpdate ( [ { "chunkNum" : 1 , "urls" : add1Urls } ] ) ; update += "u:data:," + encodeURIComponent ( update1 ) + "," + MAC ( update1 , gClientKeyRaw ) + "\n" ; var update2 = buildBareUpdate ( [ { "chunkNum" : 2 , "urls" : add2Urls } ] ) ; update += "u:data:," + encodeURIComponent ( update2 ) + "," + MAC ( update2 , gClientKeyRaw ) + "\n" ; var update3 = buildBareUpdate ( [ { "chunkNum" : 3 , "urls" : add3Urls } ] ) ; update += "u:data:," + encodeURIComponent ( update3 ) + "," + MAC ( update3 , gClientKeyRaw ) + "\n" ; var assertions = { "tableData" : "test-phish-simple;a:1-3" , "urlsExist" : add1Urls . concat ( add2Urls ) . concat ( add3Urls ) } ; update = "m:" + MAC ( update , gClientKeyRaw ) + "\n" + update ; doTest ( [ update ] , assertions , false , gClientKey ) ; }
Test an update with a valid message authentication code, with forwards.
Test an update with a valid message authentication code with forwards .