]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5532-fetch-proxy.sh
The third batch
[thirdparty/git.git] / t / t5532-fetch-proxy.sh
1 #!/bin/sh
2
3 test_description='fetching via git:// using core.gitproxy'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup remote repo' '
9 git init remote &&
10 (cd remote &&
11 echo content >file &&
12 git add file &&
13 git commit -m one
14 )
15 '
16
17 test_expect_success 'setup proxy script' '
18 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
19 read(STDIN, $buf, 4);
20 my $n = hex($buf) - 4;
21 read(STDIN, $buf, $n);
22 my ($cmd, $other) = split /\0/, $buf;
23 # drop absolute-path on repo name
24 $cmd =~ s{ /}{ };
25 print $cmd;
26 EOF
27
28 write_script proxy <<-\EOF
29 echo >&2 "proxying for $*"
30 cmd=$(./proxy-get-cmd)
31 echo >&2 "Running $cmd"
32 exec $cmd
33 EOF
34 '
35
36 test_expect_success 'setup local repo' '
37 git remote add fake git://example.com/remote &&
38 git config core.gitproxy ./proxy
39 '
40
41 test_expect_success 'fetch through proxy works' '
42 git fetch fake &&
43 echo one >expect &&
44 git log -1 --format=%s FETCH_HEAD >actual &&
45 test_cmp expect actual
46 '
47
48 test_expect_success 'funny hostnames are rejected before running proxy' '
49 test_must_fail git fetch git://-remote/repo.git 2>stderr &&
50 ! grep "proxying for" stderr
51 '
52
53 test_done