From a849273509efb38e3f8ba740a7e1f63191413d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 20 Jul 2016 14:49:01 +0200 Subject: tests: Adjust to Shepherd error message change. This is a followup to commit 2c2ec261a8d3c37e5147038f47ad24c57cde4134. * tests/guix-system.sh: Adjust expected error message for Shepherd services that are not provided. --- tests/guix-system.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/guix-system.sh b/tests/guix-system.sh index d9e1679ae7..77d4e28999 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2014, 2015 Ludovic Courtès +# Copyright © 2014, 2015, 2016 Ludovic Courtès # # This file is part of GNU Guix. # @@ -139,7 +139,7 @@ if guix system build "$tmpfile" 2> "$errorfile" then exit 1 else - grep "service 'buggy!'.*'does-not-exist'.*undefined" "$errorfile" + grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile" fi # Reporting inconsistent user accounts. -- cgit v1.2.3 From ff6638d112d794c9c433731643711932452fd2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 20 Jul 2016 16:54:31 +0200 Subject: publish: Handle '/file' URLs, for content-addressed files. * guix/scripts/publish.scm (render-content-addressed-file): New procedure. (http-write): Add 'application/octet-stream' case. (make-request-handler): Add /file/NAME/sha256/HASH URLs. * tests/publish.scm ("/file/NAME/sha256/HASH") ("/file/NAME/sha256/INVALID-NIX-BASE32-STRING") ("/file/NAME/sha256/INVALID-HASH"): New tests. * doc/guix.texi (Invoking guix publish): Mention the /file URLs. --- tests/publish.scm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/publish.scm b/tests/publish.scm index 9bf181f1fc..0ba33487bd 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -26,6 +26,8 @@ #:use-module (guix utils) #:use-module (guix hash) #:use-module (guix store) + #:use-module (guix derivations) + #:use-module (guix gexp) #:use-module (guix base32) #:use-module (guix base64) #:use-module ((guix records) #:select (recutils->alist)) @@ -210,4 +212,36 @@ References: ~%" (display "This file is not a valid store item." port))) (response-code (http-get (publish-uri (string-append "/nar/invalid")))))) +(test-equal "/file/NAME/sha256/HASH" + "Hello, Guix world!" + (let* ((data "Hello, Guix world!") + (hash (call-with-input-string data port-sha256)) + (drv (run-with-store %store + (gexp->derivation "the-file.txt" + #~(call-with-output-file #$output + (lambda (port) + (display #$data port))) + #:hash-algo 'sha256 + #:hash hash))) + (out (build-derivations %store (list drv)))) + (utf8->string + (http-get-body + (publish-uri + (string-append "/file/the-file.txt/sha256/" + (bytevector->nix-base32-string hash))))))) + +(test-equal "/file/NAME/sha256/INVALID-NIX-BASE32-STRING" + 404 + (let ((uri (publish-uri + "/file/the-file.txt/sha256/not-a-nix-base32-string"))) + (response-code (http-get uri)))) + +(test-equal "/file/NAME/sha256/INVALID-HASH" + 404 + (let ((uri (publish-uri + (string-append "/file/the-file.txt/sha256/" + (bytevector->nix-base32-string + (call-with-input-string "" port-sha256)))))) + (response-code (http-get uri)))) + (test-end "publish") -- cgit v1.2.3