From 1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 11 Jan 2020 23:36:56 +0000 Subject: Squashed 'third_party/git/' content from commit cb71568594 git-subtree-dir: third_party/git git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7 --- t/lib-httpd/apache.conf | 258 ++++++++++++++++++++++++++++++++++++++ t/lib-httpd/apply-one-time-sed.sh | 22 ++++ t/lib-httpd/broken-smart-http.sh | 10 ++ t/lib-httpd/error-smart-http.sh | 3 + t/lib-httpd/error.sh | 31 +++++ t/lib-httpd/passwd | 1 + t/lib-httpd/ssl.cnf | 8 ++ 7 files changed, 333 insertions(+) create mode 100644 t/lib-httpd/apache.conf create mode 100644 t/lib-httpd/apply-one-time-sed.sh create mode 100644 t/lib-httpd/broken-smart-http.sh create mode 100644 t/lib-httpd/error-smart-http.sh create mode 100755 t/lib-httpd/error.sh create mode 100644 t/lib-httpd/passwd create mode 100644 t/lib-httpd/ssl.cnf (limited to 't/lib-httpd') diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf new file mode 100644 index 000000000000..5c1c86c193ab --- /dev/null +++ b/t/lib-httpd/apache.conf @@ -0,0 +1,258 @@ +ServerName dummy +PidFile httpd.pid +DocumentRoot www +LogFormat "%h %l %u %t \"%r\" %>s %b" common +CustomLog access.log common +ErrorLog error.log + + LoadModule log_config_module modules/mod_log_config.so + + + LoadModule alias_module modules/mod_alias.so + + + LoadModule cgi_module modules/mod_cgi.so + + + LoadModule env_module modules/mod_env.so + + + LoadModule rewrite_module modules/mod_rewrite.so + + + LoadModule version_module modules/mod_version.so + + + LoadModule headers_module modules/mod_headers.so + + + LoadModule setenvif_module modules/mod_setenvif.so + + + +LockFile accept.lock + + + + + LoadModule auth_module modules/mod_auth.so + + + += 2.1> + + LoadModule auth_basic_module modules/mod_auth_basic.so + + + LoadModule authn_file_module modules/mod_authn_file.so + + + LoadModule authz_user_module modules/mod_authz_user.so + + + LoadModule authz_host_module modules/mod_authz_host.so + + + += 2.4> + + LoadModule authn_core_module modules/mod_authn_core.so + + + LoadModule authz_core_module modules/mod_authz_core.so + + + LoadModule access_compat_module modules/mod_access_compat.so + + + LoadModule mpm_prefork_module modules/mod_mpm_prefork.so + + + LoadModule unixd_module modules/mod_unixd.so + + + +PassEnv GIT_VALGRIND +PassEnv GIT_VALGRIND_OPTIONS +PassEnv GNUPGHOME +PassEnv ASAN_OPTIONS +PassEnv LSAN_OPTIONS +PassEnv GIT_TRACE +PassEnv GIT_CONFIG_NOSYSTEM +PassEnv GIT_TEST_SIDEBAND_ALL + +SetEnvIf Git-Protocol ".*" GIT_PROTOCOL=$0 + +Alias /dumb/ www/ +Alias /auth/dumb/ www/auth/dumb/ + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + SetEnv GIT_COMMITTER_NAME "Custom User" + SetEnv GIT_COMMITTER_EMAIL custom@example.com + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + SetEnv GIT_NAMESPACE ns + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + Header set Set-Cookie name=value + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + + + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + +ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/ +ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1 +ScriptAlias /broken_smart/ broken-smart-http.sh/ +ScriptAlias /error_smart/ error-smart-http.sh/ +ScriptAlias /error/ error.sh/ +ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1 + + Options FollowSymlinks + + + Options ExecCGI + + + Options ExecCGI + + + Options ExecCGI + + + Options ExecCGI + + + Options ExecCGI + + +RewriteEngine on +RewriteRule ^/dumb-redir/(.*)$ /dumb/$1 [R=301] +RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301] +RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302] +RewriteRule ^/smart-redir-auth/(.*)$ /auth/smart/$1 [R=301] +RewriteRule ^/smart-redir-limited/(.*)/info/refs$ /smart/$1/info/refs [R=301] +RewriteRule ^/ftp-redir/(.*)$ ftp://localhost:1000/$1 [R=302] + +RewriteRule ^/loop-redir/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-(.*) /$1 [R=302] +RewriteRule ^/loop-redir/(.*)$ /loop-redir/x-$1 [R=302] + +# redir-to/502/x?y -> really-redir-to?path=502/x&qs=y which returns 502 +# redir-to/x?y -> really-redir-to?path=x&qs=y -> x?y +RewriteCond %{QUERY_STRING} ^(.*)$ +RewriteRule ^/redir-to/(.*)$ /really-redir-to?path=$1&qs=%1 [R=302] +RewriteCond %{QUERY_STRING} ^path=502/(.*)&qs=(.*)$ +RewriteRule ^/really-redir-to$ - [R=502,L] +RewriteCond %{QUERY_STRING} ^path=(.*)&qs=(.*)$ +RewriteRule ^/really-redir-to$ /%1?%2 [R=302] + +# The first rule issues a client-side redirect to something +# that _doesn't_ look like a git repo. The second rule is a +# server-side rewrite, so that it turns out the odd-looking +# thing _is_ a git repo. The "[PT]" tells Apache to match +# the usual ScriptAlias rules for /smart. +RewriteRule ^/insane-redir/(.*)$ /intern-redir/$1/foo [R=301] +RewriteRule ^/intern-redir/(.*)/foo$ /smart/$1 [PT] + +# Serve info/refs internally without redirecting, but +# issue a redirect for any object requests. +RewriteRule ^/redir-objects/(.*/info/refs)$ /dumb/$1 [PT] +RewriteRule ^/redir-objects/(.*/objects/.*)$ /dumb/$1 [R=301] + +# Apache 2.2 does not understand , so we use RewriteCond. +# And as RewriteCond does not allow testing for non-matches, we match +# the desired case first (one has abra, two has cadabra), and let it +# pass by marking the RewriteRule as [L], "last rule, do not process +# any other matching RewriteRules after this"), and then have another +# RewriteRule that matches all other cases and lets them fail via '[F]', +# "fail the request". +RewriteCond %{HTTP:x-magic-one} =abra +RewriteCond %{HTTP:x-magic-two} =cadabra +RewriteRule ^/smart_headers/.* - [L] +RewriteRule ^/smart_headers/.* - [F] + + +LoadModule ssl_module modules/mod_ssl.so + +SSLCertificateFile httpd.pem +SSLCertificateKeyFile httpd.pem +SSLRandomSeed startup file:/dev/urandom 512 +SSLRandomSeed connect file:/dev/urandom 512 +SSLSessionCache none +SSLMutex file:ssl_mutex +SSLEngine On + + + + AuthType Basic + AuthName "git-auth" + AuthUserFile passwd + Require valid-user + + + + AuthType Basic + AuthName "git-auth" + AuthUserFile passwd + Require valid-user + + + + AuthType Basic + AuthName "git-auth" + AuthUserFile passwd + Require valid-user + + +RewriteCond %{QUERY_STRING} service=git-receive-pack [OR] +RewriteCond %{REQUEST_URI} /git-receive-pack$ +RewriteRule ^/half-auth-complete/ - [E=AUTHREQUIRED:yes] + + + Order Deny,Allow + Deny from env=AUTHREQUIRED + + AuthType Basic + AuthName "Git Access" + AuthUserFile passwd + Require valid-user + Satisfy Any + + + + LoadModule dav_module modules/mod_dav.so + LoadModule dav_fs_module modules/mod_dav_fs.so + + DAVLockDB DAVLock + + Dav on + + + Dav on + + + + + LoadModule dav_svn_module modules/mod_dav_svn.so + + + DAV svn + SVNPath "${LIB_HTTPD_SVNPATH}" + + diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh new file mode 100644 index 000000000000..fcef72892547 --- /dev/null +++ b/t/lib-httpd/apply-one-time-sed.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# If "one-time-sed" exists in $HTTPD_ROOT_PATH, run sed on the HTTP response, +# using the contents of "one-time-sed" as the sed command to be run. If the +# response was modified as a result, delete "one-time-sed" so that subsequent +# HTTP responses are no longer modified. +# +# This can be used to simulate the effects of the repository changing in +# between HTTP request-response pairs. +if [ -e one-time-sed ]; then + "$GIT_EXEC_PATH/git-http-backend" >out + sed "$(cat one-time-sed)" out_modified + + if diff out out_modified >/dev/null; then + cat out + else + cat out_modified + rm one-time-sed + fi +else + "$GIT_EXEC_PATH/git-http-backend" +fi diff --git a/t/lib-httpd/broken-smart-http.sh b/t/lib-httpd/broken-smart-http.sh new file mode 100644 index 000000000000..82cc610b0ac0 --- /dev/null +++ b/t/lib-httpd/broken-smart-http.sh @@ -0,0 +1,10 @@ +printf "Content-Type: text/%s\n" "html" +echo +printf "%s\n" "001e# service=git-upload-pack" +printf "%s" "0000" +printf "%s%c%s%s\n" \ + "00a58681d9f286a48b08f37b3a095330da16689e3693 HEAD" \ + 0 \ + " include-tag multi_ack_detailed multi_ack ofs-delta" \ + " side-band side-band-64k thin-pack no-progress shallow no-done " +printf "%s" "0000" diff --git a/t/lib-httpd/error-smart-http.sh b/t/lib-httpd/error-smart-http.sh new file mode 100644 index 000000000000..e65d447fc4c4 --- /dev/null +++ b/t/lib-httpd/error-smart-http.sh @@ -0,0 +1,3 @@ +echo "Content-Type: application/x-git-upload-pack-advertisement" +echo +printf "%s" "0019ERR server-side error" diff --git a/t/lib-httpd/error.sh b/t/lib-httpd/error.sh new file mode 100755 index 000000000000..a77b8e546926 --- /dev/null +++ b/t/lib-httpd/error.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +printf "Status: 500 Intentional Breakage\n" + +printf "Content-Type: " +charset=iso-8859-1 +case "$PATH_INFO" in +*html*) + printf "text/html" + ;; +*text*) + printf "text/plain" + ;; +*charset*) + printf "text/plain; charset=utf-8" + charset=utf-8 + ;; +*utf16*) + printf "text/plain; charset=utf-16" + charset=utf-16 + ;; +*odd-spacing*) + printf "text/plain; foo=bar ;charset=utf-16; other=nonsense" + charset=utf-16 + ;; +esac +printf "\n" + +printf "\n" +printf "this is the error message\n" | +iconv -f us-ascii -t $charset diff --git a/t/lib-httpd/passwd b/t/lib-httpd/passwd new file mode 100644 index 000000000000..99a34d648742 --- /dev/null +++ b/t/lib-httpd/passwd @@ -0,0 +1 @@ +user@host:xb4E8pqD81KQs diff --git a/t/lib-httpd/ssl.cnf b/t/lib-httpd/ssl.cnf new file mode 100644 index 000000000000..6dab2579cbf9 --- /dev/null +++ b/t/lib-httpd/ssl.cnf @@ -0,0 +1,8 @@ +RANDFILE = $ENV::RANDFILE_PATH + +[ req ] +default_bits = 1024 +distinguished_name = req_distinguished_name +prompt = no +[ req_distinguished_name ] +commonName = 127.0.0.1 -- cgit 1.4.1