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