for-each-ref: add new option to include root refs
[git.git] / t / t5561-http-backend.sh
blobe1d3b8caed07394fcdf02db4d31d4f038d3474b2
1 #!/bin/sh
3 test_description='test git-http-backend'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-httpd.sh
11 if ! test_have_prereq CURL; then
12 skip_all='skipping raw http-backend tests, curl not available'
13 test_done
16 start_httpd
18 GET() {
19 curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out &&
20 tr '\015' Q <out |
21 sed '
22 s/Q$//
24 ' >act &&
25 echo "HTTP/1.1 $2" >exp &&
26 test_cmp exp act
29 POST() {
30 curl --include --data "$2" \
31 --header "Content-Type: application/x-$1-request" \
32 "$HTTPD_URL/smart/repo.git/$1" >out &&
33 tr '\015' Q <out |
34 sed '
35 s/Q$//
37 ' >act &&
38 echo "HTTP/1.1 $3" >exp &&
39 test_cmp exp act
42 . "$TEST_DIRECTORY"/t556x_common
44 grep '^[^#]' >exp <<EOF
46 ### refs/heads/main
47 ###
48 GET /smart/repo.git/refs/heads/main HTTP/1.1 404 -
50 ### getanyfile default
51 ###
52 GET /smart/repo.git/HEAD HTTP/1.1 200
53 GET /smart/repo.git/info/refs HTTP/1.1 200
54 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
55 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
56 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
57 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
58 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
59 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
61 ### no git-daemon-export-ok
62 ###
63 GET /smart_noexport/repo.git/HEAD HTTP/1.1 404 -
64 GET /smart_noexport/repo.git/info/refs HTTP/1.1 404 -
65 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -
66 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -
67 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -
68 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -
69 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -
70 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -
72 ### git-daemon-export-ok
73 ###
74 GET /smart_noexport/repo.git/HEAD HTTP/1.1 200
75 GET /smart_noexport/repo.git/info/refs HTTP/1.1 200
76 GET /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200
77 GET /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -
78 GET /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -
79 GET /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200
80 GET /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200
81 GET /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200
83 ### getanyfile true
84 ###
85 GET /smart/repo.git/HEAD HTTP/1.1 200
86 GET /smart/repo.git/info/refs HTTP/1.1 200
87 GET /smart/repo.git/objects/info/packs HTTP/1.1 200
88 GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
89 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
90 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
91 GET /smart/repo.git/$PACK_URL HTTP/1.1 200
92 GET /smart/repo.git/$IDX_URL HTTP/1.1 200
94 ### getanyfile false
95 ###
96 GET /smart/repo.git/HEAD HTTP/1.1 403 -
97 GET /smart/repo.git/info/refs HTTP/1.1 403 -
98 GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
99 GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
100 GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
101 GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
102 GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
103 GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
105 ### uploadpack default
107 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
108 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
110 ### uploadpack true
112 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
113 POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
115 ### uploadpack false
117 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
118 POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
120 ### receivepack default
122 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
123 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
125 ### receivepack true
127 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
128 POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
130 ### receivepack false
132 GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
133 POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
135 test_expect_success 'server request log matches test results' '
136 check_access_log exp
139 test_done