]> git.ipfire.org Git - thirdparty/git.git/blame - t/t556x_common
hashmap: use *_entry APIs for iteration
[thirdparty/git.git] / t / t556x_common
CommitLineData
04481adf
TC
1#!/bin/sh
2
3find_file() {
4 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
5 find $1 -type f |
6 sed -e 1q
7}
8
9config() {
10 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
11}
12
13test_expect_success 'setup repository' '
14 echo content >file &&
15 git add file &&
16 git commit -m one &&
17
18 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
19 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
20 git --bare init &&
21 : >objects/info/alternates &&
22 : >objects/info/http-alternates
23 ) &&
24 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
25 git push public master:master &&
26
27 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
28 git repack -a -d
29 ) &&
30
31 echo other >file &&
32 git add file &&
33 git commit -m two &&
34 git push public master:master &&
35
36 LOOSE_URL=$(find_file objects/??) &&
37 PACK_URL=$(find_file objects/pack/*.pack) &&
38 IDX_URL=$(find_file objects/pack/*.idx)
39'
40
41get_static_files() {
42 GET HEAD "$1" &&
43 GET info/refs "$1" &&
44 GET objects/info/packs "$1" &&
45 GET objects/info/alternates "$1" &&
46 GET objects/info/http-alternates "$1" &&
47 GET $LOOSE_URL "$1" &&
48 GET $PACK_URL "$1" &&
49 GET $IDX_URL "$1"
50}
51
52SMART=smart
69ae92bd 53GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
04481adf 54test_expect_success 'direct refs/heads/master not found' '
04481adf
TC
55 GET refs/heads/master "404 Not Found"
56'
57test_expect_success 'static file is ok' '
04481adf
TC
58 get_static_files "200 OK"
59'
60SMART=smart_noexport
fd0a8c2e 61unset GIT_HTTP_EXPORT_ALL
04481adf 62test_expect_success 'no export by default' '
04481adf
TC
63 get_static_files "404 Not Found"
64'
65test_expect_success 'export if git-daemon-export-ok' '
04481adf
TC
66 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
67 touch git-daemon-export-ok
68 ) &&
69 get_static_files "200 OK"
70'
71SMART=smart
69ae92bd 72GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
04481adf 73test_expect_success 'static file if http.getanyfile true is ok' '
04481adf
TC
74 config http.getanyfile true &&
75 get_static_files "200 OK"
76'
77test_expect_success 'static file if http.getanyfile false fails' '
04481adf
TC
78 config http.getanyfile false &&
79 get_static_files "403 Forbidden"
80'
81
82test_expect_success 'http.uploadpack default enabled' '
04481adf
TC
83 GET info/refs?service=git-upload-pack "200 OK" &&
84 POST git-upload-pack 0000 "200 OK"
85'
86test_expect_success 'http.uploadpack true' '
04481adf
TC
87 config http.uploadpack true &&
88 GET info/refs?service=git-upload-pack "200 OK" &&
89 POST git-upload-pack 0000 "200 OK"
90'
91test_expect_success 'http.uploadpack false' '
04481adf
TC
92 config http.uploadpack false &&
93 GET info/refs?service=git-upload-pack "403 Forbidden" &&
94 POST git-upload-pack 0000 "403 Forbidden"
95'
96
97test_expect_success 'http.receivepack default disabled' '
04481adf
TC
98 GET info/refs?service=git-receive-pack "403 Forbidden" &&
99 POST git-receive-pack 0000 "403 Forbidden"
100'
101test_expect_success 'http.receivepack true' '
04481adf
TC
102 config http.receivepack true &&
103 GET info/refs?service=git-receive-pack "200 OK" &&
104 POST git-receive-pack 0000 "200 OK"
105'
106test_expect_success 'http.receivepack false' '
04481adf
TC
107 config http.receivepack false &&
108 GET info/refs?service=git-receive-pack "403 Forbidden" &&
109 POST git-receive-pack 0000 "403 Forbidden"
110'