| 1 | #!/bin/sh |
| 2 | |
| 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.' |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | test_expect_success 'extra delim packet in v2 ls-refs args' ' |
| 11 | { |
| 12 | packetize command=ls-refs && |
| 13 | packetize "object-format=$(test_oid algo)" && |
| 14 | printf 0001 && |
| 15 | # protocol expects 0000 flush here |
| 16 | printf 0001 |
| 17 | } >input && |
| 18 | test_must_fail env GIT_PROTOCOL=version=2 \ |
| 19 | git upload-pack . <input 2>err && |
| 20 | test_grep "expected flush after ls-refs arguments" err |
| 21 | ' |
| 22 | |
| 23 | test_expect_success 'extra delim packet in v2 fetch args' ' |
| 24 | { |
| 25 | packetize command=fetch && |
| 26 | packetize "object-format=$(test_oid algo)" && |
| 27 | printf 0001 && |
| 28 | # protocol expects 0000 flush here |
| 29 | printf 0001 |
| 30 | } >input && |
| 31 | test_must_fail env GIT_PROTOCOL=version=2 \ |
| 32 | git upload-pack . <input 2>err && |
| 33 | test_grep "expected flush after fetch arguments" err |
| 34 | ' |
| 35 | |
| 36 | test_expect_success 'bogus symref in v0 capabilities' ' |
| 37 | test_commit foo && |
| 38 | oid=$(git rev-parse HEAD) && |
| 39 | dst=refs/heads/foo && |
| 40 | { |
| 41 | printf "%s HEAD\0symref object-format=%s symref=HEAD:%s\n" \ |
| 42 | "$oid" "$GIT_DEFAULT_HASH" "$dst" | |
| 43 | test-tool pkt-line pack-raw-stdin && |
| 44 | printf "0000" |
| 45 | } >input && |
| 46 | git ls-remote --symref --upload-pack="cat input; read junk;:" . >actual && |
| 47 | printf "ref: %s\tHEAD\n%s\tHEAD\n" "$dst" "$oid" >expect && |
| 48 | test_cmp expect actual |
| 49 | ' |
| 50 | |
| 51 | test_done |