;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 Nikita Karetnikov ;;; Copyright © 2014, 2015 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (test-substitute) #:use-module (guix scripts substitute) #:use-module (guix base64) #:use-module (guix hash) #:use-module (guix serialization) #:use-module (guix pk-crypto) #:use-module (guix pki)
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/patches/python-pandas-skip-failing-tests.patch')
0 files changed, 0 insertions, 0 deletions
"GUIX_BINARY_SUBSTITUTE_URL")) uri-path)) (cache-directory (string-append (getenv "XDG_CACHE_HOME") "/guix/substitute/"))) (dynamic-wind (lambda () (when (file-exists? cache-directory) (delete-file-recursively cache-directory)) (call-with-output-file (string-append narinfo-directory "/nix-cache-info") (lambda (port) (format port "StoreDir: ~a\nWantMassQuery: 0\n" (%store-prefix)))) (call-with-output-file (string-append narinfo-directory "/" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ".narinfo") (cut display narinfo <>)) ;; Prepare the nar. (call-with-output-file (string-append narinfo-directory "/example.out") (cut display "Substitutable data." <>)) (call-with-output-file (string-append narinfo-directory "/example.nar") (cute write-file (string-append narinfo-directory "/example.out") <>)) (set! (@@ (guix scripts substitute) %allow-unauthenticated-substitutes?) #f)) thunk (lambda () (delete-file-recursively cache-directory))))) (define-syntax-rule (with-narinfo narinfo body ...) (call-with-narinfo narinfo (lambda () body ...))) ;; Transmit these options to 'guix substitute'. (set! (@@ (guix scripts substitute) %cache-urls) (list (getenv "GUIX_BINARY_SUBSTITUTE_URL"))) (test-equal "query narinfo without signature" "" ; not substitutable (with-narinfo %narinfo (string-trim-both (with-output-to-string (lambda () (with-input-from-string (string-append "have " (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") (lambda () (guix-substitute "--query")))))))) (test-equal "query narinfo with invalid hash" ;; The hash in the signature differs from the hash of %NARINFO. "" (with-narinfo (string-append %narinfo "Signature: " (signature-field "different body") "\n") (string-trim-both (with-output-to-string (lambda () (with-input-from-string (string-append "have " (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") (lambda () (guix-substitute "--query")))))))) (test-equal "query narinfo signed with authorized key" (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") (with-narinfo (string-append %narinfo "Signature: " (signature-field %narinfo) "\n") (string-trim-both (with-output-to-string (lambda () (with-input-from-string (string-append "have " (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") (lambda () (guix-substitute "--query")))))))) (test-equal "query narinfo signed with unauthorized key" "" ; not substitutable (with-narinfo (string-append %narinfo "Signature: " (signature-field %narinfo #:public-key %wrong-public-key) "\n") (string-trim-both (with-output-to-string (lambda () (with-input-from-string (string-append "have " (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") (lambda () (guix-substitute "--query")))))))) (test-quit "substitute, no signature" "lacks a signature" (with-narinfo %narinfo (guix-substitute "--substitute" (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") "foo"))) (test-quit "substitute, invalid hash" "hash" ;; The hash in the signature differs from the hash of %NARINFO. (with-narinfo (string-append %narinfo "Signature: " (signature-field "different body") "\n") (guix-substitute "--substitute" (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") "foo"))) (test-quit "substitute, unauthorized key" "unauthorized" (with-narinfo (string-append %narinfo "Signature: " (signature-field %narinfo #:public-key %wrong-public-key) "\n") (guix-substitute "--substitute" (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") "foo"))) (test-equal "substitute, authorized key" "Substitutable data." (with-narinfo (string-append %narinfo "Signature: " (signature-field %narinfo)) (dynamic-wind (const #t) (lambda () (guix-substitute "--substitute" (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") "substitute-retrieved") (call-with-input-file "substitute-retrieved" get-string-all)) (lambda () (false-if-exception (delete-file "substitute-retrieved")))))) (test-end "substitute") ;;; Local Variables: ;;; eval: (put 'with-narinfo 'scheme-indent-function 1) ;;; eval: (put 'test-quit 'scheme-indent-function 2) ;;; End: