Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at> |
| 4 | # |
| 5 | |
Shawn O. Pearce | 7da4e22 | 2009-10-30 17:47:47 -0700 | [diff] [blame] | 6 | test_description='test WebDAV http-push |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 7 | |
| 8 | This test runs various sanity checks on http-push.' |
| 9 | |
| 10 | . ./test-lib.sh |
| 11 | |
Mike Hommey | 9608626 | 2008-07-07 21:02:50 +0200 | [diff] [blame] | 12 | if git http-push > /dev/null 2>&1 || [ $? -eq 128 ] |
| 13 | then |
Ævar Arnfjörð Bjarmason | fadb515 | 2010-06-24 17:44:48 +0000 | [diff] [blame] | 14 | skip_all="skipping test, USE_CURL_MULTI is not defined" |
Mike Hommey | 9608626 | 2008-07-07 21:02:50 +0200 | [diff] [blame] | 15 | test_done |
Mike Hommey | 9608626 | 2008-07-07 21:02:50 +0200 | [diff] [blame] | 16 | fi |
| 17 | |
Clemens Buchacher | 859d1fb | 2009-10-30 17:47:45 -0700 | [diff] [blame] | 18 | LIB_HTTPD_DAV=t |
| 19 | LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'} |
Junio C Hamano | bfdbee9 | 2008-08-08 02:26:28 -0700 | [diff] [blame] | 20 | . "$TEST_DIRECTORY"/lib-httpd.sh |
Clemens Buchacher | 859d1fb | 2009-10-30 17:47:45 -0700 | [diff] [blame] | 21 | ROOT_PATH="$PWD" |
Jeff King | 75318a3 | 2009-02-25 03:32:08 -0500 | [diff] [blame] | 22 | start_httpd |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 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 && |
Petr Baudis | 7dce991 | 2008-08-12 00:34:46 +0200 | [diff] [blame] | 37 | mv hooks/post-update.sample hooks/post-update && |
Shawn O. Pearce | ae4efe1 | 2009-10-30 17:47:30 -0700 | [diff] [blame] | 38 | ORIG_HEAD=$(git rev-parse --verify HEAD) && |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 39 | cd - && |
Mike Hommey | 13b5481 | 2008-07-07 21:02:37 +0200 | [diff] [blame] | 40 | mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH" |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 41 | ' |
Jeff King | 3b2eb18 | 2008-06-14 03:25:56 -0400 | [diff] [blame] | 42 | |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 43 | test_expect_success 'clone remote repository' ' |
| 44 | cd "$ROOT_PATH" && |
Shawn O. Pearce | 024bb12 | 2009-10-30 17:47:46 -0700 | [diff] [blame] | 45 | git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 46 | ' |
| 47 | |
Shawn O. Pearce | ae4efe1 | 2009-10-30 17:47:30 -0700 | [diff] [blame] | 48 | test_expect_success 'push to remote repository with packed refs' ' |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 49 | cd "$ROOT_PATH"/test_repo_clone && |
| 50 | : >path2 && |
| 51 | git add path2 && |
| 52 | test_tick && |
| 53 | git commit -m path2 && |
Johannes Schindelin | 8ee09ac | 2009-01-17 16:41:41 +0100 | [diff] [blame] | 54 | HEAD=$(git rev-parse --verify HEAD) && |
Mike Hommey | b5cd2d1 | 2008-07-07 23:06:46 +0200 | [diff] [blame] | 55 | git push && |
Johannes Schindelin | 8ee09ac | 2009-01-17 16:41:41 +0100 | [diff] [blame] | 56 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && |
| 57 | test $HEAD = $(git rev-parse --verify HEAD)) |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 58 | ' |
| 59 | |
Clemens Buchacher | d8f67d2 | 2009-10-30 17:47:31 -0700 | [diff] [blame] | 60 | test_expect_success 'push already up-to-date' ' |
Shawn O. Pearce | ae4efe1 | 2009-10-30 17:47:30 -0700 | [diff] [blame] | 61 | git push |
| 62 | ' |
| 63 | |
| 64 | test_expect_success 'push to remote repository with unpacked refs' ' |
Johannes Schindelin | 8ee09ac | 2009-01-17 16:41:41 +0100 | [diff] [blame] | 65 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && |
| 66 | rm packed-refs && |
Shawn O. Pearce | ae4efe1 | 2009-10-30 17:47:30 -0700 | [diff] [blame] | 67 | git update-ref refs/heads/master $ORIG_HEAD && |
| 68 | git --bare update-server-info) && |
Johannes Schindelin | 8ee09ac | 2009-01-17 16:41:41 +0100 | [diff] [blame] | 69 | git push && |
| 70 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && |
| 71 | test $HEAD = $(git rev-parse --verify HEAD)) |
| 72 | ' |
| 73 | |
Tay Ray Chuan | 4f66250 | 2009-06-06 16:43:27 +0800 | [diff] [blame] | 74 | test_expect_success 'http-push fetches unpacked objects' ' |
Tay Ray Chuan | 242a907 | 2009-06-06 16:43:23 +0800 | [diff] [blame] | 75 | cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
| 76 | "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git && |
| 77 | |
Shawn O. Pearce | 024bb12 | 2009-10-30 17:47:46 -0700 | [diff] [blame] | 78 | git clone $HTTPD_URL/dumb/test_repo_unpacked.git \ |
Tay Ray Chuan | 242a907 | 2009-06-06 16:43:23 +0800 | [diff] [blame] | 79 | "$ROOT_PATH"/fetch_unpacked && |
| 80 | |
| 81 | # By reset, we force git to retrieve the object |
| 82 | (cd "$ROOT_PATH"/fetch_unpacked && |
| 83 | git reset --hard HEAD^ && |
| 84 | git remote rm origin && |
| 85 | git reflog expire --expire=0 --all && |
| 86 | git prune && |
Shawn O. Pearce | 024bb12 | 2009-10-30 17:47:46 -0700 | [diff] [blame] | 87 | git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master) |
Tay Ray Chuan | 242a907 | 2009-06-06 16:43:23 +0800 | [diff] [blame] | 88 | ' |
| 89 | |
Tay Ray Chuan | 4f66250 | 2009-06-06 16:43:27 +0800 | [diff] [blame] | 90 | test_expect_success 'http-push fetches packed objects' ' |
Tay Ray Chuan | 86d99f6 | 2009-06-06 16:43:24 +0800 | [diff] [blame] | 91 | cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
| 92 | "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git && |
| 93 | |
Shawn O. Pearce | 024bb12 | 2009-10-30 17:47:46 -0700 | [diff] [blame] | 94 | git clone $HTTPD_URL/dumb/test_repo_packed.git \ |
Tay Ray Chuan | 86d99f6 | 2009-06-06 16:43:24 +0800 | [diff] [blame] | 95 | "$ROOT_PATH"/test_repo_clone_packed && |
| 96 | |
| 97 | (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git && |
| 98 | git --bare repack && |
| 99 | git --bare prune-packed) && |
| 100 | |
| 101 | # By reset, we force git to retrieve the packed object |
| 102 | (cd "$ROOT_PATH"/test_repo_clone_packed && |
| 103 | git reset --hard HEAD^ && |
| 104 | git remote rm origin && |
| 105 | git reflog expire --expire=0 --all && |
| 106 | git prune && |
Shawn O. Pearce | 024bb12 | 2009-10-30 17:47:46 -0700 | [diff] [blame] | 107 | git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master) |
Tay Ray Chuan | 86d99f6 | 2009-06-06 16:43:24 +0800 | [diff] [blame] | 108 | ' |
| 109 | |
Johannes Schindelin | 8ee09ac | 2009-01-17 16:41:41 +0100 | [diff] [blame] | 110 | test_expect_success 'create and delete remote branch' ' |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 111 | cd "$ROOT_PATH"/test_repo_clone && |
| 112 | git checkout -b dev && |
| 113 | : >path3 && |
| 114 | git add path3 && |
| 115 | test_tick && |
| 116 | git commit -m dev && |
| 117 | git push origin dev && |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 118 | git push origin :dev && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 119 | test_must_fail git show-ref --verify refs/remotes/origin/dev |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 120 | ' |
| 121 | |
Johannes Schindelin | 466ddf9 | 2009-01-17 16:11:51 +0100 | [diff] [blame] | 122 | test_expect_success 'MKCOL sends directory names with trailing slashes' ' |
| 123 | |
| 124 | ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log |
| 125 | |
| 126 | ' |
| 127 | |
Jay Soffian | 2591838 | 2009-02-26 18:44:40 -0500 | [diff] [blame] | 128 | x1="[0-9a-f]" |
| 129 | x2="$x1$x1" |
| 130 | x5="$x1$x1$x1$x1$x1" |
| 131 | x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1" |
| 132 | x40="$x38$x2" |
Tay Ray Chuan | dfab7c1 | 2009-02-14 17:52:14 +0800 | [diff] [blame] | 133 | |
Jay Soffian | 2591838 | 2009-02-26 18:44:40 -0500 | [diff] [blame] | 134 | test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' ' |
Brian Gernhardt | f6918da | 2011-08-29 02:42:21 -0400 | [diff] [blame] | 135 | sed \ |
| 136 | -e "s/PUT /OP /" \ |
| 137 | -e "s/MOVE /OP /" \ |
| 138 | -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \ |
| 139 | "$HTTPD_ROOT_PATH"/access.log | |
| 140 | grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] " |
Tay Ray Chuan | dfab7c1 | 2009-02-14 17:52:14 +0800 | [diff] [blame] | 141 | |
| 142 | ' |
| 143 | |
Tay Ray Chuan | 6cbd6e9 | 2010-03-02 18:49:26 +0800 | [diff] [blame] | 144 | test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ |
| 145 | "$ROOT_PATH"/test_repo_clone master |
| 146 | |
Clemens Buchacher | faa4bc3 | 2008-02-27 20:28:45 +0100 | [diff] [blame] | 147 | stop_httpd |
| 148 | |
| 149 | test_done |