]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5532-fetch-proxy.sh
Merge branch 'bc/sha-256-part-2'
[thirdparty/git.git] / t / t5532-fetch-proxy.sh
CommitLineData
c7730e6f
JK
1#!/bin/sh
2
3test_description='fetching via git:// using core.gitproxy'
4. ./test-lib.sh
5
6test_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
ca386ee1
JK
15test_expect_success 'setup proxy script' '
16 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
c7730e6f
JK
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;
ca386ee1
JK
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
c7730e6f
JK
34test_expect_success 'setup local repo' '
35 git remote add fake git://example.com/remote &&
36 git config core.gitproxy ./proxy
37'
38
39test_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
3be4cf09
JK
46test_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
c7730e6f 51test_done