use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t5532-fetch-proxy.sh
blob9c2798603b4d7b4a3db135febedc71e8cea23635
1 #!/bin/sh
3 test_description='fetching via git:// using core.gitproxy'
4 . ./test-lib.sh
6 test_expect_success 'setup remote repo' '
7 git init remote &&
8 (cd remote &&
9 echo content >file &&
10 git add file &&
11 git commit -m one
15 test_expect_success 'setup proxy script' '
16 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
17 read(STDIN, $buf, 4);
18 my $n = hex($buf) - 4;
19 read(STDIN, $buf, $n);
20 my ($cmd, $other) = split /\0/, $buf;
21 # drop absolute-path on repo name
22 $cmd =~ s{ /}{ };
23 print $cmd;
24 EOF
26 write_script proxy <<-\EOF
27 echo >&2 "proxying for $*"
28 cmd=$(./proxy-get-cmd)
29 echo >&2 "Running $cmd"
30 exec $cmd
31 EOF
34 test_expect_success 'setup local repo' '
35 git remote add fake git://example.com/remote &&
36 git config core.gitproxy ./proxy
39 test_expect_success 'fetch through proxy works' '
40 git fetch fake &&
41 echo one >expect &&
42 git log -1 --format=%s FETCH_HEAD >actual &&
43 test_cmp expect actual
46 test_expect_success 'funny hostnames are rejected before running proxy' '
47 test_must_fail git fetch git://-remote/repo.git 2>stderr &&
48 ! grep "proxying for" stderr
51 test_done