unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Pierre Langlois <pierre.langlois@gmx.com>
To: 59423@debbugs.gnu.org
Cc: mirai <mirai@makinata.eu>
Subject: bug#59423: Invalid 'location' field generated in dovecot configuration
Date: Thu, 01 Dec 2022 21:55:27 +0000	[thread overview]
Message-ID: <87359ydbnq.fsf@gmx.com> (raw)
In-Reply-To: <87y1s5wa4p.fsf@gmx.com>


[-- Attachment #1.1: Type: text/plain, Size: 579 bytes --]

Hi all!

As suggested by mirai off-list, it would be nice to have a test that
would have caught the issue. How do people feel about something along
the following patch? The idea is to use namespaces in the dovecot config
to declare the INBOX and another additional mailbox.

The bug is quite obscure and not really about dovecot itself, so I don't
think adding such a test is strictly necessary, maybe more tests for the
configuration macro would be good instead. But I figured expanding the
dovecot system test can't hurt. Let me know if you agree and I'll format
it properly.


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 519 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.diff --]
[-- Type: text/x-patch, Size: 4689 bytes --]

diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm
index f13751b72f..8a2dbd798f 100644
--- a/gnu/tests/mail.scm
+++ b/gnu/tests/mail.scm
@@ -301,8 +301,19 @@ (define %dovecot-os
                      (auth-anonymous-username "alice")
                      (mail-location
                       (string-append "maildir:~/Maildir"
-                                     ":INBOX=~/Maildir/INBOX"
-                                     ":LAYOUT=fs"))))))
+                                     ":LAYOUT=fs"))
+                     (namespaces
+                      (list
+                       (namespace-configuration
+                        (name "INBOX")
+                        (inbox? #t)
+                        (separator "/")
+                        (location "maildir:~/Maildir/INBOX"))
+                       (namespace-configuration
+                        (name "guix-devel")
+                        (separator "/")
+                        (prefix "guix-devel/")
+                        (location "maildir:~/Maildir/guix-devel"))))))))
 
 (define (run-dovecot-test)
   "Return a test of an OS running Dovecot service."
@@ -351,9 +362,10 @@ (define message "From: test@example.com\n\
               (marionette-eval `(file-exists? (string-append "/proc/" ,pid))
                                marionette)))
 
-          (test-assert "accept an email"
+          (define-syntax-rule (with-imap-connection imap exp ...)
             (let ((imap (socket AF_INET SOCK_STREAM 0))
-                  (addr (make-socket-address AF_INET INADDR_LOOPBACK 8143)))
+                  (addr (make-socket-address AF_INET INADDR_LOOPBACK 8143))
+                  (body (lambda (imap) exp ...)))
               (connect imap addr)
               ;; Be greeted.
               (read-line imap) ;OK
@@ -362,6 +374,43 @@ (define message "From: test@example.com\n\
               (read-line imap) ;+
               (write-line "c2lyaGM=" imap)
               (read-line imap) ;OK
+
+              (let ((ok (body imap)))
+                ;; Logout
+                (write-line "a LOGOUT" imap)
+                (close imap)
+                ok)))
+
+          (define (marionette-read-new-mail mailbox marionette)
+            (marionette-eval
+             `(begin
+                (use-modules (ice-9 ftw)
+                             (ice-9 match))
+                (match (scandir ,mailbox)
+                  (("." ".." message-file)
+                   (call-with-input-file
+                       (string-append ,mailbox message-file)
+                     get-string-all))))
+             marionette))
+
+          (test-assert "accept an email"
+            (with-imap-connection imap
+              ;; Append a message to the INBOX mailbox
+              (write-line (format #f "a APPEND INBOX {~a}"
+                                  (number->string (message-length message)))
+                          imap)
+              (read-line imap) ;+
+              (write-line message imap)
+              (read-line imap) ;OK
+              #t))
+
+          (test-equal "mail arrived"
+            message
+            (marionette-read-new-mail "/home/alice/Maildir/INBOX/new/"
+                                      marionette))
+
+          (test-assert "accept an email in fresh mailbox"
+            (with-imap-connection imap
               ;; Create a TESTBOX mailbox
               (write-line "a CREATE TESTBOX" imap)
               (read-line imap) ;OK
@@ -372,24 +421,16 @@ (define message "From: test@example.com\n\
               (read-line imap) ;+
               (write-line message imap)
               (read-line imap) ;OK
-              ;; Logout
-              (write-line "a LOGOUT" imap)
-              (close imap)
               #t))
 
-          (test-equal "mail arrived"
+          (test-equal "mail arrived in fresh mailbox"
             message
-            (marionette-eval
-             '(begin
-                (use-modules (ice-9 ftw)
-                             (ice-9 match))
-                (let ((TESTBOX/new "/home/alice/Maildir/TESTBOX/new/"))
-                  (match (scandir TESTBOX/new)
-                    (("." ".." message-file)
-                     (call-with-input-file
-                         (string-append TESTBOX/new message-file)
-                       get-string-all)))))
-             marionette))
+            (marionette-read-new-mail "/home/alice/Maildir/TESTBOX/new/"
+                                      marionette))
+
+          (test-assert "mailbox exists"
+            (marionette-eval `(file-exists? "/home/alice/Maildir/guix-devel")
+                             marionette))
 
           (test-end))))
 

[-- Attachment #3: Type: text/plain, Size: 17 bytes --]


Thanks,
Pierre


  parent reply	other threads:[~2022-12-01 22:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 21:53 bug#59423: Invalid 'location' field generated in dovecot configuration Pierre Langlois
2022-11-22  8:10 ` Ludovic Courtès
2022-11-25 15:36   ` Maxim Cournoyer
2022-11-25 20:19     ` Pierre Langlois
2022-11-25 19:17 ` mirai
2022-11-25 20:06 ` Maxim Cournoyer
2022-11-25 20:25   ` Pierre Langlois
2022-11-25 20:50     ` Pierre Langlois
2022-11-25 21:09       ` Pierre Langlois
2022-11-26  2:54         ` Maxim Cournoyer
2022-11-26 19:32           ` Pierre Langlois
2022-11-27  2:33             ` Maxim Cournoyer
2022-11-28 15:01               ` Ludovic Courtès
2022-11-28 20:00                 ` Maxim Cournoyer
2022-11-28 21:33                   ` Ludovic Courtès
2022-11-29  1:58                     ` Maxim Cournoyer
2022-12-02  9:30                       ` Ludovic Courtès
2022-12-02 21:18                         ` Ludovic Courtès
2022-12-03  3:05                           ` Maxim Cournoyer
2022-12-04 16:53                             ` Ludovic Courtès
2022-12-04 21:43                               ` Maxim Cournoyer
2022-12-06  8:53                                 ` Ludovic Courtès
2022-12-01 20:29                   ` Pierre Langlois
2022-11-26 23:17 ` Fredrik Salomonsson
2022-12-01 21:55 ` Pierre Langlois [this message]
2022-12-03  2:24   ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87359ydbnq.fsf@gmx.com \
    --to=pierre.langlois@gmx.com \
    --cc=59423@debbugs.gnu.org \
    --cc=mirai@makinata.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).