[Pkg-gnupg-commit] [gnupg2] 98/118: tests: Simplify tofu test.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 15 18:25:16 UTC 2016


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

dkg pushed a commit to branch encoding-and-speling
in repository gnupg2.

commit aa81e32df7189c3eb44d4c602fd63f5b3f6a9e49
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 12 11:07:48 2016 +0200

    tests: Simplify tofu test.
    
    * tests/openpgp/tofu.scm: Simplify now that we only have one db
    format.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/openpgp/tofu.scm | 130 ++++++++++++++++++++++++-------------------------
 1 file changed, 64 insertions(+), 66 deletions(-)

diff --git a/tests/openpgp/tofu.scm b/tests/openpgp/tofu.scm
index cf2b389..f4de1d8 100755
--- a/tests/openpgp/tofu.scm
+++ b/tests/openpgp/tofu.scm
@@ -95,70 +95,68 @@
   (call-check `(, at GPG --trust-model=tofu , at args
 		      --tofu-policy ,policy ,keyid)))
 
+(info "Checking tofu policies and trust...")
+
+;; Carefully remove the TOFU db.
+(catch '() (unlink (string-append GNUPGHOME "/tofu.db")))
+(catch '() (unlink-recursively (string-append GNUPGHOME "/tofu.d")))
+
+;; Verify a message.  There should be no conflict and the trust
+;; policy should be set to auto.
+(call-check `(, at GPG --trust-model=tofu
+		    --verify ,(in-srcdir "tofu-2183839A-1.txt")))
+
+(checkpolicy "2183839A" "auto")
+;; Check default trust.
+(checktrust "2183839A" "m")
+
+;; Trust should be derived lazily.  Thus, if the policy is set to
+;; auto and we change --tofu-default-policy, then the trust should
+;; change as well.  Try it.
+(checktrust "2183839A" "f" '--tofu-default-policy=good)
+(checktrust "2183839A" "-" '--tofu-default-policy=unknown)
+(checktrust "2183839A" "n" '--tofu-default-policy=bad)
+
+;; Change the policy to something other than auto and make sure the
+;; policy and the trust are correct.
 (for-each-p
- "Testing tofu db"
- (lambda (1)
-   ;; Carefully remove the TOFU db.
-   (catch '() (unlink (string-append GNUPGHOME "/tofu.db")))
-   (catch '() (unlink-recursively (string-append GNUPGHOME "/tofu.d")))
-
-   ;; Verify a message.  There should be no conflict and the trust
-   ;; policy should be set to auto.
-   (call-check `(, at GPG --trust-model=tofu
-		       --verify ,(in-srcdir "tofu-2183839A-1.txt")))
-
-   (checkpolicy "2183839A" "auto")
-   ;; Check default trust.
-   (checktrust "2183839A" "m")
-
-   ;; Trust should be derived lazily.  Thus, if the policy is set to
-   ;; auto and we change --tofu-default-policy, then the trust should
-   ;; change as well.  Try it.
-   (checktrust "2183839A" "f" '--tofu-default-policy=good)
-   (checktrust "2183839A" "-" '--tofu-default-policy=unknown)
-   (checktrust "2183839A" "n" '--tofu-default-policy=bad)
-
-   ;; Change the policy to something other than auto and make sure the
-   ;; policy and the trust are correct.
-   (for-each-p
-    ""
-    (lambda (policy)
-      (let ((expected-trust
-	     (cond
-	      ((string=? "good" policy) "f")
-	      ((string=? "unknown" policy) "-")
-	      (else "n"))))
-	(setpolicy "2183839A" policy)
-
-	;; Since we have a fixed policy, the trust level shouldn't
-	;; change if we change the default policy.
-	(for-each-p
-	 ""
-	 (lambda (default-policy)
-	   (checkpolicy "2183839A" policy
-			'--tofu-default-policy default-policy)
-	   (checktrust "2183839A" expected-trust
-		       '--tofu-default-policy default-policy))
-	 '("auto" "good" "unknown" "bad" "ask"))))
-    '("good" "unknown" "bad"))
-
-   ;; BC15C85A conflicts with 2183839A.  On conflict, this will set
-   ;; BC15C85A to ask.  If 2183839A is auto (it's not, it's bad), then
-   ;; it will be set to ask.
-   (call-check `(, at GPG --trust-model=tofu
-		       --verify ,(in-srcdir "tofu-BC15C85A-1.txt")))
-   (checkpolicy "BC15C85A" "ask")
-   (checkpolicy "2183839A" "bad")
-
-   ;; EE37CF96 conflicts with 2183839A and BC15C85A.  We change
-   ;; BC15C85A's policy to auto and leave 2183839A's policy at bad.
-   ;; This conflict should cause BC15C85A's policy to be changed to
-   ;; ask (since it is auto), but not affect 2183839A's policy.
-   (setpolicy "BC15C85A" "auto")
-   (checkpolicy "BC15C85A" "auto")
-   (call-check `(, at GPG --trust-model=tofu
-		       --verify ,(in-srcdir "tofu-EE37CF96-1.txt")))
-   (checkpolicy "BC15C85A" "ask")
-   (checkpolicy "2183839A" "bad")
-   (checkpolicy "EE37CF96" "ask"))
- '("flat"))
+ "Setting a fixed policy..."
+ (lambda (policy)
+   (let ((expected-trust
+	  (cond
+	   ((string=? "good" policy) "f")
+	   ((string=? "unknown" policy) "-")
+	   (else "n"))))
+     (setpolicy "2183839A" policy)
+
+     ;; Since we have a fixed policy, the trust level shouldn't
+     ;; change if we change the default policy.
+     (for-each-p
+      ""
+      (lambda (default-policy)
+	(checkpolicy "2183839A" policy
+		     '--tofu-default-policy default-policy)
+	(checktrust "2183839A" expected-trust
+		    '--tofu-default-policy default-policy))
+      '("auto" "good" "unknown" "bad" "ask"))))
+ '("good" "unknown" "bad"))
+
+;; BC15C85A conflicts with 2183839A.  On conflict, this will set
+;; BC15C85A to ask.  If 2183839A is auto (it's not, it's bad), then
+;; it will be set to ask.
+(call-check `(, at GPG --trust-model=tofu
+		    --verify ,(in-srcdir "tofu-BC15C85A-1.txt")))
+(checkpolicy "BC15C85A" "ask")
+(checkpolicy "2183839A" "bad")
+
+;; EE37CF96 conflicts with 2183839A and BC15C85A.  We change
+;; BC15C85A's policy to auto and leave 2183839A's policy at bad.
+;; This conflict should cause BC15C85A's policy to be changed to
+;; ask (since it is auto), but not affect 2183839A's policy.
+(setpolicy "BC15C85A" "auto")
+(checkpolicy "BC15C85A" "auto")
+(call-check `(, at GPG --trust-model=tofu
+		    --verify ,(in-srcdir "tofu-EE37CF96-1.txt")))
+(checkpolicy "BC15C85A" "ask")
+(checkpolicy "2183839A" "bad")
+(checkpolicy "EE37CF96" "ask")

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list