git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Carlos Martín Nieto" <cmn@dwim.me>
To: git@vger.kernel.org
Cc: "Carlos Martín Nieto" <cmn@dwim.me>
Subject: [PATCH 3/4] t5541: add test for rejecting a push due to packfile size
Date: Wed, 12 Jun 2024 13:50:27 +0200	[thread overview]
Message-ID: <20240612115028.1169183-4-cmn@dwim.me> (raw)
In-Reply-To: <20240612115028.1169183-1-cmn@dwim.me>

This rejection requires us to make sure we handle this kind of error
correctly rather than throw away the report in remote-curl and end up
with "Everything up-to-date" due to the lack of report.

Signed-off-by: Carlos Martín Nieto <cmn@dwim.me>
---
 t/t5546-receive-limits.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/t/t5546-receive-limits.sh b/t/t5546-receive-limits.sh
index 9fc9ba552f1..ccbdf3945ab 100755
--- a/t/t5546-receive-limits.sh
+++ b/t/t5546-receive-limits.sh
@@ -5,6 +5,11 @@ test_description='check receive input limits'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+
+ROOT_PATH="$PWD"
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_serve_git
+
 # Let's run tests with different unpack limits: 1 and 10000
 # When the limit is 1, `git receive-pack` will call `git index-pack`.
 # When the limit is 10000, `git receive-pack` will call `git unpack-objects`.
@@ -83,4 +88,23 @@ test_expect_success "create known-size (1024 bytes) commit" '
 test_pack_input_limit index
 test_pack_input_limit unpack
 
+test_expect_success 'reject too-large push over HTTP' '
+	git init "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" &&
+	git -C "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" config receive.maxInputSize 128 &&
+	test-tool genrandom foo $((10*1024*1024)) >large-file &&
+	git add large-file &&
+	test_commit large-file &&
+	test_must_fail git push --porcelain \
+		$GIT_SERVE_URL/error_too_large \
+		HEAD:refs/tags/will-fail >actual &&
+	test_must_fail git -C "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" \
+		rev-parse --verify refs/tags/will-fail &&
+	cat >expect <<-EOF &&
+	To $GIT_SERVE_URL/error_too_large
+	!	HEAD:refs/tags/will-fail	[remote rejected] (unpacker error)
+	Done
+	EOF
+	test_cmp expect actual
+'
+
 test_done
-- 
2.43.0


  parent reply	other threads:[~2024-06-12 11:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 11:50 [PATCH 0/4] Report rejections over HTTP when the remote rejects during the transfer Carlos Martín Nieto
2024-06-12 11:50 ` [PATCH 1/4] t/lib-http: add serve-git.py Carlos Martín Nieto
2024-06-12 21:51   ` Junio C Hamano
2024-06-12 11:50 ` [PATCH 2/4] t/lib-http.sh: add functions related to serve-git.py Carlos Martín Nieto
2024-06-13  9:19   ` Jeff King
2024-06-12 11:50 ` Carlos Martín Nieto [this message]
2024-06-12 21:49   ` [PATCH 3/4] t5541: add test for rejecting a push due to packfile size Taylor Blau
2024-06-13  9:21   ` Jeff King
2024-06-13 10:07   ` Jeff King
2024-06-12 11:50 ` [PATCH 4/4] remote-curl: read in the push report even if we fail to finish sending data Carlos Martín Nieto
2024-06-13  9:55   ` Jeff King
2024-07-23 15:07     ` Carlos Martín Nieto
2024-06-13  9:11 ` [PATCH 0/4] Report rejections over HTTP when the remote rejects during the transfer Jeff King
2024-07-23 13:46   ` Carlos Martín Nieto

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=20240612115028.1169183-4-cmn@dwim.me \
    --to=cmn@dwim.me \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).