]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5532-fetch-proxy.sh
The third batch
[thirdparty/git.git] / t / t5532-fetch-proxy.sh
CommitLineData
c7730e6f
JK
1#!/bin/sh
2
3test_description='fetching via git:// using core.gitproxy'
e75d2f7f
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
c7730e6f
JK
6. ./test-lib.sh
7
8test_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
ca386ee1
JK
17test_expect_success 'setup proxy script' '
18 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
c7730e6f
JK
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;
ca386ee1
JK
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
c7730e6f
JK
36test_expect_success 'setup local repo' '
37 git remote add fake git://example.com/remote &&
38 git config core.gitproxy ./proxy
39'
40
41test_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
3be4cf09
JK
48test_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
c7730e6f 53test_done