Skip to content

Commit eb1c42d

Browse files
peffgitster
authored andcommitted
t/lib-httpd: make CGIPassAuth support conditional
Commit 988aad9 (t5563: add tests for basic and anoymous HTTP access, 2023-02-27) added tests that require Apache to support the CGIPassAuth directive, which was added in Apache 2.4.13. This is fairly old (~8 years), but recent enough that we still encounter it in the wild (e.g., RHEL/CentOS 7, which is not EOL until June 2024). We can live with skipping the new tests on such a platform. But unfortunately, since the directive is used unconditionally in our apache.conf, it means the web server fails to start entirely, and we cannot run other HTTP tests at all (e.g., the basic ones in t5551). We can fix that by making the config conditional, and only triggering it for t5563. That solves the problem for t5551 (which then ignores the directive entirely). For t5563, we'd see apache complain in start_httpd; with the default setting of GIT_TEST_HTTPD, we'd then skip the whole script. But that leaves one small problem: people may set GIT_TEST_HTTPD=1 explicitly, which instructs the tests to fail (rather than skip) when we can't start the webserver (to avoid accidentally missing some tests). This could be worked around by having the user manually set GIT_SKIP_TESTS on a platform with an older Apache. But we can be a bit friendlier by doing the version check ourselves and setting an appropriate prereq. We'll use the (lack of) prereq to then skip the rest of t5563. In theory we could use the prereq to skip individual tests, but in practice this whole script depends on it. Reported-by: Todd Zullinger <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f2117b commit eb1c42d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

t/lib-httpd.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ enable_http2 () {
181181
test_set_prereq HTTP2
182182
}
183183

184+
enable_cgipassauth () {
185+
# We are looking for 2.4.13 or more recent. Since we only support
186+
# 2.4 and up, no need to check for older major/minor.
187+
if test "$HTTPD_VERSION_MAJOR" = 2 &&
188+
test "$HTTPD_VERSION_MINOR" = 4 &&
189+
test "$(echo $HTTPD_VERSION | cut -d. -f3)" -lt 13
190+
then
191+
echo >&4 "apache $HTTPD_VERSION too old for CGIPassAuth"
192+
return
193+
fi
194+
HTTPD_PARA="$HTTPD_PARA -DUSE_CGIPASSAUTH"
195+
test_set_prereq CGIPASSAUTH
196+
}
197+
184198
start_httpd() {
185199
prepare_httpd >&3 2>&4
186200

t/lib-httpd/apache.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ Alias /auth/dumb/ www/auth/dumb/
138138
<LocationMatch /custom_auth/>
139139
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
140140
SetEnv GIT_HTTP_EXPORT_ALL
141+
<IfDefine USE_CGIPASSAUTH>
141142
CGIPassAuth on
143+
</IfDefine>
142144
</LocationMatch>
143145
ScriptAlias /smart/incomplete_length/git-upload-pack incomplete-length-upload-pack-v2-http.sh/
144146
ScriptAlias /smart/incomplete_body/git-upload-pack incomplete-body-upload-pack-v2-http.sh/

t/t5563-simple-http-auth.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ test_description='test http auth header and credential helper interop'
55
. ./test-lib.sh
66
. "$TEST_DIRECTORY"/lib-httpd.sh
77

8+
enable_cgipassauth
9+
if ! test_have_prereq CGIPASSAUTH
10+
then
11+
skip_all="no CGIPassAuth support"
12+
test_done
13+
fi
814
start_httpd
915

1016
test_expect_success 'setup_credential_helper' '

0 commit comments

Comments
 (0)