From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Pierre Langlois <pierre.langlois@gmx.com>
Cc: mirai <mirai@makinata.eu>, 59423@debbugs.gnu.org
Subject: bug#59423: Invalid 'location' field generated in dovecot configuration
Date: Fri, 02 Dec 2022 21:24:29 -0500 [thread overview]
Message-ID: <878rjpgr6q.fsf@gmail.com> (raw)
In-Reply-To: <87359ydbnq.fsf@gmx.com> (Pierre Langlois's message of "Thu, 01 Dec 2022 21:55:27 +0000")
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
Hi Pierre,
Pierre Langlois <pierre.langlois@gmx.com> writes:
> 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.
Thanks for the diff! I've turned it into a patch and was ready to apply
it, but 2 tests are always failing, even after addressing this issue;
could you look into why? It looks good otherwise.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-tests-Expound-Dovecot-test-suite.patch --]
[-- Type: text/x-patch, Size: 5531 bytes --]
From 149790c4bd264d81938596cdbfa3376f31f9182f Mon Sep 17 00:00:00 2001
From: Pierre Langlois <pierre.langlois@gmx.com>
Date: Fri, 2 Dec 2022 14:17:25 -0500
Subject: [PATCH] tests: Expound Dovecot test suite.
Relates to <https://issues.guix.gnu.org/59423>.
* gnu/tests/mail.scm (%dovecot-os) [services] <dovecot-configuration>: Add two
namespaces.
(run-dovecot-test) <with-imap-connection>: New syntax.
<marionette-read-new-mail>: New test.
<accept an email>: Use with-imap-connection.
<mail arrived in fresh mailbox>: New test.
<mail arrived>: Adjust test.
<mailbox exists>: New test.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
gnu/tests/mail.scm | 79 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 19 deletions(-)
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))))
base-commit: 83350bf56b20f3106cd9eeab80b70a9eaf810a48
--
2.38.1
[-- Attachment #3: Type: text/plain, Size: 19 bytes --]
--
Thanks,
Maxim
prev parent reply other threads:[~2022-12-03 3:07 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
2022-12-03 2:24 ` Maxim Cournoyer [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878rjpgr6q.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=59423@debbugs.gnu.org \
--cc=mirai@makinata.eu \
--cc=pierre.langlois@gmx.com \
/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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.