3 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
6 if test -z "$GIT_TEST_HTTPD"
8 skip_all
="Network testing disabled (define GIT_TEST_HTTPD to enable)"
14 for DEFAULT_HTTPD_PATH
in '/usr/sbin/httpd' '/usr/sbin/apache2'
16 if test -x "$DEFAULT_HTTPD_PATH"
22 for DEFAULT_HTTPD_MODULE_PATH
in '/usr/libexec/apache2' \
23 '/usr/lib/apache2/modules' \
24 '/usr/lib64/httpd/modules' \
25 '/usr/lib/httpd/modules'
27 if test -d "$DEFAULT_HTTPD_MODULE_PATH"
35 HTTPD_PARA
="$HTTPD_PARA -DDarwin"
39 LIB_HTTPD_PATH
=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
40 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'8111'}
42 TEST_PATH
="$TEST_DIRECTORY"/lib-httpd
43 HTTPD_ROOT_PATH
="$PWD"/httpd
44 HTTPD_DOCUMENT_ROOT_PATH
=$HTTPD_ROOT_PATH/www
46 # hack to suppress apache PassEnv warnings
47 GIT_VALGRIND
=$GIT_VALGRIND; export GIT_VALGRIND
48 GIT_VALGRIND_OPTIONS
=$GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS
50 if ! test -x "$LIB_HTTPD_PATH"
52 skip_all
="skipping test, no web server found at '$LIB_HTTPD_PATH'"
56 HTTPD_VERSION
=`$LIB_HTTPD_PATH -v | \
57 sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
59 if test -n "$HTTPD_VERSION"
61 if test -z "$LIB_HTTPD_MODULE_PATH"
63 if ! test $HTTPD_VERSION -ge 2
65 skip_all
="skipping test, at least Apache version 2 is required"
68 if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
70 skip_all
="Apache module directory not found. Skipping tests."
74 LIB_HTTPD_MODULE_PATH
="$DEFAULT_HTTPD_MODULE_PATH"
77 error
"Could not identify web server at '$LIB_HTTPD_PATH'"
81 mkdir
-p "$HTTPD_DOCUMENT_ROOT_PATH"
82 cp "$TEST_PATH"/passwd
"$HTTPD_ROOT_PATH"
83 cp "$TEST_PATH"/broken-smart-http.sh
"$HTTPD_ROOT_PATH"
85 ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
87 if test -n "$LIB_HTTPD_SSL"
91 RANDFILE_PATH
="$HTTPD_ROOT_PATH"/.rnd openssl req \
92 -config "$TEST_PATH/ssl.cnf" \
94 -out "$HTTPD_ROOT_PATH/httpd.pem" \
95 -keyout "$HTTPD_ROOT_PATH/httpd.pem"
97 export GIT_SSL_NO_VERIFY
98 HTTPD_PARA
="$HTTPD_PARA -DSSL"
102 HTTPD_DEST
=127.0.0.1:$LIB_HTTPD_PORT
103 HTTPD_URL
=$HTTPD_PROTO://$HTTPD_DEST
104 HTTPD_URL_USER
=$HTTPD_PROTO://user
%40host@
$HTTPD_DEST
105 HTTPD_URL_USER_PASS
=$HTTPD_PROTO://user
%40host:user
%40host@
$HTTPD_DEST
107 if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
109 HTTPD_PARA
="$HTTPD_PARA -DDAV"
111 if test -n "$LIB_HTTPD_SVN"
113 HTTPD_PARA
="$HTTPD_PARA -DSVN"
114 rawsvnrepo
="$HTTPD_ROOT_PATH/svnrepo"
115 svnrepo
="http://127.0.0.1:$LIB_HTTPD_PORT/svn"
121 prepare_httpd
>&3 2>&4
123 trap 'code=$?; stop_httpd; (exit $code); die' EXIT
125 "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
126 -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
127 -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
131 skip_all
="skipping test, web server setup failed"
140 "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
141 -f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
144 test_http_push_nonff
() {
149 test_expect_success
'non-fast-forward push fails' '
151 HEAD=$(git rev-parse --verify HEAD) &&
154 git checkout $BRANCH &&
155 echo "changed" > path2 &&
156 git commit -a -m path2 --amend &&
158 test_must_fail git push -v origin >output 2>&1 &&
159 (cd "$REMOTE_REPO" &&
160 test $HEAD = $(git rev-parse --verify HEAD))
163 test_expect_success
'non-fast-forward push show ref status' '
164 grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output
167 test_expect_success
'non-fast-forward push shows help message' '
168 test_i18ngrep "Updates were rejected because" output
172 setup_askpass_helper
() {
173 test_expect_success
'setup askpass helper' '
174 write_script "$TRASH_DIRECTORY/askpass" <<-\EOF &&
175 echo >>"$TRASH_DIRECTORY/askpass-query" "askpass: $*" &&
176 cat "$TRASH_DIRECTORY/askpass-response"
178 GIT_ASKPASS="$TRASH_DIRECTORY/askpass" &&
179 export GIT_ASKPASS &&
180 export TRASH_DIRECTORY
185 >"$TRASH_DIRECTORY/askpass-query" &&
186 echo "$*" >"$TRASH_DIRECTORY/askpass-response"
196 echo "askpass: Password for 'http://$2@$dest': "
199 echo "askpass: Username for 'http://$dest': "
200 echo "askpass: Password for 'http://$2@$dest': "
206 } >"$TRASH_DIRECTORY/askpass-expect" &&
207 test_cmp
"$TRASH_DIRECTORY/askpass-expect" \
208 "$TRASH_DIRECTORY/askpass-query"