interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t5532-fetch-proxy.sh

58 lines · 1227 bytes Raw Blame History
1#!/bin/sh
2
3test_description='fetching via git:// using core.gitproxy'
4
5. ./test-lib.sh
6
7if ! test_have_prereq PERL_TEST_HELPERS
8then
9 skip_all='skipping fetch proxy tests; Perl not available'
10 test_done
11fi
12
13test_expect_success 'setup remote repo' '
14 git init remote &&
15 (cd remote &&
16 echo content >file &&
17 git add file &&
18 git commit -m one
19 )
20'
21
22test_expect_success 'setup proxy script' '
23 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
24 read(STDIN, $buf, 4);
25 my $n = hex($buf) - 4;
26 read(STDIN, $buf, $n);
27 my ($cmd, $other) = split /\0/, $buf;
28 # drop absolute-path on repo name
29 $cmd =~ s{ /}{ };
30 print $cmd;
31 EOF
32
33 write_script proxy <<-\EOF
34 echo >&2 "proxying for $*"
35 cmd=$(./proxy-get-cmd)
36 echo >&2 "Running $cmd"
37 exec $cmd
38 EOF
39'
40
41test_expect_success 'setup local repo' '
42 git remote add fake git://example.com/remote &&
43 git config core.gitproxy ./proxy
44'
45
46test_expect_success 'fetch through proxy works' '
47 git fetch fake &&
48 echo one >expect &&
49 git log -1 --format=%s FETCH_HEAD >actual &&
50 test_cmp expect actual
51'
52
53test_expect_success 'funny hostnames are rejected before running proxy' '
54 test_must_fail git fetch git://-remote/repo.git 2>stderr &&
55 test_grep ! "proxying for" stderr
56'
57
58test_done