chiark / gitweb /
asshelp.c: add a lot of debug logging
[gnupg2.git] / tests / openpgp / delete-keys.scm
1 #!/usr/bin/env gpgscm
2
3 ;; Copyright (C) 2016 g10 Code GmbH
4 ;;
5 ;; This file is part of GnuPG.
6 ;;
7 ;; GnuPG is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
11 ;;
12 ;; GnuPG is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
19
20 (load (with-path "defs.scm"))
21 (setup-legacy-environment)
22
23 (let* ((key keys::alfa)
24       (subkey (car key::subkeys)))
25   (assert (have-public-key? key))
26   (assert (have-public-key? subkey))
27   (assert (have-secret-key? key))
28   (assert (have-secret-key-file? key))
29   (assert (have-secret-key? subkey))
30   (assert (have-secret-key-file? subkey))
31
32   ;; Firstly, delete the secret key.
33   (call-check `(,@gpg --delete-secret-keys ,key::fpr))
34   (assert (have-public-key? key))
35   (assert (have-public-key? subkey))
36   (assert (not (have-secret-key? key)))
37   (assert (not (have-secret-key-file? key)))
38   (assert (not (have-secret-key? subkey)))
39   (assert (not (have-secret-key-file? subkey)))
40
41   ;; Now, delete the public key.
42   (call-check `(,@gpg --delete-keys ,key::fpr))
43   (assert (not (have-public-key? key)))
44   (assert (not (have-public-key? subkey))))
45
46 ;; Do the same for key one, but do the subkeys separately.
47 (let* ((key keys::one)
48        (subkey (car key::subkeys)))
49   (assert (have-public-key? key))
50   (assert (have-public-key? subkey))
51   (assert (have-secret-key? key))
52   (assert (have-secret-key-file? key))
53   (assert (have-secret-key-file? key))
54   (assert (have-secret-key? subkey))
55   (assert (have-secret-key-file? subkey))
56
57   ;; Firstly, delete the secret subkey.
58   (call-check `(,@gpg --delete-secret-keys ,subkey::fpr))
59   (assert (have-public-key? key))
60   (assert (have-public-key? subkey))
61   ;; JW: Deleting the secret subkey also deletes the secret key.
62   ;; XXX (assert (have-secret-key? key))
63   ;; XXX (assert (have-secret-key-file? key))
64   (assert (not (have-secret-key? subkey)))
65   (assert (not (have-secret-key-file? subkey)))
66
67   ;; Then, delete the secret key.
68   ;; XXX (call-check `(,@gpg --delete-secret-keys ,key::fpr))
69   (assert (have-public-key? key))
70   (assert (have-public-key? subkey))
71   (assert (not (have-secret-key? key)))
72   (assert (not (have-secret-key-file? key)))
73   (assert (not (have-secret-key? subkey)))
74   (assert (not (have-secret-key-file? subkey)))
75
76   ;; Now, delete the public subkey.
77   (call-check `(,@gpg --delete-keys ,subkey::fpr))
78   ;; JW: Deleting the subkey also deletes the key.
79   ;; XXX (assert (have-public-key? key))
80   (assert (not (have-public-key? subkey)))
81
82   ;; Now, delete the public key.
83   ;; XXX (call-check `(,@gpg --delete-keys ,key::fpr))
84   (assert (not (have-public-key? key)))
85   (assert (not (have-public-key? subkey))))
86
87 (let* ((key keys::two)
88       (subkey (car key::subkeys)))
89   (assert (have-public-key? key))
90   (assert (have-public-key? subkey))
91   (assert (have-secret-key? key))
92   (assert (have-secret-key-file? key))
93   (assert (have-secret-key? subkey))
94   (assert (have-secret-key-file? subkey))
95
96   ;; Delete everything at once.
97   (call-check `(,@gpg --delete-secret-and-public-key ,key::fpr))
98   (assert (not (have-public-key? key)))
99   (assert (not (have-public-key? subkey)))
100   (assert (not (have-secret-key? key)))
101   (assert (not (have-secret-key-file? key)))
102   (assert (not (have-secret-key? subkey)))
103   (assert (not (have-secret-key-file? subkey))))