From patchwork Thu Nov 21 12:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Abramov X-Patchwork-Id: 70623 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7024A27BBEA; Thu, 21 Nov 2024 12:27:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D48AD27BBE2 for ; Thu, 21 Nov 2024 12:27:42 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE6HA-0008Bd-B8; Thu, 21 Nov 2024 07:27:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tE6H2-0008AT-5b for guix-patches@gnu.org; Thu, 21 Nov 2024 07:27:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE6H1-00025i-T2 for guix-patches@gnu.org; Thu, 21 Nov 2024 07:27:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=2179E/YnXyM8ZBbGZmXQ1H6HB96ZBNNJdJEakthEzjk=; b=At7mvQls+lJEbBFrDhyZ+V+XMEGv4g0UXBT9qzGCyRwq4S3BSLmhg+r0VOWL+p2D4186mQTm7lq2rLladqEalKDTp8p42SWWVE7TLUYnyRVMM3Jh4VTM9BR3rWTgC/v+aXyVEiLFOgmtedpvp6T74to3iXhaIa01+VChLycVtpGs6aBciGR/HyOAW/sae1mBEJ0hpGde075mvCbHr+iW4EexPudmza/PcUySfLmqSIEeVOMI/OIjAnP5g9KGRVsrApLJ5RONfKa8Pu7oMc/SNkPsn7rTuoXAubdqAsAPCkf56B2dnQuXFuMWZyaxOY+wMp0mRKoKvOyGTnNuICaHmQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tE6H1-000890-O7 for guix-patches@gnu.org; Thu, 21 Nov 2024 07:27:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#42899] [PATCH v6 3/3] tests: dovecot: Add sieve. Resent-From: Alexey Abramov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 21 Nov 2024 12:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42899 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42899@debbugs.gnu.org Received: via spool by 42899-submit@debbugs.gnu.org id=B42899.173219197631214 (code B ref 42899); Thu, 21 Nov 2024 12:27:03 +0000 Received: (at 42899) by debbugs.gnu.org; 21 Nov 2024 12:26:16 +0000 Received: from localhost ([127.0.0.1]:49395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tE6GF-00087I-Jj for submit@debbugs.gnu.org; Thu, 21 Nov 2024 07:26:16 -0500 Received: from mail.mmer.org ([178.22.65.174]:58744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tE6GC-00086V-6q for 42899@debbugs.gnu.org; Thu, 21 Nov 2024 07:26:12 -0500 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 3e5fba11 for <42899@debbugs.gnu.org>; Thu, 21 Nov 2024 12:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=UbmnPpHQzLSxIROX3fbzqvygM WgSBEOfWq5L0axxHGQ=; b=Lg5HQWL2SY3R1X99BY1xcp+Xlbej1mV5Uv9IT71cf u7jcCMani9QSXhEgjcXuZoG70MJOUUKO8KH1q1DbcIkgQGW5cJSwdHDhYOv6aL7k nfzKpOytDQwIqzDR5jo98HD0i2V2Oww9hE3P46ZvghLCzhgY4DMCSOVhzIazd8LU CY= Received: from delta (142-212-98-95.ftth.glasoperator.nl [95.98.212.142]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 01f15c1f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <42899@debbugs.gnu.org>; Thu, 21 Nov 2024 12:25:59 +0000 (UTC) Date: Thu, 21 Nov 2024 12:25:58 +0000 Message-ID: <20241121122558.8617-4-levenson@mmer.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241121122558.8617-1-levenson@mmer.org> References: <20241121122558.8617-1-levenson@mmer.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Alexey Abramov X-ACL-Warn: , Alexey Abramov via Guix-patches X-Patchwork-Original-From: Alexey Abramov via Guix-patches via From: Alexey Abramov Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/mail.scm (%dovecot-os): Add dovecot-pigeonhole and simple imapsieve configuration. * gnu/tests/mail.scm (run-dovecot-test): Define simple sieve script. Add SELECT TESTBOX step to let dovecot properly do mailbox synchronization. --- gnu/tests/mail.scm | 67 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm index 176e7c1d074..3b498b5b575 100644 --- a/gnu/tests/mail.scm +++ b/gnu/tests/mail.scm @@ -297,10 +297,42 @@ (define %dovecot-os (service dhcp-client-service-type) (service dovecot-service-type (dovecot-configuration + (extensions (list dovecot-pigeonhole)) (disable-plaintext-auth? #f) + ;; Required for sieve! + (postmaster-address "postmaster@komputilo") (ssl? "no") (auth-mechanisms '("anonymous")) (auth-anonymous-username "alice") + (protocols + (list (protocol-configuration + (name "imap") + (mail-plugins '("$mail_plugins" "imap_sieve")) + (imap-metadata? #t)))) + + (plugin-configuration + (plugin-configuration + (entries (list + (cons 'sieve-global "/tmp") + (cons 'sieve-extensions "+editheader") + + (cons 'imapsieve-mailbox1-name "*") + (cons 'imapsieve-mailbox1-causes "APPEND") + ;; Run the script *before* the user scripts + (cons 'imapsieve-mailbox1-before "file:/tmp/main.sieve") + ;; We want to automatically remove original email + (cons 'imapsieve-expunge-discarded "yes") + + (cons 'sieve-trace-debug "yes") + (cons 'sieve-trace-dir "/tmp") + (cons 'sieve-trace-level "tests") + (cons 'sieve-plugins "sieve_imapsieve") + ;; You cannot run scripts anywhere you want + ;; Sieve allows you to only run scripts under + ;; sieve_pipe_bin_dir. + (cons 'sieve-pipe-bin-dir "/tmp") + )))) + (mail-location (string-append "maildir:~/Maildir" ":INBOX=~/Maildir/INBOX" @@ -334,6 +366,18 @@ (define* (message-length message #:key (encoding "iso-8859-1")) (define message "From: test@example.com\n\ Subject: Hello Nice to meet you!") + (define sieve-script + "require \"editheader\";\n +addheader \"X-Sieve-Filtered\" \"Guix\"; +") + ;; Install our sieve script + (marionette-eval + `(begin + (with-output-to-file "/tmp/main.sieve" + (lambda () + (display ,sieve-script)))) + marionette) + (test-runner-current (system-test-runner #$output)) (test-begin "dovecot") @@ -367,6 +411,19 @@ (define message "From: test@example.com\n\ ;; Create a TESTBOX mailbox (write-line "a CREATE TESTBOX" imap) (read-line imap) ;OK + ;; Select mailbox. This is required so that dovecot did + ;; synchronization correctly. + (write-line "a SELECT TESTBOX" imap) + ;; ("* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\r") + ;; ("* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft \\*)] Flags permitted.\r") + ;; ("* 1 EXISTS\r") + ;; ("* 1 RECENT\r") + ;; ("* OK [UNSEEN 1] First unseen.\r") + ;; ("* OK [UIDVALIDITY 1732177859] UIDs valid\r") + ;; ("* OK [UIDNEXT 3] Predicted next UID\r") + (for-each (lambda (n) + (read-line imap)) + (iota 7)) ;; Append a message to a TESTBOX mailbox (write-line (format #f "a APPEND TESTBOX {~a}" (number->string (message-length message))) @@ -380,18 +437,18 @@ (define message "From: test@example.com\n\ #t)) (test-equal "mail arrived" - message + (string-join (list "X-Sieve-Filtered: Guix" message) "\n") (marionette-eval '(begin (use-modules (ice-9 ftw) (ice-9 match) (rnrs io ports)) - - (let ((TESTBOX/new "/home/alice/Maildir/TESTBOX/new/")) - (match (scandir TESTBOX/new) + ;; XXX: We expect a new email in /cur directory + (let ((TESTBOX/cur "/home/alice/Maildir/TESTBOX/cur/")) + (match (scandir TESTBOX/cur) (("." ".." message-file) (call-with-input-file - (string-append TESTBOX/new message-file) + (string-append TESTBOX/cur message-file) get-string-all))))) marionette))