diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-06-07 23:06:41 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-06-07 23:10:46 +0200 |
| commit | e78275608065ef073775fabb9f1a757da65851f2 (patch) | |
| tree | 1a732111874006d3c5d9f8f47b0752a538ed3d51 /tests/git-authenticate.scm | |
| parent | 1fd7de45f218ce572a3fe87764ad15927e3dbdc4 (diff) | |
git-authenticate: Prevent removal of '.guix-authorizations'.
* guix/git-authenticate.scm (commit-authorized-keys)
[parents-have-authorizations-file?, assert-parents-lack-authorizations]:
New procedures.
Use the latter before returning DEFAULT-AUTHORIZATIONS.
* guix/git.scm (false-if-git-not-found): Export.
* guix/tests/git.scm (populate-git-repository): Add 'remove' clause.
* tests/git-authenticate.scm ("signed commits, .guix-authorizations removed"):
New test.
Diffstat (limited to 'tests/git-authenticate.scm')
| -rw-r--r-- | tests/git-authenticate.scm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/git-authenticate.scm b/tests/git-authenticate.scm index 5937c37ee68..84689d628e4 100644 --- a/tests/git-authenticate.scm +++ b/tests/git-authenticate.scm | |||
| @@ -282,5 +282,46 @@ | |||
| 282 | merge master3) | 282 | merge master3) |
| 283 | #:keyring-reference "master")))))) | 283 | #:keyring-reference "master")))))) |
| 284 | 284 | ||
| 285 | (unless (gpg+git-available?) (test-skip 1)) | ||
| 286 | (test-assert "signed commits, .guix-authorizations removed" | ||
| 287 | (with-fresh-gnupg-setup (list %ed25519-public-key-file | ||
| 288 | %ed25519-secret-key-file) | ||
| 289 | (with-temporary-git-repository directory | ||
| 290 | `((add "signer.key" ,(call-with-input-file %ed25519-public-key-file | ||
| 291 | get-string-all)) | ||
| 292 | (add ".guix-authorizations" | ||
| 293 | ,(object->string | ||
| 294 | `(authorizations (version 0) | ||
| 295 | ((,(key-fingerprint | ||
| 296 | %ed25519-public-key-file) | ||
| 297 | (name "Charlie")))))) | ||
| 298 | (commit "zeroth commit") | ||
| 299 | (add "a.txt" "A") | ||
| 300 | (commit "first commit" | ||
| 301 | (signer ,(key-fingerprint %ed25519-public-key-file))) | ||
| 302 | (remove ".guix-authorizations") | ||
| 303 | (commit "second commit" | ||
| 304 | (signer ,(key-fingerprint %ed25519-public-key-file))) | ||
| 305 | (add "b.txt" "B") | ||
| 306 | (commit "third commit" | ||
| 307 | (signer ,(key-fingerprint %ed25519-public-key-file)))) | ||
| 308 | (with-repository directory repository | ||
| 309 | (let ((commit1 (find-commit repository "first")) | ||
| 310 | (commit2 (find-commit repository "second")) | ||
| 311 | (commit3 (find-commit repository "third"))) | ||
| 312 | ;; COMMIT1 and COMMIT2 are fine. | ||
| 313 | (and (authenticate-commits repository (list commit1 commit2) | ||
| 314 | #:keyring-reference "master") | ||
| 315 | |||
| 316 | ;; COMMIT3 is rejected because COMMIT2 removes | ||
| 317 | ;; '.guix-authorizations'. | ||
| 318 | (guard (c ((unauthorized-commit-error? c) | ||
| 319 | (oid=? (git-authentication-error-commit c) | ||
| 320 | (commit-id commit2)))) | ||
| 321 | (authenticate-commits repository | ||
| 322 | (list commit1 commit2 commit3) | ||
| 323 | #:keyring-reference "master") | ||
| 324 | 'failed))))))) | ||
| 325 | |||
| 285 | (test-end "git-authenticate") | 326 | (test-end "git-authenticate") |
| 286 | 327 | ||
