Merge branch 'bp/fsmonitor' into next
[git] / t / t5532-fetch-proxy.sh
1 #!/bin/sh
2
3 test_description='fetching via git:// using core.gitproxy'
4 . ./test-lib.sh
5
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
12         )
13 '
14
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
25
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
32 '
33
34 test_expect_success 'setup local repo' '
35         git remote add fake git://example.com/remote &&
36         git config core.gitproxy ./proxy
37 '
38
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
44 '
45
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
49 '
50
51 test_done