From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4OllJYMHVGAuEQAA0tVLHw (envelope-from ) for ; Fri, 19 Mar 2021 02:08:03 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4CMhIYMHVGCvIAAAbx9fmQ (envelope-from ) for ; Fri, 19 Mar 2021 02:08:03 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F2814E327 for ; Fri, 19 Mar 2021 03:08:02 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id EB75327126; Thu, 18 Mar 2021 22:07:53 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 76B9220613 for ; Thu, 18 Mar 2021 22:07:50 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id AB1A15FA96; Thu, 18 Mar 2021 22:07:48 -0400 (EDT) Received: (nullmailer pid 1491993 invoked by uid 1000); Fri, 19 Mar 2021 02:07:47 -0000 From: David Bremner To: Matthew Lear , notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 1/2] test: Add tests for write access to database from hooks. Date: Thu, 18 Mar 2021 23:07:42 -0300 Message-Id: <20210319020743.1491945-1-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk> References: <9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk> MIME-Version: 1.0 Message-ID-Hash: D5ZODP7MAP6NXCCW4BR3IZD7YYFGO4YI X-Message-ID-Hash: D5ZODP7MAP6NXCCW4BR3IZD7YYFGO4YI X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616119683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UInfZk0wvMN4akMYrodGXTPcsX+XtvP8fScmkz5t48U=; b=pv9BB2GLBdrBt0HJPcCYZJNcwTtMhsAiTmr4YMft2WYU5rB1HsTTobDYWZFYoJytmqNJ8H Y/QFj4W/i+2ezu456QcHNjxlfq5cLNMBdHl52KwptncQ3gjZQZnpKyBjsvdbFqeHb1d1v3 dj/Y7w3tcvnS7vgqgxsBloPVH95UNYMGGq3k+wavc7dAeNRrNMA4xHQLGbQiRZXxVEsQlw YQwVBk9jKudJVtS8S5Iz1SelwXb3DTGRJTz5CBm+xh5hMJNlZahSDB8HHRXzC7qx1KtpF7 5lH3EWr9T8kF/aR0F37A7LAYg82hWi1YBaHCuxaGMAefsh84FZI1lSaN3aIM0w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616119683; a=rsa-sha256; cv=none; b=qTtwQJjUWNwmo1LG0v0yZ9fwompQNRgLk1OQ6Is3X4glihtgmBtORlQ4FkpaVGgwD3wDMx pyOiq5fgJJJPmtiNfQOKEZ1Gh28d+YAw7QGzrijoZM2mRR7HIk4OWGDQX5QV1C9QhhqWX+ WNr5sP+CQXsbeGbPEcVaN5FQcJ5FnVVlOlBTMoGOvY/0A/AIjHYbZd5XuK6eN2Mhot9xLP fLSYuOG7S65o2ntqD7FWfvT1OB4juSB2xdD8WpH3bPlYxKuESSsL2bR1i2jbH3YCORn8yG fsSzH7PpNPV4TSJW+589a/5Tiwv7NWPXThRAsU25fS67nAvwdL96FN5qZvemRQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.10 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: F2814E327 X-Spam-Score: -1.10 X-Migadu-Scanner: scn0.migadu.com X-TUID: uCfFbdayNY0c Recent changes to configuration handling meant the pre-new hook was run while the database was open read only, limiting what could be done in the hook. Add some known broken tests for this problem, as well as a regression test for write access from the post-new hook. --- test/T400-hooks.sh | 28 ++++++++++++++++++++++++++++ test/test-lib.sh | 1 + 2 files changed, 29 insertions(+) diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh index a3dd4c63..a2b67d59 100755 --- a/test/T400-hooks.sh +++ b/test/T400-hooks.sh @@ -2,6 +2,8 @@ test_description='hooks' . $(dirname "$0")/test-lib.sh || exit 1 +test_require_external_prereq xapian-delve + create_echo_hook () { local TOKEN="${RANDOM}" mkdir -p ${HOOK_DIR} @@ -13,6 +15,19 @@ EOF echo "${TOKEN}" > ${2} } +create_write_hook () { + local TOKEN="${RANDOM}" + mkdir -p ${HOOK_DIR} + cat <"${HOOK_DIR}/${1}" +#!/bin/sh +if xapian-delve ${MAIL_DIR}/.notmuch/xapian | grep -q "writing = false"; then + echo "${TOKEN}" > ${3} +fi +EOF + chmod +x "${HOOK_DIR}/${1}" + echo "${TOKEN}" > ${2} +} + create_failing_hook () { local HOOK_DIR=${2} mkdir -p ${HOOK_DIR} @@ -137,6 +152,19 @@ EOF chmod +x "${HOOK_DIR}/pre-new" test_expect_code 1 "notmuch new" + test_begin_subtest "post-new with write access [${config}]" + rm -rf ${HOOK_DIR} + create_write_hook "post-new" write.expected write.output $HOOK_DIR + NOTMUCH_NEW + test_expect_equal_file write.expected write.output + + test_begin_subtest "pre-new with write access [${config}]" + test_subtest_known_broken + rm -rf ${HOOK_DIR} + create_write_hook "pre-new" write.expected write.output $HOOK_DIR + NOTMUCH_NEW + test_expect_equal_file write.expected write.output + rm -rf ${HOOK_DIR} done test_done diff --git a/test/test-lib.sh b/test/test-lib.sh index 29baa0c1..fc176af8 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1271,3 +1271,4 @@ test_declare_external_prereq openssl test_declare_external_prereq gpgsm test_declare_external_prereq ${NOTMUCH_PYTHON} test_declare_external_prereq xapian-metadata +test_declare_external_prereq xapian-delve -- 2.30.2