]>
Commit | Line | Data |
---|---|---|
faa4bc35 CB |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at> | |
4 | # | |
5 | ||
7da4e228 | 6 | test_description='test WebDAV http-push |
faa4bc35 CB |
7 | |
8 | This test runs various sanity checks on http-push.' | |
9 | ||
10 | . ./test-lib.sh | |
11 | ||
96086262 MH |
12 | if git http-push > /dev/null 2>&1 || [ $? -eq 128 ] |
13 | then | |
fadb5156 | 14 | skip_all="skipping test, USE_CURL_MULTI is not defined" |
96086262 | 15 | test_done |
96086262 MH |
16 | fi |
17 | ||
859d1fb4 CB |
18 | LIB_HTTPD_DAV=t |
19 | LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'} | |
bfdbee98 | 20 | . "$TEST_DIRECTORY"/lib-httpd.sh |
859d1fb4 | 21 | ROOT_PATH="$PWD" |
75318a3b | 22 | start_httpd |
faa4bc35 CB |
23 | |
24 | test_expect_success 'setup remote repository' ' | |
25 | cd "$ROOT_PATH" && | |
26 | mkdir test_repo && | |
27 | cd test_repo && | |
28 | git init && | |
29 | : >path1 && | |
30 | git add path1 && | |
31 | test_tick && | |
32 | git commit -m initial && | |
33 | cd - && | |
34 | git clone --bare test_repo test_repo.git && | |
35 | cd test_repo.git && | |
36 | git --bare update-server-info && | |
7dce9918 | 37 | mv hooks/post-update.sample hooks/post-update && |
ae4efe19 | 38 | ORIG_HEAD=$(git rev-parse --verify HEAD) && |
faa4bc35 | 39 | cd - && |
13b5481e | 40 | mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH" |
faa4bc35 | 41 | ' |
3b2eb186 | 42 | |
0521710a JK |
43 | test_expect_success 'create password-protected repository' ' |
44 | mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" && | |
45 | cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \ | |
46 | "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" | |
47 | ' | |
48 | ||
49 | test_expect_success 'setup askpass helper' ' | |
50 | cat >askpass <<-\EOF && | |
51 | #!/bin/sh | |
52 | echo user@host | |
53 | EOF | |
54 | chmod +x askpass && | |
55 | GIT_ASKPASS="$PWD/askpass" && | |
56 | export GIT_ASKPASS | |
57 | ' | |
58 | ||
faa4bc35 CB |
59 | test_expect_success 'clone remote repository' ' |
60 | cd "$ROOT_PATH" && | |
024bb125 | 61 | git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone |
faa4bc35 CB |
62 | ' |
63 | ||
ae4efe19 | 64 | test_expect_success 'push to remote repository with packed refs' ' |
faa4bc35 CB |
65 | cd "$ROOT_PATH"/test_repo_clone && |
66 | : >path2 && | |
67 | git add path2 && | |
68 | test_tick && | |
69 | git commit -m path2 && | |
8ee09acd | 70 | HEAD=$(git rev-parse --verify HEAD) && |
b5cd2d1e | 71 | git push && |
8ee09acd JS |
72 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && |
73 | test $HEAD = $(git rev-parse --verify HEAD)) | |
faa4bc35 CB |
74 | ' |
75 | ||
d8f67d20 | 76 | test_expect_success 'push already up-to-date' ' |
ae4efe19 SP |
77 | git push |
78 | ' | |
79 | ||
80 | test_expect_success 'push to remote repository with unpacked refs' ' | |
8ee09acd JS |
81 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && |
82 | rm packed-refs && | |
ae4efe19 SP |
83 | git update-ref refs/heads/master $ORIG_HEAD && |
84 | git --bare update-server-info) && | |
8ee09acd JS |
85 | git push && |
86 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && | |
87 | test $HEAD = $(git rev-parse --verify HEAD)) | |
88 | ' | |
89 | ||
4f66250d | 90 | test_expect_success 'http-push fetches unpacked objects' ' |
242a9077 TRC |
91 | cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
92 | "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git && | |
93 | ||
024bb125 | 94 | git clone $HTTPD_URL/dumb/test_repo_unpacked.git \ |
242a9077 TRC |
95 | "$ROOT_PATH"/fetch_unpacked && |
96 | ||
97 | # By reset, we force git to retrieve the object | |
98 | (cd "$ROOT_PATH"/fetch_unpacked && | |
99 | git reset --hard HEAD^ && | |
100 | git remote rm origin && | |
101 | git reflog expire --expire=0 --all && | |
102 | git prune && | |
024bb125 | 103 | git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master) |
242a9077 TRC |
104 | ' |
105 | ||
4f66250d | 106 | test_expect_success 'http-push fetches packed objects' ' |
86d99f6d TRC |
107 | cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
108 | "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git && | |
109 | ||
024bb125 | 110 | git clone $HTTPD_URL/dumb/test_repo_packed.git \ |
86d99f6d TRC |
111 | "$ROOT_PATH"/test_repo_clone_packed && |
112 | ||
113 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git && | |
114 | git --bare repack && | |
115 | git --bare prune-packed) && | |
116 | ||
117 | # By reset, we force git to retrieve the packed object | |
118 | (cd "$ROOT_PATH"/test_repo_clone_packed && | |
119 | git reset --hard HEAD^ && | |
120 | git remote rm origin && | |
121 | git reflog expire --expire=0 --all && | |
122 | git prune && | |
024bb125 | 123 | git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master) |
86d99f6d TRC |
124 | ' |
125 | ||
8ee09acd | 126 | test_expect_success 'create and delete remote branch' ' |
faa4bc35 CB |
127 | cd "$ROOT_PATH"/test_repo_clone && |
128 | git checkout -b dev && | |
129 | : >path3 && | |
130 | git add path3 && | |
131 | test_tick && | |
132 | git commit -m dev && | |
133 | git push origin dev && | |
faa4bc35 | 134 | git push origin :dev && |
d492b31c | 135 | test_must_fail git show-ref --verify refs/remotes/origin/dev |
faa4bc35 CB |
136 | ' |
137 | ||
466ddf90 JS |
138 | test_expect_success 'MKCOL sends directory names with trailing slashes' ' |
139 | ||
140 | ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log | |
141 | ||
142 | ' | |
143 | ||
2591838b JS |
144 | x1="[0-9a-f]" |
145 | x2="$x1$x1" | |
146 | x5="$x1$x1$x1$x1$x1" | |
147 | x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1" | |
148 | x40="$x38$x2" | |
dfab7c14 | 149 | |
2591838b | 150 | test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' ' |
f6918da7 BG |
151 | sed \ |
152 | -e "s/PUT /OP /" \ | |
153 | -e "s/MOVE /OP /" \ | |
154 | -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \ | |
155 | "$HTTPD_ROOT_PATH"/access.log | | |
156 | grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] " | |
dfab7c14 TRC |
157 | |
158 | ' | |
159 | ||
6cbd6e92 TRC |
160 | test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
161 | "$ROOT_PATH"/test_repo_clone master | |
162 | ||
a4ddbc33 | 163 | test_expect_success 'push to password-protected repository (user in URL)' ' |
0521710a JK |
164 | test_commit pw-user && |
165 | git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD && | |
166 | git rev-parse --verify HEAD >expect && | |
167 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \ | |
168 | rev-parse --verify HEAD >actual && | |
169 | test_cmp expect actual | |
170 | ' | |
171 | ||
172 | test_expect_failure 'push to password-protected repository (no user in URL)' ' | |
173 | test_commit pw-nouser && | |
174 | git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD && | |
175 | git rev-parse --verify HEAD >expect && | |
176 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \ | |
177 | rev-parse --verify HEAD >actual && | |
178 | test_cmp expect actual | |
179 | ' | |
180 | ||
faa4bc35 CB |
181 | stop_httpd |
182 | ||
183 | test_done |