summaryrefslogtreecommitdiff
path: root/t/t5541-http-push-smart.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-03-30 18:01:11 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-03-30 18:01:11 -0700
commita5bf611cc4f14f062cd74965deafe617048bff05 (patch)
tree47dd4d166bf8dc324a619d591ad03b918a93211a /t/t5541-http-push-smart.sh
parentMerge branch 'jd/prompt-upstream-mark' (diff)
parenthttp tests: use "test_hook" for "smart" and "dumb" http tests (diff)
downloadtgif-a5bf611cc4f14f062cd74965deafe617048bff05.tar.xz
Merge branch 'ab/hook-tests-updates'
Update tests around the use of hook scripts. * ab/hook-tests-updates: http tests: use "test_hook" for "smart" and "dumb" http tests proc-receive hook tests: use "test_hook" instead of "write_script" tests: extend "test_hook" for "rm" and "chmod -x", convert "$HOOK" tests: use "test_hook" for misc "mkdir -p" and "chmod" cases tests: change "mkdir -p && write_script" to use "test_hook" tests: change "cat && chmod +x" to use "test_hook" gc + p4 tests: use "test_hook", remove sub-shells fetch+push tests: use "test_hook" and "test_when_finished" pattern bugreport tests: tighten up "git bugreport -s hooks" test tests: assume the hooks are disabled by default http tests: don't rely on "hook/post-update.sample" hook tests: turn exit code assertions into a loop test-lib-functions: add and use a "test_hook" wrapper
Diffstat (limited to 't/t5541-http-push-smart.sh')
-rwxr-xr-xt/t5541-http-push-smart.sh32
1 files changed, 15 insertions, 17 deletions
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index 8ca50f8b18..2f09ff4fac 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -96,18 +96,18 @@ test_expect_success 'create and delete remote branch' '
test_must_fail git show-ref --verify refs/remotes/origin/dev
'
-cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
-#!/bin/sh
-exit 1
-EOF
-chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
+test_expect_success 'setup rejected update hook' '
+ test_hook --setup -C "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" update <<-\EOF &&
+ exit 1
+ EOF
-cat >exp <<EOF
-remote: error: hook declined to update refs/heads/dev2
-To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
- ! [remote rejected] dev2 -> dev2 (hook declined)
-error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'
-EOF
+ cat >exp <<-EOF
+ remote: error: hook declined to update refs/heads/dev2
+ To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
+ ! [remote rejected] dev2 -> dev2 (hook declined)
+ error: failed to push some refs to '\''http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'\''
+ EOF
+'
test_expect_success 'rejected update prints status' '
cd "$ROOT_PATH"/test_repo_clone &&
@@ -419,10 +419,7 @@ test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' '
'
test_expect_success GPG 'push with post-receive to inspect certificate' '
- (
- cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
- mkdir -p hooks &&
- write_script hooks/post-receive <<-\EOF &&
+ test_hook -C "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git post-receive <<-\EOF &&
# discard the update list
cat >/dev/null
# record the push certificate
@@ -437,8 +434,9 @@ test_expect_success GPG 'push with post-receive to inspect certificate' '
NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
NONCE=${GIT_PUSH_CERT_NONCE-nononce}
E_O_F
- EOF
-
+ EOF
+ (
+ cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
git config receive.certnonceseed sekrit &&
git config receive.certnonceslop 30
) &&