From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- t/t5411/test-0014-bad-protocol--porcelain.sh | 304 +++++++++++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 t/t5411/test-0014-bad-protocol--porcelain.sh (limited to 't/t5411/test-0014-bad-protocol--porcelain.sh') diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh new file mode 100644 index 0000000..298a3d1 --- /dev/null +++ b/t/t5411/test-0014-bad-protocol--porcelain.sh @@ -0,0 +1,304 @@ +test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --version 2 + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output actual && + + # Check status report for git-push + sed -n \ + -e "/^To / { p; n; p; n; p; }" \ + actual-report && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual-report && + + # Check error message from "receive-pack", but ignore unstable fatal error + # message ("remote: fatal: the remote end hung up unexpectedly") which + # is different from the remote HTTP server with different locale settings. + grep "^remote: error:" actual-error && + format_and_save_expect <<-EOF && + > remote: error: proc-receive version "2" is not supported Z + EOF + test_cmp expect actual-error && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --die-read-version + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + filter_out_user_friendly_and_stable_output \ + -e "/^To / { p; n; p; n; p; }" \ + actual && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual && + grep "remote: fatal: die with the --die-read-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --die-write-version + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + filter_out_user_friendly_and_stable_output \ + -e "/^To / { p; n; p; n; p; }" \ + actual && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual && + grep "remote: fatal: die with the --die-write-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --die-read-commands + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + filter_out_user_friendly_and_stable_output \ + -e "/^To / { p; n; p; n; p; }" \ + actual && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual && + grep "remote: fatal: die with the --die-read-commands option" out-$test_count && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --die-read-push-options + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $PROTOCOL/porcelain)" ' + git -C "$upstream" config receive.advertisePushOptions true && + test_must_fail git -C workbench push --porcelain origin \ + -o reviewers=user1,user2 \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + filter_out_user_friendly_and_stable_output \ + -e "/^To / { p; n; p; n; p; }" \ + actual && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual && + grep "remote: fatal: die with the --die-read-push-options option" out-$test_count && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v --die-write-report + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + filter_out_user_friendly_and_stable_output \ + -e "/^To / { p; n; p; n; p; }" \ + actual && + cat >expect <<-EOF && + To + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) + Done + EOF + test_cmp expect actual && + grep "remote: fatal: die with the --die-write-report option" out-$test_count && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : next(A) refs/for/main/topic(A) +test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/heads/next \ + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/heads/next Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< refs/heads/next Z + > To + > * HEAD:refs/heads/next [new branch] + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done + EOF + test_cmp expect actual && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + refs/heads/next + EOF +' + +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 +test_expect_success "cleanup ($PROTOCOL/porcelain)" ' + git -C "$upstream" update-ref -d refs/heads/next +' + +test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v \ + -r "ok" + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic +test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic\ + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> ok Z + > remote: error: proc-receive reported incomplete status line: "ok" Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done + EOF + test_cmp expect actual && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' + +test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelain)" ' + test_hook -C "$upstream" --clobber proc-receive <<-\EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v \ + -r "xx refs/for/main/topic" + EOF +' + +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic +test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porcelain)" ' + test_must_fail git -C workbench push --porcelain origin \ + HEAD:refs/for/main/topic \ + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< refs/for/main/topic Z + > remote: proc-receive> xx refs/for/main/topic Z + > remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z + > To + > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) + > Done + EOF + test_cmp expect actual && + + test_cmp_refs -C "$upstream" <<-EOF + refs/heads/main + EOF +' -- cgit v1.2.3