t / lib-proto-disable.shon commit config: use git_config_parse_key() in git_config_parse_parameter() (1274a15)
   1# Test routines for checking protocol disabling.
   2
   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
   7test_proto () {
   8        desc=$1
   9        proto=$2
  10        url=$3
  11
  12        test_expect_success "clone $1 (enabled)" '
  13                rm -rf tmp.git &&
  14                (
  15                        GIT_ALLOW_PROTOCOL=$proto &&
  16                        export GIT_ALLOW_PROTOCOL &&
  17                        git clone --bare "$url" tmp.git
  18                )
  19        '
  20
  21        test_expect_success "fetch $1 (enabled)" '
  22                (
  23                        cd tmp.git &&
  24                        GIT_ALLOW_PROTOCOL=$proto &&
  25                        export GIT_ALLOW_PROTOCOL &&
  26                        git fetch
  27                )
  28        '
  29
  30        test_expect_success "push $1 (enabled)" '
  31                (
  32                        cd tmp.git &&
  33                        GIT_ALLOW_PROTOCOL=$proto &&
  34                        export GIT_ALLOW_PROTOCOL &&
  35                        git push origin HEAD:pushed
  36                )
  37        '
  38
  39        test_expect_success "push $1 (disabled)" '
  40                (
  41                        cd tmp.git &&
  42                        GIT_ALLOW_PROTOCOL=none &&
  43                        export GIT_ALLOW_PROTOCOL &&
  44                        test_must_fail git push origin HEAD:pushed
  45                )
  46        '
  47
  48        test_expect_success "fetch $1 (disabled)" '
  49                (
  50                        cd tmp.git &&
  51                        GIT_ALLOW_PROTOCOL=none &&
  52                        export GIT_ALLOW_PROTOCOL &&
  53                        test_must_fail git fetch
  54                )
  55        '
  56
  57        test_expect_success "clone $1 (disabled)" '
  58                rm -rf tmp.git &&
  59                (
  60                        GIT_ALLOW_PROTOCOL=none &&
  61                        export GIT_ALLOW_PROTOCOL &&
  62                        test_must_fail git clone --bare "$url" tmp.git
  63                )
  64        '
  65}
  66
  67# set up an ssh wrapper that will access $host/$repo in the
  68# trash directory, and enable it for subsequent tests.
  69setup_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
  80        '
  81}
  82
  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"
  86setup_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
  95        '
  96}