[Pkg-mozext-commits] [perspectives-extension] 58/72: unit tests - Fix test for parsing duplicate notaries
David Prévot
taffit at moszumanska.debian.org
Thu Dec 11 02:12:51 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 75495bfa7adbc47063b691465c50eeb201f5b51a
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date: Mon Oct 27 22:41:45 2014 -0600
unit tests - Fix test for parsing duplicate notaries
It's simpler and better to just test the parsing function
rather than mucking with user preferences.
---
test/test.html | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/test/test.html b/test/test.html
index e540e8d..d209b54 100644
--- a/test/test.html
+++ b/test/test.html
@@ -797,20 +797,33 @@ function notary_parsing() {
// TODO bad method of declaration?
// We need newlines after the server name and 'BEGIN PUBLIC KEY' lines
// for the string to parse properly
- var notary_dupe = "perspectives1.networknotary.org:8080\n\
+ var test_notary_one = "testnotaryone.nowhere.org:8080\n\
-----BEGIN PUBLIC KEY-----\n\
MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAGXsegzE6E/6j4vgzi3NqGSn2dz\
W6gRxkuAL7PB8QmRqtG9ieSQjFB6cTYvkmp7x/LtHqlr9Fa6+/mT4Ma5oKU0RpgY\
MyfYnEk0iiNWG2fj4mRpTscHfcEJfKP13OGAYP1ZuHksTXSYsaKfIwiVKMLgQ/hA\
FHBSCs9X+bvVMgPOiEpxZXfaynOQ3TLGYtVywLRwW5yvlRq4E9z0rtvwR1bn1hVd\
JaJ2Lw7kRVMCAwEAAQ==\
------END PUBLIC KEY-----";
+-----END PUBLIC KEY-----\n"; // end with a newline so we can concatenate
- Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, "");
- count_before = Perspectives.getNotaryList().length;
- Perspectives.root_prefs.setCharPref(pref_string_extra_notaries, notary_dupe);
- notaries = Perspectives.getNotaryList();
- assert(notaries.length === count_before, "Trying to add a duplicate notary doesn't work.");
+ var test_notary_two = "testnotarytwo.nowhere.org:8080\n\
+-----BEGIN PUBLIC KEY-----\n\
+MIHKMA0GCSqGSIb3DQEBAQUAA4G4ADCBtAKBrAGXsegzE6E/6j4vgzi3NqGSn2dz\
+W6gRxkuAL7PB8QmRqtG9ieSQjFB6cTYvkmp7x/LtHqlr9Fa6+/mT4Ma5oKU0RpgY\
+MyfYnEk0iiNWG2fj4mRpTscHfcEJfKP13OGAYP1ZuHksTXSYsaKfIwiVKMLgQ/hA\
+FHBSCs9X+bvVMgPOiEpxZXfaynOQ3TLGYtVywLRwW5yvlRq4E9z0rtvwR1bn1hVd\
+JaJ2Lw7kRVMCAwEAAQ==\
+-----END PUBLIC KEY-----\n";
+
+ var single_notary = Pers_util.loadNotaryListFromString(test_notary_one);
+ assert(single_notary.length === 1, "Trying to parse a single notary works.");
+
+ assert(test_notary_one !== test_notary_two, "(meta) test notaries are distinct.");
+ var distinct_notaries = Pers_util.loadNotaryListFromString(test_notary_one + test_notary_two);
+ assert(distinct_notaries.length > 1, "Trying to parse multiple distinct notaries works.");
+
+ var duplicate_notaries = Pers_util.loadNotaryListFromString(test_notary_one + test_notary_one + test_notary_one);
+ assert(duplicate_notaries.length === 1, "Trying to parse a duplicate notary is ignored.");
var sparse_notary = "perspectivesFAKETEST.networknotary.org:8080\n\n\n\n\
-----BEGIN PUBLIC KEY-----\n\n\n\n\n\
--
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