guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/05: channels: Error out when the 'guix' channel lacks an introduction


From: guix-commits
Subject: 03/05: channels: Error out when the 'guix' channel lacks an introduction.
Date: Sun, 28 Jun 2020 17:30:05 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit ead5c46147ebf352ad4804d52a766dcf105eda4f
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Jun 24 14:53:08 2020 +0200

    channels: Error out when the 'guix' channel lacks an introduction.
    
    * guix/channels.scm (latest-channel-instance): Raise an error instead of
    warning when 'guix is unauthenticated.
    * tests/channels.scm ("latest-channel-instances, missing introduction for 
'guix'"):
    New test.
---
 guix/channels.scm  | 13 ++++++++++---
 tests/channels.scm | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/guix/channels.scm b/guix/channels.scm
index 3eec5df..1016b95 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -406,9 +406,16 @@ their relation.  When AUTHENTICATE? is false, CHANNEL is 
not authenticated."
             ;; TODO: Warn for all the channels once the authentication 
interface
             ;; is public.
             (when (guix-channel? channel)
-              (warning (G_ "channel '~a' lacks an introduction and \
-cannot be authenticated~%")
-                       (channel-name channel))))
+              (raise (condition
+                      (&message
+                       (message (format #f (G_ "channel '~a' lacks an \
+introduction and cannot be authenticated~%")
+                                        (channel-name channel))))
+                      (&fix-hint
+                       (hint (G_ "Add the missing introduction to your
+channels file to address the issue.  Alternatively, you can pass
+@option{--disable-authentication}, at the risk of running unauthenticated and
+thus potentially malicious code.")))))))
         (warning (G_ "channel authentication disabled~%")))
 
     (when (guix-channel? channel)
diff --git a/tests/channels.scm b/tests/channels.scm
index 3a2c1d4..d7202f8 100644
--- a/tests/channels.scm
+++ b/tests/channels.scm
@@ -402,6 +402,27 @@
                          (channel-news-for-commit channel commit5 commit1))
                     '(#f "tag-for-first-news-entry")))))))
 
+(unless (which (git-command)) (test-skip 1))
+(test-assert "latest-channel-instances, missing introduction for 'guix'"
+  (with-temporary-git-repository directory
+      '((add "a.txt" "A")
+        (commit "first commit")
+        (add "b.scm" "#t")
+        (commit "second commit"))
+    (with-repository directory repository
+      (let* ((commit1 (find-commit repository "first"))
+             (commit2 (find-commit repository "second"))
+             (channel (channel (url (string-append "file://" directory))
+                               (name 'guix))))
+
+        (guard (c ((message-condition? c)
+                   (->bool (string-contains (condition-message c)
+                                            "introduction"))))
+          (with-store store
+            ;; Attempt a downgrade from NEW to OLD.
+            (latest-channel-instances store (list channel))
+            #f))))))
+
 (unless (gpg+git-available?) (test-skip 1))
 (test-equal "authenticate-channel, wrong first commit signer"
   #t



reply via email to

[Prev in Thread] Current Thread [Next in Thread]