mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
tests: Move some functions into a common module.
* tests/openpgp/tofu.scm (gettrust): Moved to the common defs.scm module. (checktrust): Likewise. * tests/openpgp/defs.scm (gettrust): New function. (checktrust): Likewise. -- These functions will be re-used by the tests for the PGP trust model. Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
This commit is contained in:
parent
0161225457
commit
cbe54b28bf
@ -466,5 +466,29 @@
|
|||||||
(catch (log "Warning: Removing socket directory failed.")
|
(catch (log "Warning: Removing socket directory failed.")
|
||||||
(gpg-conf '--remove-socketdir)))
|
(gpg-conf '--remove-socketdir)))
|
||||||
|
|
||||||
|
;; Get the trust level for KEYID. Any remaining arguments are simply
|
||||||
|
;; passed to GPG.
|
||||||
|
;;
|
||||||
|
;; This function only supports keys with a single user id.
|
||||||
|
(define (gettrust keyid . args)
|
||||||
|
(let ((trust
|
||||||
|
(list-ref (assoc "pub" (gpg-with-colons
|
||||||
|
`(,@args
|
||||||
|
--list-keys ,keyid))) 1)))
|
||||||
|
(unless (and (= 1 (string-length trust))
|
||||||
|
(member (string-ref trust 0) (string->list "oidreqnmfuws-")))
|
||||||
|
(fail "Bad trust value:" trust))
|
||||||
|
trust))
|
||||||
|
|
||||||
|
;; Check that KEYID's trust level matches EXPECTED-TRUST. Any
|
||||||
|
;; remaining arguments are simply passed to GPG.
|
||||||
|
;;
|
||||||
|
;; This function only supports keys with a single user id.
|
||||||
|
(define (checktrust keyid expected-trust . args)
|
||||||
|
(let ((trust (apply gettrust `(,keyid ,@args))))
|
||||||
|
(unless (string=? trust expected-trust)
|
||||||
|
(fail keyid ": Expected trust to be" expected-trust
|
||||||
|
"but got" trust))))
|
||||||
|
|
||||||
|
|
||||||
;; end
|
;; end
|
||||||
|
@ -71,30 +71,6 @@
|
|||||||
(fail keyid ": Expected policy to be" expected-policy
|
(fail keyid ": Expected policy to be" expected-policy
|
||||||
"but got" policy))))
|
"but got" policy))))
|
||||||
|
|
||||||
;; Get the trust level for KEYID. Any remaining arguments are simply
|
|
||||||
;; passed to GPG.
|
|
||||||
;;
|
|
||||||
;; This function only supports keys with a single user id.
|
|
||||||
(define (gettrust keyid . args)
|
|
||||||
(let ((trust
|
|
||||||
(list-ref (assoc "pub" (gpg-with-colons
|
|
||||||
`(,@args
|
|
||||||
--list-keys ,keyid))) 1)))
|
|
||||||
(unless (and (= 1 (string-length trust))
|
|
||||||
(member (string-ref trust 0) (string->list "oidreqnmfuws-")))
|
|
||||||
(fail "Bad trust value:" trust))
|
|
||||||
trust))
|
|
||||||
|
|
||||||
;; Check that KEYID's trust level matches EXPECTED-TRUST. Any
|
|
||||||
;; remaining arguments are simply passed to GPG.
|
|
||||||
;;
|
|
||||||
;; This function only supports keys with a single user id.
|
|
||||||
(define (checktrust keyid expected-trust . args)
|
|
||||||
(let ((trust (apply gettrust `(,keyid ,@args))))
|
|
||||||
(unless (string=? trust expected-trust)
|
|
||||||
(fail keyid ": Expected trust to be" expected-trust
|
|
||||||
"but got" trust))))
|
|
||||||
|
|
||||||
;; Set key KEYID's policy to POLICY. Any remaining arguments are
|
;; Set key KEYID's policy to POLICY. Any remaining arguments are
|
||||||
;; passed as options to gpg.
|
;; passed as options to gpg.
|
||||||
(define (setpolicy keyid policy . args)
|
(define (setpolicy keyid policy . args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user