commit - abdc4ee6fb5fe9e255c4a15bd681467bf9170cb3c014c82586a376bfdb91740b
commit + e53db67fdd6b2b35c7a48135ce256d9560c719785900fa2e3fe5c0d56108cea5
blob - 29fd12bc44d68174ca488b1860f586ba33a2b7a455d227bae96f3df217426ecc
blob + 5413a01622a4098db8633dd09e7de168af6fa8bac0be133926c407d39586cd1b
--- regress/gotd/send_bad.sh
+++ regress/gotd/send_bad.sh
if [ "$GOT_TEST_ALGO" = "sha256" ]; then
zero_commit="${zero_commit}000000000000000000000000"
- capabilities="${basic_capabilities} object-format=sha256"
+ client_capabilities="${basic_capabilities} object-format=sha256"
server_capabilities="${server_capabilities} object-format=sha256"
else
- capabilities="$basic_capabilities"
+ client_capabilities="$basic_capabilities"
fi
test_send_incompatible_hash_algo() {
other_algo=sha256
commit1="${commit1}aaaaaaaaaaaaaaaaaaaaaaaa"
commit2="${commit2}bbbbbbbbbbbbbbbbbbbbbbbb"
+ capabilities="${client_capabilities}"
fi
# The protocol requires an embedded NUL between reference name
test_done "$testroot" "$ret"
}
+test_announce_wrong_hash_algo() {
+ local testroot=`test_init announce_wrong_hash_algo`
+
+ commit1="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ commit2="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ len="009c"
+ other_algo=sha1
+ capabilities="${client_capabilities}"
+ else
+ capabilities="${basic_capabilities}"
+ len="00b7"
+ other_algo=sha256
+ commit1="${commit1}aaaaaaaaaaaaaaaaaaaaaaaa"
+ commit2="${commit2}bbbbbbbbbbbbbbbbbbbbbbbb"
+ fi
+
+ # The protocol requires an embedded NUL between reference name
+ # and capabilities.
+ echo "${len}$commit1 $commit2 refs/heads/mainX$capabilities" | \
+ tr 'X' '\0' | \
+ ssh ${GOTD_DEVUSER}@127.0.0.1 git-receive-pack '/test-repo' \
+ > $testroot/stdout 2>$testroot/stderr
+
+ # Remove embedded NUL from Git protocol with a space character.
+ tr -d '\0' < $testroot/stdout > $testroot/stdout.filtered
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ echo -n "00ae" > $testroot/stdout.expected
+ else
+ echo -n "0081" > $testroot/stdout.expected
+ fi
+ echo -n "$zero_commit capabilities^{} " >> $testroot/stdout.expected
+ echo -n "agent=got/${GOT_VERSION_STR} ${server_capabilities}0000" \
+ >> $testroot/stdout.expected
+
+ echo -n "0025ERR ref-update with bad object ID" \
+ >> $testroot/stdout.expected
+ echo "gotsh: ref-update with bad object ID" \
+ >> $testroot/stderr.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout.filtered
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "unexpected stdout" >&2
+ diff -a -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "unexpected stderr" >&2
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
run_test test_send_incompatible_hash_algo
+run_test test_announce_wrong_hash_algo