Merge branch 'ab/ci-updates'
[git/debian.git] / t / t5704-protocol-violations.sh
blobae1a00afb09e2f38b272602a9c39d51f0fa72110
1 #!/bin/sh
3 test_description='Test responses to violations of the network protocol. In most
4 of these cases it will generally be acceptable for one side to break off
5 communications if the other side says something unexpected. We are mostly
6 making sure that we do not segfault or otherwise behave badly.'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success 'extra delim packet in v2 ls-refs args' '
13 packetize command=ls-refs &&
14 packetize "object-format=$(test_oid algo)" &&
15 printf 0001 &&
16 # protocol expects 0000 flush here
17 printf 0001
18 } >input &&
19 test_must_fail env GIT_PROTOCOL=version=2 \
20 git upload-pack . <input 2>err &&
21 test_i18ngrep "expected flush after ls-refs arguments" err
24 test_expect_success 'extra delim packet in v2 fetch args' '
26 packetize command=fetch &&
27 packetize "object-format=$(test_oid algo)" &&
28 printf 0001 &&
29 # protocol expects 0000 flush here
30 printf 0001
31 } >input &&
32 test_must_fail env GIT_PROTOCOL=version=2 \
33 git upload-pack . <input 2>err &&
34 test_i18ngrep "expected flush after fetch arguments" err
37 test_expect_success 'bogus symref in v0 capabilities' '
38 test_commit foo &&
39 oid=$(git rev-parse HEAD) &&
40 dst=refs/heads/foo &&
42 printf "%s HEAD\0symref object-format=%s symref=HEAD:%s\n" \
43 "$oid" "$GIT_DEFAULT_HASH" "$dst" |
44 test-tool pkt-line pack-raw-stdin &&
45 printf "0000"
46 } >input &&
47 git ls-remote --symref --upload-pack="cat input; read junk;:" . >actual &&
48 printf "ref: %s\tHEAD\n%s\tHEAD\n" "$dst" "$oid" >expect &&
49 test_cmp expect actual
52 test_done