1 # Test routines for checking protocol disabling.
3 # test cloning a particular protocol
4 # $1 - description of the protocol
5 # $2 - machine-readable name of the protocol
6 # $3 - the URL to try cloning
12 test_expect_success "clone $1 (enabled)" '
15 GIT_ALLOW_PROTOCOL=$proto &&
16 export GIT_ALLOW_PROTOCOL &&
17 git clone --bare "$url" tmp.git
21 test_expect_success "fetch $1 (enabled)" '
24 GIT_ALLOW_PROTOCOL=$proto &&
25 export GIT_ALLOW_PROTOCOL &&
30 test_expect_success "push $1 (enabled)" '
33 GIT_ALLOW_PROTOCOL=$proto &&
34 export GIT_ALLOW_PROTOCOL &&
35 git push origin HEAD:pushed
39 test_expect_success "push $1 (disabled)" '
42 GIT_ALLOW_PROTOCOL=none &&
43 export GIT_ALLOW_PROTOCOL &&
44 test_must_fail git push origin HEAD:pushed
48 test_expect_success "fetch $1 (disabled)" '
51 GIT_ALLOW_PROTOCOL=none &&
52 export GIT_ALLOW_PROTOCOL &&
53 test_must_fail git fetch
57 test_expect_success "clone $1 (disabled)" '
60 GIT_ALLOW_PROTOCOL=none &&
61 export GIT_ALLOW_PROTOCOL &&
62 test_must_fail git clone --bare "$url" tmp.git
67 # set up an ssh wrapper that will access $host/$repo in the
68 # trash directory, and enable it for subsequent tests.
69 setup_ssh_wrapper () {
70 test_expect_success 'setup ssh wrapper' '
71 write_script ssh-wrapper <<-\EOF &&
74 cd "$TRASH_DIRECTORY/$host" &&
77 GIT_SSH="$PWD/ssh-wrapper" &&
79 export TRASH_DIRECTORY
83 # set up a wrapper that can be used with remote-ext to
84 # access repositories in the "remote" directory of trash-dir,
85 # like "ext::fake-remote %S repo.git"
86 setup_ext_wrapper () {
87 test_expect_success 'setup ext wrapper' '
88 write_script fake-remote <<-\EOF &&
89 echo >&2 "fake-remote: $*"
90 cd "$TRASH_DIRECTORY/remote" &&
93 PATH=$TRASH_DIRECTORY:$PATH &&
94 export TRASH_DIRECTORY