summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2026-03-01 17:48:10 +0100
committerNguyễn Gia Phong <cnx@loang.net>2026-04-10 15:03:18 +0900
commitb361ab8ceb053cf1d413524b54de76a1d05a7920 (patch)
tree3c90c5316fc281562efb05908265e6406cb9a757
parent4c7a7a1d498f4ca418a649a0b3e3a056569aec15 (diff)
tests: openpgp: Migrate to (srfi srfi-71).
* tests/openpgp.scm ("read-radix-64", "get-openpgp-keyring") ("verify-openpgp-signature, missing key") ("verify-openpgp-signature, good signatures") ("verify-openpgp-signature, bad signature"): Migrate tests to from (srfi srfi-11) to (srfi srfi-71). Change-Id: I5c4939dd5217fc15f5c1071c4223ecb194a693b3 Merges: https://codeberg.org/guix/guix/pulls/6794 Reviewed-by: Danny Milosavljevic <dannym@friendly-machines.com> Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
-rw-r--r--tests/openpgp.scm78
1 files changed, 37 insertions, 41 deletions
diff --git a/tests/openpgp.scm b/tests/openpgp.scm
index 30be6644684..ca6c800b15d 100644
--- a/tests/openpgp.scm
+++ b/tests/openpgp.scm
@@ -25,7 +25,6 @@
25 #:use-module (ice-9 match) 25 #:use-module (ice-9 match)
26 #:use-module (rnrs bytevectors) 26 #:use-module (rnrs bytevectors)
27 #:use-module (srfi srfi-1) 27 #:use-module (srfi srfi-1)
28 #:use-module (srfi srfi-11)
29 #:use-module (srfi srfi-64) 28 #:use-module (srfi srfi-64)
30 #:use-module (srfi srfi-71)) 29 #:use-module (srfi srfi-71))
31 30
@@ -153,8 +152,7 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
153 152
154(test-equal "read-radix-64" 153(test-equal "read-radix-64"
155 '(#t "PGP MESSAGE") 154 '(#t "PGP MESSAGE")
156 (let-values (((data type) 155 (let ((data type (call-with-input-string %radix-64-sample read-radix-64)))
157 (call-with-input-string %radix-64-sample read-radix-64)))
158 (list (bytevector? data) type))) 156 (list (bytevector? data) type)))
159 157
160(test-equal "read-radix-64, CRC mismatch" 158(test-equal "read-radix-64, CRC mismatch"
@@ -175,18 +173,16 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
175 (let* ((key (search-path %load-path "tests/keys/openpgp/civodul.pub")) 173 (let* ((key (search-path %load-path "tests/keys/openpgp/civodul.pub"))
176 (keyring (get-openpgp-keyring 174 (keyring (get-openpgp-keyring
177 (open-bytevector-input-port 175 (open-bytevector-input-port
178 (call-with-input-file key read-radix-64))))) 176 (call-with-input-file key read-radix-64))))
179 (let-values (((primary packets) 177 (primary packets (lookup-key-by-id keyring %civodul-key-id))
180 (lookup-key-by-id keyring %civodul-key-id))) 178 (fingerprint (openpgp-public-key-fingerprint primary)))
181 (let ((fingerprint (openpgp-public-key-fingerprint primary))) 179 (and (= (openpgp-public-key-id primary) %civodul-key-id)
182 (and (= (openpgp-public-key-id primary) %civodul-key-id) 180 (not (openpgp-public-key-subkey? primary))
183 (not (openpgp-public-key-subkey? primary)) 181 (string=? (openpgp-format-fingerprint fingerprint)
184 (string=? (openpgp-format-fingerprint fingerprint) 182 %civodul-fingerprint)
185 %civodul-fingerprint) 183 (string=? (openpgp-user-id-value (find openpgp-user-id? packets))
186 (string=? (openpgp-user-id-value (find openpgp-user-id? packets)) 184 "Ludovic Courtès <ludo@gnu.org>")
187 "Ludovic Courtès <ludo@gnu.org>") 185 (eq? primary (lookup-key-by-fingerprint keyring fingerprint)))))
188 (eq? (lookup-key-by-fingerprint keyring fingerprint)
189 primary))))))
190 186
191(test-equal "get-openpgp-detached-signature/ascii" 187(test-equal "get-openpgp-detached-signature/ascii"
192 (list `(,%dsa-key-id ,%dsa-key-fingerprint dsa sha256) 188 (list `(,%dsa-key-id ,%dsa-key-fingerprint dsa sha256)
@@ -209,12 +205,11 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
209 205
210(test-equal "verify-openpgp-signature, missing key" 206(test-equal "verify-openpgp-signature, missing key"
211 `(missing-key ,%rsa-key-fingerprint) 207 `(missing-key ,%rsa-key-fingerprint)
212 (let* ((keyring (get-openpgp-keyring (%make-void-port "r"))) 208 (let* ((keyring (get-openpgp-keyring (%make-void-port "r")))
213 (signature (string->openpgp-packet %hello-signature/rsa))) 209 (signature (string->openpgp-packet %hello-signature/rsa))
214 (let-values (((status key) 210 (port (open-input-string "Hello!\n"))
215 (verify-openpgp-signature signature keyring 211 (status key (verify-openpgp-signature signature keyring port)))
216 (open-input-string "Hello!\n")))) 212 (list status key)))
217 (list status key))))
218 213
219(test-equal "verify-openpgp-signature, good signatures" 214(test-equal "verify-openpgp-signature, good signatures"
220 `((good-signature ,%rsa-key-id) 215 `((good-signature ,%rsa-key-id)
@@ -223,21 +218,21 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
223 (good-signature ,%ed25519-key-id) 218 (good-signature ,%ed25519-key-id)
224 (good-signature ,%ed25519-key-id)) 219 (good-signature ,%ed25519-key-id))
225 (map (lambda (key signature) 220 (map (lambda (key signature)
226 (let* ((key (search-path %load-path key)) 221 (let* ((key (search-path %load-path key))
227 (keyring (get-openpgp-keyring 222 (keyring (get-openpgp-keyring
228 (open-bytevector-input-port 223 (open-bytevector-input-port
229 (call-with-input-file key read-radix-64)))) 224 (call-with-input-file key read-radix-64))))
230 (signature (string->openpgp-packet signature))) 225 (signature (string->openpgp-packet signature))
231 (let-values (((status key) 226 (port (open-input-string "Hello!\n"))
232 (verify-openpgp-signature signature keyring 227 (status key (verify-openpgp-signature signature keyring port)))
233 (open-input-string "Hello!\n")))) 228 (list status (openpgp-public-key-id key))))
234 (list status (openpgp-public-key-id key)))))
235 (list "tests/keys/openpgp/rsa.pub" 229 (list "tests/keys/openpgp/rsa.pub"
236 "tests/keys/openpgp/dsa.pub" 230 "tests/keys/openpgp/dsa.pub"
237 "tests/keys/openpgp/ed25519.pub" 231 "tests/keys/openpgp/ed25519.pub"
238 "tests/keys/openpgp/ed25519.pub" 232 "tests/keys/openpgp/ed25519.pub"
239 "tests/keys/openpgp/ed25519.pub") 233 "tests/keys/openpgp/ed25519.pub")
240 (list %hello-signature/rsa %hello-signature/dsa 234 (list %hello-signature/rsa
235 %hello-signature/dsa
241 %hello-signature/ed25519/sha256 236 %hello-signature/ed25519/sha256
242 %hello-signature/ed25519/sha512 237 %hello-signature/ed25519/sha512
243 %hello-signature/ed25519/sha1))) 238 %hello-signature/ed25519/sha1)))
@@ -260,15 +255,16 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
260 "tests/keys/openpgp/ed25519.pub" 255 "tests/keys/openpgp/ed25519.pub"
261 "tests/keys/openpgp/ed25519.pub" 256 "tests/keys/openpgp/ed25519.pub"
262 "tests/keys/openpgp/ed25519.pub")))) 257 "tests/keys/openpgp/ed25519.pub"))))
263 (map (lambda (signature) 258 (map
264 (let ((signature (string->openpgp-packet signature))) 259 (lambda (signature)
265 (let-values (((status key) 260 (let* ((signature (string->openpgp-packet signature))
266 (verify-openpgp-signature signature keyring 261 (port (open-input-string "What?!"))
267 (open-input-string "What?!")))) 262 (status key (verify-openpgp-signature signature keyring port)))
268 (list status (openpgp-public-key-id key))))) 263 (list status (openpgp-public-key-id key))))
269 (list %hello-signature/rsa %hello-signature/dsa 264 (list %hello-signature/rsa
270 %hello-signature/ed25519/sha256 265 %hello-signature/dsa
271 %hello-signature/ed25519/sha512 266 %hello-signature/ed25519/sha256
272 %hello-signature/ed25519/sha1)))) 267 %hello-signature/ed25519/sha512
268 %hello-signature/ed25519/sha1))))
273 269
274(test-end "openpgp") 270(test-end "openpgp")