]>
Commit | Line | Data |
---|---|---|
7f640b77 SP |
1 | #!/bin/sh |
2 | ||
3 | test_description='test git-http-backend' | |
028cb644 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
1fdd31cf | 7 | TEST_PASSES_SANITIZE_LEAK=true |
7f640b77 | 8 | . ./test-lib.sh |
7f640b77 | 9 | . "$TEST_DIRECTORY"/lib-httpd.sh |
e9184b07 JK |
10 | |
11 | if ! test_have_prereq CURL; then | |
12 | skip_all='skipping raw http-backend tests, curl not available' | |
13 | test_done | |
14 | fi | |
15 | ||
7f640b77 SP |
16 | start_httpd |
17 | ||
7f640b77 | 18 | GET() { |
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 | ||
29 | POST() { | |
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 | 44 | grep '^[^#]' >exp <<EOF |
7f640b77 | 45 | |
028cb644 | 46 | ### refs/heads/main |
7f640b77 | 47 | ### |
028cb644 | 48 | GET /smart/repo.git/refs/heads/main HTTP/1.1 404 - |
7f640b77 SP |
49 | |
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 | |
60 | ||
8b2bd7cd TC |
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 - | |
71 | ||
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 | |
82 | ||
7f640b77 SP |
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 | |
93 | ||
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 - | |
104 | ||
105 | ### uploadpack default | |
106 | ### | |
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 - | |
109 | ||
110 | ### uploadpack true | |
111 | ### | |
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 - | |
114 | ||
115 | ### uploadpack false | |
116 | ### | |
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 - | |
119 | ||
120 | ### receivepack default | |
121 | ### | |
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 - | |
124 | ||
125 | ### receivepack true | |
126 | ### | |
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 - | |
129 | ||
130 | ### receivepack false | |
131 | ### | |
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 - | |
134 | EOF | |
135 | test_expect_success 'server request log matches test results' ' | |
e8b3b2e2 | 136 | check_access_log exp |
7f640b77 SP |
137 | ' |
138 | ||
7f640b77 | 139 | test_done |