1#!/usr/bin/env gpgscm
2
3;; Copyright (C) 2017 Damien Goutte-Gattat
4;;
5;; This file is part of GnuPG.
6;;
7;;
8;; GnuPG is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 3 of the License, or
11;; (at your option) any later version.
12;;
13;; GnuPG is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16;; GNU General Public License for more details.
17;;
18;; You should have received a copy of the GNU General Public License
19;; along with this program; if not, see <http://www.gnu.org/licenses/>.
20
21(load (in-srcdir "tests" "openpgp" "defs.scm"))
22
23;; Redefine GPG without --always-trust.
24(define GPG `(,(tool 'gpg)))
25
26;; Helper constants for setownertrust.
27(define MARGINALTRUST "4")
28(define FULLTRUST "5")
29(define ULTIMATETRUST "6")
30
31;; Assign OWNERTRUST to the key identified by the provided
32;; fingerprint KEYFPR.
33(define (setownertrust keyfpr ownertrust)
34  (pipe:do
35    (pipe:echo (string-append keyfpr ":" ownertrust ":\n"))
36    (pipe:gpg `(--import-ownertrust))))
37
38;; Force a trustdb update.
39(define (updatetrustdb)
40  (call-check `(,@GPG --check-trustdb --yes)))
41
42;; IDs of all the keys involved in those tests.
43(define ALICE "FD9B20DD3C98123EEEAF8CC51BA41538D2E656B5")
44(define BOBBY "4D3F59F4D8030FD2D844AFEBA5BAC3ED125CCAE5")
45(define CAROL "6C62735E454CCDD79FA6CA601079113AEC1282FD")
46(define DAVID "A0607635198CABA2C467FAA64CE5BB42E3984000")
47(define FRANK "CE1A0E07CF8A20CBF8DC47D6DB9017DBAE6CD0EF")
48(define GRACE "B935F4B8DA009AFBCCDD41386653A183007F8345")
49(define HEIDI "0389C0B7990E10520B334F23756F1571EDA9184B")
50
51;; Initialize a given scenario.
52;; NAME should be the basename of the scenario file
53;; in this directory.
54(define (initscenario name)
55  (setup-environment)
56  ;; Make sure we are using the PGP trust model. This may no
57  ;; be the default model in the future.
58  (let ((trust-model (gpg-config 'gpg "trust-model")))
59    (trust-model::update "pgp"))
60  ;; Load the scenario's public keys.
61  (call-check `(,@GPG --import
62		      ,(in-srcdir "tests" "openpgp" "trust-pgp"
63				  (string-append name ".asc"))))
64  ;; Use Alice's key as root for all trust evaluations.
65  (setownertrust ALICE ULTIMATETRUST)
66  (updatetrustdb))
67