Documentation/diff-config: fix description of diff.renames
[git.git] / t / lib-proto-disable.sh
blobb0917d93e64a93faef4a87fed300761f7461420a
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
7 test_proto () {
8 desc=$1
9 proto=$2
10 url=$3
12 test_expect_success "clone $1 (enabled)" '
13 rm -rf tmp.git &&
15 GIT_ALLOW_PROTOCOL=$proto &&
16 export GIT_ALLOW_PROTOCOL &&
17 git clone --bare "$url" tmp.git
21 test_expect_success "fetch $1 (enabled)" '
23 cd tmp.git &&
24 GIT_ALLOW_PROTOCOL=$proto &&
25 export GIT_ALLOW_PROTOCOL &&
26 git fetch
30 test_expect_success "push $1 (enabled)" '
32 cd tmp.git &&
33 GIT_ALLOW_PROTOCOL=$proto &&
34 export GIT_ALLOW_PROTOCOL &&
35 git push origin HEAD:pushed
39 test_expect_success "push $1 (disabled)" '
41 cd tmp.git &&
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)" '
50 cd tmp.git &&
51 GIT_ALLOW_PROTOCOL=none &&
52 export GIT_ALLOW_PROTOCOL &&
53 test_must_fail git fetch
57 test_expect_success "clone $1 (disabled)" '
58 rm -rf tmp.git &&
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 &&
72 echo >&2 "ssh: $*"
73 host=$1; shift
74 cd "$TRASH_DIRECTORY/$host" &&
75 eval "$*"
76 EOF
77 GIT_SSH="$PWD/ssh-wrapper" &&
78 export GIT_SSH &&
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" &&
91 eval "$*"
92 EOF
93 PATH=$TRASH_DIRECTORY:$PATH &&
94 export TRASH_DIRECTORY