[Pkg-mozext-commits] [perspectives-extension] 20/72: fixed in generate_svg.js: Actually draw stale_limit line Fixes #68 added in svg_test: some more tests

David Prévot taffit at moszumanska.debian.org
Thu Dec 11 02:12:46 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 786f619e5696a1b971e28a568da9e9f738fd122a
Author: Gerold Meisinger <gerold.meisinger at gmail.com>
Date:   Sun Jun 29 18:06:36 2014 +0100

    fixed in generate_svg.js: Actually draw stale_limit line
    Fixes #68
    added in svg_test: some more tests
---
 plugin/chrome/content/generate_svg.js | 14 +++---
 plugin/chrome/content/notaries.js     |  2 +-
 test/svg_test.html                    | 89 ++++++++++++++++++++++++++++++-----
 3 files changed, 84 insertions(+), 21 deletions(-)

diff --git a/plugin/chrome/content/generate_svg.js b/plugin/chrome/content/generate_svg.js
index af0e530..dca2968 100644
--- a/plugin/chrome/content/generate_svg.js
+++ b/plugin/chrome/content/generate_svg.js
@@ -66,7 +66,7 @@ var Pers_gen = {
 	},
 
 	get_svg_graph: function(service_id, server_result_list, len_days, cur_secs,
-							browser_key, max_stale_sec, required_duration) {
+							browser_key, max_stale_sec) {
 		var x_offset = 230, y_offset = 40;
 		var width = 700;
 		var y_cord = y_offset;
@@ -178,13 +178,11 @@ var Pers_gen = {
 				+ '" rx="5" stroke="black" stroke-width="1px" />\n';
 		} // end per-server
 
-		// draw quorum line
-		if(required_duration > 0) {
-			var x = x_offset + pixels_per_day * required_duration;
-			res += '<path d = "M ' + x + ' ' + (y_offset + 30) +  ' L ' + x
-				+ ' ' + (y_cord + 20)
-				+ '" stroke="black" stroke-width="1"/>\n';
-		}
+		// draw stale_limit line
+		var x = x_offset + pixels_per_day * Pers_util.SEC2DAY(max_stale_sec);
+		res += '<path d = "M ' + x + ' ' + (y_offset + 30) +  ' L ' + x
+			+ ' ' + (y_cord + 20)
+			+ '" stroke="black" stroke-width="1"/>\n';
 
 		// draw Days axis
 		for(var i = 0; i < 11; i++) {
diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index 44a86bd..02640fb 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -521,7 +521,7 @@ var Perspectives = {
 			var required_duration = Perspectives.root_prefs.
 								getIntPref("perspectives.required_duration");
 			var svg = Pers_gen.get_svg_graph(ti.service_id, server_result_list, 30,
-				unixtime, test_key, max_stale_sec, required_duration);
+				unixtime, test_key, max_stale_sec);
 			ti.query_results = new Perspectives.SslCert(ti.uri.host,
 										ti.uri.port, test_key,
 										str, null,svg, qd_days,
diff --git a/test/svg_test.html b/test/svg_test.html
index 863abe8..618845e 100644
--- a/test/svg_test.html
+++ b/test/svg_test.html
@@ -21,30 +21,95 @@
     };
 
     function generate_graph() {
+        var DAY         = 24 * 60 * 60;
+        var BROWSER_KEY = "01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef";
+        var OTHER_KEY   = BROWSER_KEY.split('').reverse().join('');
+
+        var unixtime      = 1000000000; // 2001-09-09 01:46:40
+        var max_stale_sec = 2 * DAY;
+
         var server_result_list = [
-            { "server": "cmu.ron.lcs.mit.edu:8080",
+            { "server": "same key, non-stale",
+                "obs": [
+                    { "key": BROWSER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - 3 * DAY, "end": unixtime - 0 * DAY }
+                        ] }
+                ],
+                "is_valid" : true
+            },
+            { "server": "same key, stale",
+                "obs": [
+                    { "key": BROWSER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - 6 * DAY, "end": unixtime - 3 * DAY }
+                        ] }
+                ],
+                "is_valid" : true
+            },
+            { "server": "from stale limit",
+                "obs": [
+                    { "key": BROWSER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - max_stale_sec, "end": unixtime - 0 * DAY }
+                        ] }
+                ],
+                "is_valid" : true
+            },
+            { "server": "to stale limit",
                 "obs": [
-                    { "key": "bc:7f:b1:15:25:4e:7b:fb:93:83:ac:5c:26:df:f7:00",
+                    { "key": BROWSER_KEY,
                         "timestamps": [
-                            { "start": 0, "end": 100000  }
+                            { "start": unixtime - 2 * max_stale_sec, "end": unixtime - 1 * max_stale_sec }
                         ] }
-                ]
+                ],
+                "is_valid" : true
             },
-            { "server": "hostway.ron.lcs.mit.edu:8080",
+            { "server": "to stale limit - 1",
                 "obs": [
-                    { "key": "bc:7f:b1:15:25:4e:7b:fb:93:83:ac:5c:26:df:f7:00",
+                    { "key": BROWSER_KEY,
                         "timestamps": [
-                            { "start": 9000, "end": 100000  }
+                            { "start": unixtime - 2 * max_stale_sec, "end": unixtime - 1 * max_stale_sec - 1 }
                         ] }
-                ]
+                ],
+                "is_valid" : true
+            },
+            { "server": "other key, non-stale",
+                "obs": [
+                    { "key": OTHER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - 3 * DAY, "end": unixtime - 0 * DAY }
+                        ] }
+                ],
+                "is_valid" : true
+            },
+            { "server": "other key, stale",
+                "obs": [
+                    { "key": OTHER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - 6 * DAY, "end": unixtime - 3 * DAY }
+                        ] }
+                ],
+                "is_valid" : true
+            },
+            { "server": "invalid signature",
+                "obs": [
+                    { "key": BROWSER_KEY,
+                        "timestamps": [
+                            { "start": unixtime - 3 * DAY, "end": unixtime - 0 * DAY }
+                        ] }
+                ],
+                "is_valid" : false
+            },
+            { "server": "no response",
+                "obs": [],
+                "is_valid" : true
             }
         ];
 
-        var key = "bc:7f:b1:15:25:4e:7b:fb:93:83:ac:5c:26:df:f7:00";
-        var max_stale_sec     = 2 * 24 * 3600;
         var required_duration = 2;
         var svg = Pers_gen.get_svg_graph("www.test.com:443,2", server_result_list,
-                30, 100100, key, max_stale_sec, required_duration);
+                30, unixtime, BROWSER_KEY, max_stale_sec);
 
         var parser = new DOMParser();
         var svgDoc = parser.parseFromString(svg, "text/xml");
@@ -55,7 +120,7 @@
 </script>
 </head>
 <body>
-    <input type="button" value="Generate Graph" onclick="generate_graph()">
+    <input type="button" value="Generate Graph" onclick="generate_graph();">
     <p>Run with firebug to see detailed test output if something fails.</p>
     <h2>Results: </h2>
     <div id="results"></div>

-- 
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