]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5561-http-backend.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5561-http-backend.sh
CommitLineData
7f640b77
SP
1#!/bin/sh
2
3test_description='test git-http-backend'
028cb644 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
1fdd31cf 7TEST_PASSES_SANITIZE_LEAK=true
7f640b77 8. ./test-lib.sh
7f640b77 9. "$TEST_DIRECTORY"/lib-httpd.sh
e9184b07
JK
10
11if ! test_have_prereq CURL; then
12 skip_all='skipping raw http-backend tests, curl not available'
13 test_done
14fi
15
7f640b77
SP
16start_httpd
17
7f640b77 18GET() {
fcd9d709 19 curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out &&
7f640b77
SP
20 tr '\015' Q <out |
21 sed '
22 s/Q$//
23 1q
24 ' >act &&
25 echo "HTTP/1.1 $2" >exp &&
26 test_cmp exp act
27}
28
29POST() {
30 curl --include --data "$2" \
31 --header "Content-Type: application/x-$1-request" \
fcd9d709 32 "$HTTPD_URL/smart/repo.git/$1" >out &&
7f640b77
SP
33 tr '\015' Q <out |
34 sed '
35 s/Q$//
36 1q
37 ' >act &&
38 echo "HTTP/1.1 $3" >exp &&
39 test_cmp exp act
40}
41
04481adf 42. "$TEST_DIRECTORY"/t556x_common
34b6cb8b 43
362d8b6e 44grep '^[^#]' >exp <<EOF
7f640b77 45
028cb644 46### refs/heads/main
7f640b77 47###
028cb644 48GET /smart/repo.git/refs/heads/main HTTP/1.1 404 -
7f640b77
SP
49
50### getanyfile default
51###
52GET /smart/repo.git/HEAD HTTP/1.1 200
53GET /smart/repo.git/info/refs HTTP/1.1 200
54GET /smart/repo.git/objects/info/packs HTTP/1.1 200
55GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
56GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
57GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
58GET /smart/repo.git/$PACK_URL HTTP/1.1 200
59GET /smart/repo.git/$IDX_URL HTTP/1.1 200
60
8b2bd7cd
TC
61### no git-daemon-export-ok
62###
63GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
64GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
65GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
66GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
67GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
68GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
69GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
70GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
71
72### git-daemon-export-ok
73###
74GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
75GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
76GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
77GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
78GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
79GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
80GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
81GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
82
7f640b77
SP
83### getanyfile true
84###
85GET /smart/repo.git/HEAD HTTP/1.1 200
86GET /smart/repo.git/info/refs HTTP/1.1 200
87GET /smart/repo.git/objects/info/packs HTTP/1.1 200
88GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
89GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
90GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
91GET /smart/repo.git/$PACK_URL HTTP/1.1 200
92GET /smart/repo.git/$IDX_URL HTTP/1.1 200
93
94### getanyfile false
95###
96GET /smart/repo.git/HEAD HTTP/1.1 403 -
97GET /smart/repo.git/info/refs HTTP/1.1 403 -
98GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
99GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
100GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
101GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
102GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
103GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
104
105### uploadpack default
106###
107GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
108POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
109
110### uploadpack true
111###
112GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
113POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
114
115### uploadpack false
116###
117GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
118POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
119
120### receivepack default
121###
122GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
123POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
124
125### receivepack true
126###
127GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
128POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
129
130### receivepack false
131###
132GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
133POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
134EOF
135test_expect_success 'server request log matches test results' '
e8b3b2e2 136 check_access_log exp
7f640b77
SP
137'
138
7f640b77 139test_done