commit f0bab4651c526c1d7907bfe9b83583e7c95c8d3add5ff2e82c5a3f5736012137 from: Stefan Sperling date: Sun Oct 25 09:47:54 2026 UTC add test coverage for "hash algorithm" in global gotsys.conf context commit - 2cd8863b9225d29955e9620edf5804d13d3eb5c3c5b509ef366629f2aecbb02b commit + f0bab4651c526c1d7907bfe9b83583e7c95c8d3add5ff2e82c5a3f5736012137 blob - 0ac6f44a8030382775f15decacec74cc2bad79cd5d6a7062350f76ed328de08c blob + 9fbcd9c6c43ee9e18d4fc7135a1dc6ea4850e9bce5d59ae9be1a2485b992a641 --- regress/gotsysd/test_gotsysd.sh +++ regress/gotsysd/test_gotsysd.sh @@ -1292,6 +1292,52 @@ EOF return 1 fi + # An ambiguous default hash algo in gotsys.conf should be rejected. + cat > ${testroot}/wt/gotsys.conf < $testroot/stdout 2> $testroot/stderr + ret=$? + if [ $ret -eq 0 ]; then + echo "gotsys check succeeded unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + + cat > ${testroot}/stderr.expected </dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "got checkout failed unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + + if [ "${GOT_TEST_ALGO}" = "sha256" ]; then + OTHER_ALGO=sha1 + else + OTHER_ALGO=sha256 + fi + + crypted_vm_pw=`echo ${GOTSYSD_VM_PASSWORD} | encrypt | tr -d '\n'` + crypted_pw=`echo ${GOTSYSD_DEV_PASSWORD} | encrypt | tr -d '\n'` + sshkey=`cat ${GOTSYSD_SSH_PUBKEY}` + cat > ${testroot}/wt/gotsys.conf </dev/null) + local commit_id=`git_show_head $testroot/${GOTSYS_REPO}` + + got send -q -i ${GOTSYSD_SSH_KEY} -r ${testroot}/${GOTSYS_REPO} + ret=$? + if [ $ret -ne 0 ]; then + echo "got send failed unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + + # Wait for gotsysd to apply the new configuration. + echo "$commit_id" > $testroot/stdout.expected + for i in 1 2 3 4 5; do + sleep 1 + ssh -i ${GOTSYSD_SSH_KEY} root@${VMIP} \ + cat /var/db/gotsysd/commit > $testroot/stdout + if cmp -s $testroot/stdout.expected $testroot/stdout; then + break; + fi + done + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + echo "gotsysd failed to apply configuration" >&2 + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + # We should be able to import data into the newly created repository. + got init -A ${OTHER_ALGO} $testroot/other-algo.git + mkdir $testroot/other-algo + echo alpha > $testroot/other-algo/alpha + got import -m init -r $testroot/other-algo.git \ + $testroot/other-algo >/dev/null + + cat > $testroot/other-algo.git/got.conf <&2 + test_done "$testroot" 1 + return 1 + fi + + test_done "$testroot" "$ret" +} + + test_parseargs "$@" run_test test_user_add run_test test_user_mod @@ -2653,3 +2802,4 @@ run_test test_http_notification run_test test_http_notification_hmac run_test test_email_notification run_test test_no_gotsys_conf_in_pack +run_test test_default_hash_algo