[Pkg-mozext-commits] [perspectives-extension] 07/18: Unit tests - Add tests for certificates with short durations

David Prévot taffit at alioth.debian.org
Fri Oct 25 18:24:29 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch debian
in repository perspectives-extension.

commit a156d437b6a24c417225137b581b277ac7fc0e86
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date:   Wed Oct 9 22:27:16 2013 -0600

    Unit tests - Add tests for certificates with short durations
---
 test/test.html |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/test/test.html b/test/test.html
index 4d358a2..3801af3 100644
--- a/test/test.html
+++ b/test/test.html
@@ -244,6 +244,46 @@ function quorum_basics() {
           empty_result_list, 1, max_stale_sec,cur_time);
  assert((quorum_duration == -1), "Passing an empty results list fails");
 
+ spacer('Quorums for certificates with short durations');
+
+ var short_start = 10;
+ var short_end = 11;
+ var short_result_list = [
+     { "server" : "test1:8080",
+       "obs" : [  { "key" : key,
+        "timestamps" : [ { "start" : short_start , "end" : short_end  } ] } ]
+     }
+   ];
+
+  // place cur_time within the 'valid range' cutoff
+  cur_time = 24 * 3600;
+  max_stale_sec = 200;
+  quorum_duration = Pers_client_policy.get_quorum_duration(key,
+          short_result_list, 1, max_stale_sec, cur_time);
+ assert((quorum_duration == -1), "A one-second duration out of the valid time window is inconsistent (got " +
+    quorum_duration + ").");
+
+ // the 'weakly seen' property is relative to the current time,
+ // so allow a check length going back to the end date of the observation.
+ var weak_check_time_limit = Pers_util.SEC2DAY(Pers_util.get_unix_time() - short_end);
+ var weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(key,
+          short_result_list, 1, weak_check_time_limit);
+ assert((weakly_seen === true), "keys with one second duration count as 'weakly seen'");
+
+  max_stale_sec = 3 * 24 * 3600;
+  quorum_duration = Pers_client_policy.get_quorum_duration(key,
+          short_result_list, 1, max_stale_sec, cur_time);
+ assert((quorum_duration == 1), "A one-second duration within the valid time window is one second (got " +
+    quorum_duration + ").");
+
+ cur_time += 24 * 3600;
+ assert(((cur_time - max_stale_sec) < short_end), "(meta) Current time for the next test is still within the valid window.");
+ var quorum_duration2 = Pers_client_policy.get_quorum_duration(key,
+          short_result_list, 1, max_stale_sec, cur_time);
+ assert((quorum_duration == quorum_duration2), "Changing the curtime within the valid window doesn't change the duration of the cert observation (got " +
+    quorum_duration2 + ").");
+
+ spacer('Quorums with a small number of notaries');
 
  //quorums with a small number of notaries
  //TODO: write code to save and restore all preferences after each test,

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