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