[Pkg-mozext-commits] [perspectives-extension] 37/72: Merge branch 'master' of https://github.com/lambdor/Perspectives into lambdor-pr-124
David Prévot
taffit at moszumanska.debian.org
Thu Dec 11 02:12:49 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository perspectives-extension.
commit b953b952db1a144592b4b83f8ac08e9e1e9512f4
Merge: 87227a2 01564ab
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date: Wed Oct 22 22:23:46 2014 -0600
Merge branch 'master' of https://github.com/lambdor/Perspectives into lambdor-pr-124
Conflicts manually merged:
- statusbar.xul
- preferences_dialog.xul
- test.html - new format with added call to hash tests from HEAD code
- notaries.js - merge in HEAD md5 handling with external library
README | 56 -
README.md | 69 +
plugin/chrome/content/about.js | 12 +-
plugin/chrome/content/base64.js | 168 ---
plugin/chrome/content/client_policy.js | 378 +++---
plugin/chrome/content/common.js | 265 ++--
plugin/chrome/content/css/preferences_dialog.css | 5 +
plugin/chrome/content/generate_svg.js | 308 +++--
plugin/chrome/content/notaries.js | 1117 ++++++++--------
plugin/chrome/content/notify.js | 185 +--
plugin/chrome/content/preferences_dialog.js | 180 ++-
plugin/chrome/content/preferences_dialog.xul | 359 ++---
plugin/chrome/content/results_dialog.js | 57 +-
plugin/chrome/content/statusbar.js | 82 +-
plugin/chrome/content/statusbar.xul | 80 +-
plugin/chrome/content/whitelist_dialog.js | 165 +--
plugin/chrome/content/xml_notary_client.js | 175 +--
plugin/chrome/locale/de/amodetails.properties | 5 +-
plugin/chrome/locale/de/dialogs.dtd | 26 +-
plugin/chrome/locale/de/help.dtd | 14 +-
plugin/chrome/locale/de/notaries.properties | 59 +-
plugin/chrome/locale/de/results.properties | 1 +
plugin/chrome/locale/en-US/dialogs.dtd | 13 +-
plugin/chrome/locale/en-US/notaries.properties | 72 +-
plugin/chrome/locale/en-US/results.properties | 1 +
plugin/chrome/locale/es-MX/dialogs.dtd | 19 +-
plugin/chrome/locale/es-MX/notaries.properties | 28 +-
plugin/chrome/locale/es-MX/results.properties | 4 +-
plugin/chrome/locale/fi/dialogs.dtd | 19 +-
plugin/chrome/locale/fi/notaries.properties | 28 +-
plugin/chrome/locale/fi/results.properties | 2 +
plugin/chrome/locale/fr/dialogs.dtd | 19 +-
plugin/chrome/locale/fr/notaries.properties | 26 +-
plugin/chrome/locale/fr/results.properties | 2 +
plugin/chrome/locale/nl/dialogs.dtd | 16 +-
plugin/chrome/locale/nl/notaries.properties | 26 +-
plugin/chrome/locale/nl/results.properties | 2 +
plugin/chrome/locale/pl/dialogs.dtd | 21 +-
plugin/chrome/locale/pl/notaries.properties | 26 +-
plugin/chrome/locale/pl/results.properties | 2 +
plugin/chrome/locale/zh-CN/dialogs.dtd | 19 +-
plugin/chrome/locale/zh-CN/notaries.properties | 28 +-
plugin/chrome/locale/zh-CN/results.properties | 2 +
plugin/defaults/preferences/prefs.js | 23 +-
test/svg_test.html | 152 ++-
test/test.html | 1535 +++++++++++-----------
46 files changed, 3236 insertions(+), 2615 deletions(-)
diff --cc plugin/chrome/content/notaries.js
index d0fba73,7341178..41d15b5
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@@ -452,26 -479,19 +488,26 @@@ var Perspectives =
Perspectives.strbundle = document.getElementById("notary_strings");
}
- var server_result_list = ti.partial_query_results;
- delete ti.partial_query_results;
- delete ti.timeout_id;
+ var server_result_list = ti.partial_query_results;
+ delete ti.partial_query_results;
+ delete ti.timeout_id;
+
+ var test_key;
+ if (ti.cert["md5Fingerprint"] !== undefined) {
+ test_key = ti.cert.md5Fingerprint.toLowerCase();
+ }
+ else {
+ test_key = this.calculateMD5(ti.cert.getRawDER({}));
+ }
+
- var test_key = ti.cert.md5Fingerprint.toLowerCase();
// 2 days (FIXME: make this a pref)
- var max_stale_sec = 2 * 24 * 3600;
+ var max_stale_sec = 2 * 24 * 3600;
var q_required = Perspectives.getQuorumAsInt();
- var unixtime = Pers_util.get_unix_time();
- var quorum_duration = Pers_client_policy.get_quorum_duration(test_key,
- server_result_list, q_required, max_stale_sec,unixtime);
- var is_cur_consistent = quorum_duration != -1;
-
-
+ var unixtime = Pers_util.get_unix_time();
+ var quorum_duration = Pers_client_policy.get_quorum_duration(test_key,
+ server_result_list, q_required, max_stale_sec,unixtime);
+ var is_cur_consistent = quorum_duration !== -1;
+
var weak_check_time_limit = Perspectives.root_prefs.
getIntPref("perspectives.weak_consistency_time_limit");
var inconsistent_check_max = Perspectives.root_prefs.
@@@ -579,15 -603,8 +619,16 @@@
ti.reason_str = text;
return;
}
+
+ var md5;
+ if (ti.cert["md5Fingerprint"] !== undefined) {
+ // use the built-in browser hash if available
+ md5 = ti.cert.md5Fingerprint.toLowerCase();
+ }
+ else {
+ md5 = this.calculateMD5(ti.cert.getRawDER({}));
+ }
+
- var md5 = ti.cert.md5Fingerprint.toLowerCase();
ti.state = ti.browser.securityUI.state;
ti.is_override_cert = Perspectives.overrideService.isCertUsedForOverrides(ti.cert, true, true);
diff --cc plugin/chrome/content/statusbar.xul
index 628c461,080a392..cd3532d
--- a/plugin/chrome/content/statusbar.xul
+++ b/plugin/chrome/content/statusbar.xul
@@@ -6,20 -6,17 +6,19 @@@
<stringbundleset id="stringbundleset">
<stringbundle id="notary_strings" src="chrome://perspectives/locale/notaries.properties" insertbefore="1"/>
- </stringbundleset>
+ </stringbundleset>
+ <script type="application/x-javascript" src="extlib/spark-md5.min.js"/>
+
- <script type="application/x-javascript" src="base64.js"/>
+ <script type="application/x-javascript" src="client_policy.js"/>
<script type="application/x-javascript" src="common.js"/>
- <script type="application/x-javascript" src="client_policy.js" />
- <script type="application/x-javascript" src="xml_notary_client.js" />
- <script type="application/x-javascript" src="generate_svg.js" />
- <script type="application/x-javascript" src="notify.js" />
- <script type="application/x-javascript" src="notaries.js" />
- <script type="application/x-javascript" src="report.js" />
- <script type="application/x-javascript" src="whitelist_dialog.js"/>
+ <script type="application/x-javascript" src="generate_svg.js"/>
+ <script type="application/x-javascript" src="notaries.js"/>
+ <script type="application/x-javascript" src="notify.js"/>
+ <script type="application/x-javascript" src="report.js"/>
<script type="application/x-javascript" src="statusbar.js"/>
+ <script type="application/x-javascript" src="whitelist_dialog.js"/>
+ <script type="application/x-javascript" src="xml_notary_client.js"/>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton class="perspective-status"
diff --cc test/test.html
index 522aec6,4b0ce66..e540e8d
--- a/test/test.html
+++ b/test/test.html
@@@ -5,26 -5,74 +5,76 @@@
<title>Perspectives - Test cases</title>
<!-- Include every file so we can verify that all of the objects are testable in meta_test() -->
+<script type="text/javascript" src="../extlib/spark-md5.min.js"></script>
+
- <script type="text/javascript" src="../about.js"></script>
- <script type="text/javascript" src="../base64.js"></script>
- <script type="text/javascript" src="../client_policy.js"></script>
- <script type="text/javascript" src="../common.js"></script>
- <script type="text/javascript" src="../generate_svg.js"></script>
- <script type="text/javascript" src="../notaries.js"></script>
- <script type="text/javascript" src="../notify.js"></script>
+ <script type="text/javascript" src="../about.js" ></script>
+ <script type="text/javascript" src="../client_policy.js" ></script>
+ <script type="text/javascript" src="../common.js" ></script>
+ <script type="text/javascript" src="../generate_svg.js" ></script>
+ <script type="text/javascript" src="../notaries.js" ></script>
+ <script type="text/javascript" src="../notify.js" ></script>
<script type="text/javascript" src="../preferences_dialog.js"></script>
- <script type="text/javascript" src="../report.js"></script>
- <script type="text/javascript" src="../results_dialog.js"></script>
- <script type="text/javascript" src="../statusbar.js"></script>
- <script type="text/javascript" src="../whitelist_dialog.js"></script>
- <script type="text/javascript" src="../xml_notary_client.js"></script>
-
- <script type="text/javascript">
+ <script type="text/javascript" src="../report.js" ></script>
+ <script type="text/javascript" src="../results_dialog.js" ></script>
+ <script type="text/javascript" src="../statusbar.js" ></script>
+ <script type="text/javascript" src="../whitelist_dialog.js" ></script>
+ <script type="text/javascript" src="../xml_notary_client.js" ></script>
+
+ <!-- Also include every file for testing in browser (no chrome privileges) and fake some functions -->
+ <script type="text/javascript">
+ // if on browser fake objects and make at least some tests work
+ if( typeof Components.classes === "undefined") {
+ Perspectives =
+ { root_prefs :
+ { getIntPref : function(key) { return Perspectives.root_prefs[key]; }
+ , getCharPref : function(key) { return Perspectives.root_prefs[key]; }
+ , getBoolPref : function(key) { return Perspectives.root_prefs[key]; }
+ , setIntPref : function(key, value) { Perspectives.root_prefs[key] = value; }
+ , setCharPref : function(key, value) { Perspectives.root_prefs[key] = value; }
+ , setBoolPref : function(key, value) { Perspectives.root_prefs[key] = value; }
+ }
+ , getNotaryList: function() {
+ return [
+ {"host": "heimdal.herokuapp.com:80" , "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAGhzbwVcnEaT2Hb9WD9Wvh9CVYu86w+8ZMdO4KG506K77IsERfIuh84YkE4qoDnjfR7TCQBvreVl81lIh5UE0kzO84X673risoBebbGCNjXQNu5mWkq2Qp7SuuemeXaYFmkpc06t2n6NvNcS9JVm8KJRqBKqlwqlFgDuDZPUcYmWoIL4sF9w/3ep9nPSIJYburTdpCaeXPGhMiMzh4E2GnJc3Y2beezGWtciXUCAwEAAQ=="},
+ {"host": "nine-eyes.herokuapp.com:80" , "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAEw+W1dv0a00gzVqvHa8SafHhpYESsCIB8kj4bb1ccXr7u6vaiBN83ssaPi1N/ZNDlyOnqZwopoZGkgzUxMUNzg9P6Vph9l7ldMu8XGuwmFoHBgEys633EPcrJcs46lfvNz5JRrYnjh0WMkj0VXvVlYla2g6aAA80+C7u56D2FodNxWscPNpQWUAHDJOnAWr1CI9CNU/rbl5c85KJ7cW6u+LFBmpXk2xzJ2tq8CAwEAAQ=="},
+ {"host": "perspectives2.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAHB9gHj3Zyx7u++wTffAsEuRJdjCZSFocs5ZKVamm6O7ywtFCuPgxxYTr3GyrDKj2IBO05iXirOISyX0OtENvs829XjTbKqDgeN1ttDiJmszN939RvBdmzkmXi2zaOXPX3ral56hJOWjOs6NokeBo26ZHux5k9g3AqFer5LNyDVgGrG5q7+INGodDSTYm2W5nvmi55U/pe7MmJCH7EEY1ObGPr17XqZeEbL4ikCAwEAAQ=="},
+ {"host": "perspectives3.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAFTgU6nDuhi9TDkzypfgaW2ztQbc9eFlVTiLfUkUCmrfn8FqNzxuYdl/Hin3/Usz443GAvOwx0pXocClZ7Xtve06w6HxtuWMxAR0VMhywdzotTJAb/4a2btqHdrUlOZg6l7R66GbCupVWwyDQF7YBKarEGF2v6mRM/WknwaEYVOMu7XDb6zkEf4MsxptQnY7PfNktMMcuhusYjko3IhFmlUl4lue+c3aFR35Y8CAwEAAQ=="},
+ {"host": "perspectives4.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAFiENC/BwZXOfzDOed4Qbvjd/25MixlCMlRUlfArJAvcjeBRmnY4fdQhi7/VH1qZeTQClegX1FMcuOORD29a4lks12WiXrh1HxLKxCTkPp5ZLqP8OiNxWqHdEQyinh2ulYFXZHWMlXhlsQKV2T7VsmfS0rLeukQAWpgGTXhACyZNpOQgjMm1vWEFaIsd2tT59Son7vxyCcaBoFCWv+zRW6kwaoKi0KgnEHwKwcCAwEAAQ=="},
+ {"host": "perspectives5.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAGvUdk9PffzqgvXs31Z6Okf8llXat4IK/YuB7QA/JiJ0BZaNIQS+7ndtAJjNesfCC8ktjshOafGLitsc4DsPCjj/7wweV0RNABHHTbE+ObkmoZBlE9RXU5v1gMFVJOQtWZRz3MrNCg/zq93tdo0+SJLqnCy7endY6z1k+3Z9HNSU5bA5e/Er8jE/4IbL0zWhZgWTZcISH5ZuJICUN72Ag4u7yL3poPv+zdl86UCAwEAAQ=="},
+ {"host": "perspectives6.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAGgQqPeMH0hYpJqSfsOPkJfZqQ731cYf/yvi54Zlux0S42aUu947T+d7GkH1SF25BAOK9suPfhPq7DKCvZ9MTOyNPlxpb6q82EgKV7LkqRfbBU6G5Xu8vN6Auif/gc4OYunCzru/ZKYM6Inp7tkl60/uEcsoHQtQMDguJEiuDuTFmkhOF6HsM4GAa2Wji612U0bB3hcjpJNQ0L3CWrWQNjpZAoS7ONaLk8IP9kCAwEAAQ=="},
+ {"host": "perspectives7.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAFndaQshFiJmW9FDgmGQ8SgVs/5F8e1LQAyTyt2iW9J1Kavu2hisFhIShU2rOkv0w3j9JanO+FbaA0vrqoWN0dnwRpc41JQtjzhNZgE0j78w4nu5lxwMiJ16OlZh7p6L/hoZsDGNYrtGIEm4w8NurncFlAQ5JZPmcbhKkXikVjYi/sNM5G2osRxAZjimscvDpLqWxzDjLv4VpbXXMGY1WsvQwca/ScQhTV/uu0CAwEAAQ=="},
+ {"host": "perspectives8.networknotary.org:8080", "public_key": "MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAHrtkVD3O4XCkOdFwMqlEDVYTW6W82QQomSb9Pa/OGeRvbupk/d1iNNbBAs7B2Irg3Xk+OValBf29cUwXsYbpm3lEKGOqVhwas7YaHz4cnztkQJ5N+fW2eGe7iD1k1/wB7aPECPYVQgXOSpYcmg4999JGxjPE6LWmIu3KQfk1YtZBjGOI9Sa5wNhECvVoIMYGH1oG+oXkACpd6AgUJMfIOdG7BkwW9YFRKHPJkCAwEAAQ=="}
+ ];
+ }, getQuorumAsInt: function() { return 7; }
+ };
+
+ pref = function(key, value) {
+ console.log(key + ": " + value);
+ };
+
+ Pers_pref = null;
+ Pers_results = null;
+ Pers_whitelist_dialog = null;
+ }
+ </script>
+ <script type="text/javascript" src="../plugin/defaults/preferences/prefs.js" ></script>
+ <script type="text/javascript" src="../plugin/chrome/content/about.js" ></script>
+ <script type="text/javascript" src="../plugin/chrome/content/client_policy.js" ></script>
+ <script type="text/javascript" src="../plugin/chrome/content/common.js" ></script>
+ <script type="text/javascript" src="../plugin/chrome/content/generate_svg.js" ></script>
+ <!--<script type="text/javascript" src="../plugin/chrome/content/notaries.js" ></script>-->
+ <script type="text/javascript" src="../plugin/chrome/content/notify.js" ></script>
+ <!--<script type="text/javascript" src="../plugin/chrome/content/preferences_dialog.js"></script>-->
+ <script type="text/javascript" src="../plugin/chrome/content/report.js" ></script>
+ <!--<script type="text/javascript" src="../plugin/chrome/content/results_dialog.js" ></script>-->
+ <script type="text/javascript" src="../plugin/chrome/content/statusbar.js" ></script>
+ <!--<script type="text/javascript" src="../plugin/chrome/content/whitelist_dialog.js" ></script>-->
+ <script type="text/javascript" src="../plugin/chrome/content/xml_notary_client.js" ></script>
+
+ <script type="text/javascript">
d_print_all = true;
- other_cache = { "debug" : "" }; // needed for common.js
+ other_cache = { "debug": "" }; // needed for common.js
var g_test_count = 0;
var g_pass_count = 0;
@@@ -93,26 -139,22 +141,23 @@@ function spacer(category_name)
// if you're lazy and want to print some text while debugging
function debug(obj) {
- if(obj == null) {
- return;
- }
+
- if (obj === null || obj === undefined) {
++ if (obj === null || typeof obj === "undefined") {
+ return;
+ }
- if (obj instanceof Array) {
- deb_console("array contains:");
- for (var i = 0; i < obj.length; i++) {
- deb_console(obj[i]);
+ if(obj instanceof Array) {
+ deb_console("array contains:");
+ for(var i = 0; i < obj.length; i++) {
+ deb_console(obj[i]);
+ }
+ }
+ else {
+ deb_console(obj);
}
- }
- else {
- deb_console(obj);
- }
-
- obj = JSON.stringify(obj);
- // strip out < so strings always appear on the page
- write_string_to_element("<font color='grey'>DEBUG: " +
- obj.replace(/</g, '<') + "</font>", 'li');
+ // strip out < so strings always appear on the page
+ write_string_to_element('<span style="color: grey">DEBUG: ' + JSON.stringify(obj).replace(/</g, '<') + '</span>', 'li');
}
function deb_console(obj) {
@@@ -124,119 -166,111 +169,123 @@@
/******* Tests *******/
function meta_tests() {
+ // make sure we can include and parse every object
+ // so we'll be able to run tests on them.
+ // if you add objects, add a test here
+
+ write_string("Starting object creation tests");
+
+ var objs =
+ [ "Pers_about"
+ , "Pers_client_policy"
+ , "Pers_debug"
+ , "Pers_util"
+ , "Pers_keypress"
+ , "Pers_gen"
+ , "Perspectives"
+ , "Pers_notify"
+ , "Pers_pref"
+ , "Pers_report"
+ , "Pers_results"
+ , "Pers_statusbar"
+ , "Pers_whitelist_dialog"
+ , "Pers_xml"
+ ];
+
+ for(var i = 0; i < objs.length; i++) {
+ var key = objs[i];
+ var type = typeof window[key];
+ assert(type === 'object', key + " is type '" + type + "'.");
+ }
- // make sure we can include and parse every object
- // so we'll be able to run tests on them.
- // if you add objects, add a test here
-
- write_string("Starting object creation tests");
-
- assert(typeof Pers_about === 'object', "Pers_about is type '" + typeof Pers_about + "'."); //about.js
- assert(typeof Pers_Base64 === 'object', "Pers_Base64 is type '" + typeof Pers_Base64 + "'.");
- assert(typeof Pers_client_policy === 'object', "Pers_client_policy is type '" + typeof Pers_client_policy + "'."); //client_policy.js
- assert(typeof Pers_debug === 'object', "Pers_debug is type '" + typeof Pers_debug + "'."); //common.js
- assert(typeof Pers_util === 'object', "Pers_util is type '" + typeof Pers_util + "'.");
- assert(typeof Pers_keypress === 'object', "Pers_keypress is type '" + typeof Pers_keypress + "'.");
- assert(typeof Pers_gen === 'object', "Pers_gen is type '" + typeof Pers_gen + "'."); //generate_svg.js
- assert(typeof Perspectives === 'object', "Perspectives is type '" + typeof Perspectives + "'."); //notaries.js
- assert(typeof Pers_notify === 'object', "Pers_notify is type '" + typeof Pers_notify + "'."); //notify.js
- assert(typeof Pers_pref === 'object', "Pers_pref is type '" + typeof Pers_pref + "'."); //preferences_dialog.js FIXME
- assert(typeof Pers_report === 'object', "Pers_report is type '" + typeof Pers_report + "'."); //report.js
- assert(typeof Pers_results === 'object', "Pers_results is type '" + typeof Pers_results + "'."); //results_dialog.js FIXME
- assert(typeof Pers_statusbar === 'object', "Pers_statusbar is type '" + typeof Pers_statusbar + "'."); //statusbar.js
- assert(typeof Pers_whitelist_dialog === 'object', "Pers_whitelist_dialog is type '" + typeof Pers_whitelist_dialog + "'."); //whitelist_dialog.js FIXME
- assert(typeof Pers_xml === 'object', "Pers_xml is type '" + typeof Pers_xml + "'."); //xml_notary_client.js
-
- write_string("Finished");
+ write_string("Finished");
}
+function hash_tests() {
+
+ write_string("Starting hash tests");
+
+ var known_md5_hash = "ffe5f73de2828ae744f3b126a7744fc3"; // verified independently with three external MD5 calculators
+ var md5_test_string = "This is the Perspectives project browser extension MD5 test";
+ var md5_hash = SparkMD5.hash(md5_test_string);
+ assert((md5_hash === known_md5_hash), "MD5 hash of test string: " + known_md5_hash);
+
+ write_string("Finished");
+}
+
function client_sanity() {
- write_string("Starting client policy unit tests...");
-
- var key = "b1:7f:b1:15:25:4e:7b:fb:93:83:ac:5c:26:df:f7:00";
- var curtime = Pers_util.get_unix_time();
- var short_start = curtime - 1;
- var short_end = curtime;
- var short_result_list = [
- { "server" : "test1:8080",
- "obs" : [ { "key" : key,
- "timestamps" : [ { "start" : short_start , "end" : short_end } ] } ]
- }
- ];
-
- var days_last_seen = 3;
- var duration = 2; // days
- var old_end = Pers_util.get_unix_time() - Pers_util.DAY2SEC(days_last_seen);
- var old_start = Pers_util.get_unix_time() - Pers_util.DAY2SEC(days_last_seen - duration);
-
- var second_result_list = [
- { "server" : "test1:8080",
- "obs" : [ { "key" : key,
- "timestamps" : [ { "start" : old_start , "end" : old_end } ] } ]
- },
- { "server" : "test2:8080",
- "obs" : [ { "key" : key,
- "timestamps" : [ { "start" : old_start , "end" : old_end } ] } ]
- }
- ];
-
- var weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(key,
- short_result_list, 1, -10);
- assert((weakly_seen === false), "Negative Check lengths can't be weakly seen");
-
- var weak_check_time_limit = Pers_util.SEC2DAY(curtime + curtime);
- weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(key,
- short_result_list, 1, weak_check_time_limit);
- assert((weakly_seen === false), "Check lengths longer than time since the epoch can't be weakly seen");
-
- weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(key,
- short_result_list, -1, 1);
- assert((weakly_seen === false), "Negative quorum sizes can't be weakly seen");
-
- weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(key,
- short_result_list, 0, 1);
- assert((weakly_seen === false), "Quorum size 0 can't be weakly seen");
-
-
- var check_length = (days_last_seen + 1); //days
- assert((check_length >= days_last_seen), "(meta) Test setup: check length >= ending day of observation.");
- var weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key,
- second_result_list, 3, check_length);
- assert((weakly_seen_test === false), "Keys seen but by fewer than quorum_size notaries do not count as weakly seen.");
-
- check_length = (days_last_seen - 1); //days
- assert((check_length <= days_last_seen), "(meta) Test setup: check length <= ending day of observation.");
- weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key,
- second_result_list, 2, check_length);
- assert((weakly_seen_test === false), "Keys seen by quorum_size notaries but not in the past X days do not count as weakly seen.");
-
- check_length = (days_last_seen + 1); //days
- assert((check_length >= days_last_seen), "(meta) Test setup: check length >= ending day of observation.");
- weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key,
- second_result_list, 2, check_length);
- assert((weakly_seen_test === true), "Keys seen by quorum_size notaries AND in the past X days DO count as weakly seen.");
-
- check_length = days_last_seen; //days
- assert((check_length === days_last_seen), "(meta) Test setup: check length === ending day of observation.");
- weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key,
- second_result_list, 2, check_length);
- assert((weakly_seen_test === true), "Keys seen by quorum_size notaries exactly in the past X days DO count as weakly seen.");
-
-
+ write_string("Starting client policy unit tests...");
+
+ var key = "b1:7f:b1:15:25:4e:7b:fb:93:83:ac:5c:26:df:f7:00";
+ var curtime = Pers_util.get_unix_time();
+ var short_start = curtime - 1;
+ var short_result_list = [
+ { "server": "test1:8080",
+ "obs": [
+ { "key": key,
+ "timestamps": [
+ { "start": short_start, "end": curtime }
+ ] }
+ ]
+ }
+ ];
+
+ var days_last_seen = 3;
+ var duration = 2; // days
+ var old_end = Pers_util.get_unix_time() - Pers_util.DAY2SEC(days_last_seen );
+ var old_start = Pers_util.get_unix_time() - Pers_util.DAY2SEC(days_last_seen - duration);
+
+ var second_result_list = [
+ { "server": "test1:8080",
+ "obs": [
+ { "key": key,
+ "timestamps": [
+ { "start": old_start, "end": old_end }
+ ] }
+ ]
+ },
+ { "server": "test2:8080",
+ "obs": [
+ { "key": key,
+ "timestamps": [
+ { "start": old_start, "end": old_end }
+ ] }
+ ]
+ }
+ ];
+
+ var weakly_seen0 = Pers_client_policy.key_weakly_seen_by_quorum(key, short_result_list, 1, -10);
+ assert(weakly_seen0 === false, "Negative Check lengths can't be weakly seen");
+
+ var weak_check_time_limit = Pers_util.SEC2DAY(curtime + curtime);
+ var weakly_seen1 = Pers_client_policy.key_weakly_seen_by_quorum(key, short_result_list, 1, weak_check_time_limit);
+ assert(weakly_seen1 === false, "Check lengths longer than time since the epoch can't be weakly seen");
+
+ var weakly_seen2 = Pers_client_policy.key_weakly_seen_by_quorum(key, short_result_list, -1, 1);
+ assert(weakly_seen2 === false, "Negative quorum sizes can't be weakly seen");
+
+ var weakly_seen3 = Pers_client_policy.key_weakly_seen_by_quorum(key, short_result_list, 0, 1);
+ assert(weakly_seen3 === false, "Quorum size 0 can't be weakly seen");
+
+ var check_length0 = days_last_seen + 1; //days
+ assert(check_length0 >= days_last_seen , "(meta) Test setup: check length >= ending day of observation.");
+ var weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key, second_result_list, 3, check_length0);
+ assert(weakly_seen_test === false , "Keys seen but by fewer than quorum_size notaries do not count as weakly seen.");
+
+ var check_length1 = days_last_seen - 1; //days
+ assert(check_length1 <= days_last_seen , "(meta) Test setup: check length <= ending day of observation.");
+ weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key, second_result_list, 2, check_length1);
+ assert(weakly_seen_test === false , "Keys seen by quorum_size notaries but not in the past X days do not count as weakly seen.");
+
+ var check_length2 = days_last_seen + 1; //days
+ assert(check_length2 >= days_last_seen , "(meta) Test setup: check length >= ending day of observation.");
+ weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key, second_result_list, 2, check_length2);
+ assert(weakly_seen_test === true , "Keys seen by quorum_size notaries AND in the past X days DO count as weakly seen.");
+
+ var check_length3 = days_last_seen; //days
+ assert(check_length3 === days_last_seen , "(meta) Test setup: check length === ending day of observation.");
+ weakly_seen_test = Pers_client_policy.key_weakly_seen_by_quorum(key, second_result_list, 2, check_length3);
+ assert(weakly_seen_test === true , "Keys seen by quorum_size notaries exactly in the past X days DO count as weakly seen.");
}
function nonrouted_ips() {
@@@ -862,59 -820,79 +835,81 @@@ JaJ2Lw7kRVMCAwEAAQ==\n\n\n\n
}
function notary_replies() {
+ write_string("Starting notary reply tests");
- write_string("Starting notary reply tests");
+ //TODO: overwrite, or ignore?
+ assert_fixme(false, "Don't accept multiple responses from the same server");
+ //we can test this by temporarily allowing duplicates and sending out two responses.
+ //but it's even better if we can just do it in code.
- //TODO: overwrite, or ignore?
- assert_fixme(false, "Don't accept multiple responses from the same server");
- //we can test this by temporarily allowing duplicates and sending out two responses.
- //but it's even better if we can just do it in code.
-
- write_string("Finished");
+ write_string("Finished");
}
+
-
-
-
- function run_tests() {
-
- // print debug info to console by default
- Pers_debug.d_print_flags["error"] = true;
-
- try {
-
- Perspectives.init_data();
-
- clear();
- meta_tests();
- hash_tests();
- client_sanity();
- nonrouted_ips();
- quorum_basics();
- quorum_oldkey();
- notary_parsing();
- notary_replies();
-
-
- write_string("Finished: " + g_pass_count + "/" + g_test_count + " successes, "
- + g_fail_count + " failures. ");
- if (g_test_count != (g_pass_count + g_fail_count)) {
- error("Count totals did not match!");
+ function run_tests() {
+ // check if we are running with chrome privileges or from within browser
+ if(typeof Components.classes !== "undefined") {
+ // print debug info to console by default
+ Pers_debug.d_print_flags["error"] = true;
+
+ try {
+ Perspectives.init_data();
+
+ clear();
+ meta_tests();
++ hash_tests();
+ client_sanity();
+ nonrouted_ips();
+ quorum_basics();
+ quorum_oldkey();
+ notary_parsing();
+ notary_replies();
+
+ write_string("Finished: " + g_pass_count + "/" + g_test_count + " successes, "
+ + g_fail_count + " failures. ");
+ if(g_test_count !== g_pass_count + g_fail_count) {
+ error("Count totals did not match!");
+ }
+ } catch(e) {
+ alert(e);
+ error("tests did not finish: '" + e + "'.");
+ }
+ } else {
+ error("You are probably running the test from browser context, but you need to run it from chrome context. Use 'make test' to to build and install the Perspectives extension and open chrome://perspectives/content/test/test.html");
+
+ try {
+ //Perspectives.init_data();
+
+ clear();
+ meta_tests();
+ client_sanity();
+ //nonrouted_ips();
+ quorum_basics();
+ quorum_oldkey();
+ //notary_parsing();
+ notary_replies();
+
+ write_string("Finished: " + g_pass_count + "/" + g_test_count + " successes, "
+ + g_fail_count + " failures. ");
+ if(g_test_count !== g_pass_count + g_fail_count) {
+ error("Count totals did not match!");
+ }
+ } catch(e) {
+ alert(e);
+ error("tests did not finish: '" + e + "'.");
+ }
}
- } catch(e) {
- alert(e);
- error("tests did not finish: '" + e + "'.");
- }
- }
-
+ }
</script>
</head>
+
<body>
- <img src="../img/default.png" TITLE="Perspectives Logo"/>
- <input type="button" value="Run Tests" onclick="run_tests()">
- <p> Run with firebug or the web console to see detailed test output if something fails.</p>
- <h2> Results: </h2>
- <div id="results">
+ <img src="../img/default.png" title="Perspectives Logo"/>
+ <input type="button" value="Run Tests" onclick="run_tests();">
+
+ <p>Run with firebug or the web console to see detailed test output if something fails.</p>
+
+ <h2>Results: </h2>
+ <div id="results"></div>
</body>
</html>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git
More information about the Pkg-mozext-commits
mailing list