commit - 2cd8863b9225d29955e9620edf5804d13d3eb5c3c5b509ef366629f2aecbb02b
commit + f0bab4651c526c1d7907bfe9b83583e7c95c8d3add5ff2e82c5a3f5736012137
blob - 0ac6f44a8030382775f15decacec74cc2bad79cd5d6a7062350f76ed328de08c
blob + 9fbcd9c6c43ee9e18d4fc7135a1dc6ea4850e9bce5d59ae9be1a2485b992a641
--- regress/gotsysd/test_gotsysd.sh
+++ regress/gotsysd/test_gotsysd.sh
return 1
fi
+ # An ambiguous default hash algo in gotsys.conf should be rejected.
+ cat > ${testroot}/wt/gotsys.conf <<EOF
+group slackers
+
+hash algorithm sha1
+hash algorithm sha256
+
+looser ${GOTSYSD_TEST_USER} {
+ password "${crypted_vm_pw}"
+ authorized key ${sshkey}
+}
+looser ${GOTSYSD_DEV_USER} {
+ password "${crypted_pw}"
+ authorized key ${sshkey}
+}
+repository gotsys.git {
+ hash algorithm "${GOT_TEST_ALGO}"
+ permit rw ${GOTSYSD_TEST_USER}
+ permit rw ${GOTSYSD_DEV_USER}
+}
+repository "foo" {
+ hash algorithm "${GOT_TEST_ALGO}"
+ permit rw ${GOTSYSD_DEV_USER}
+ permit ro anonymous
+}
+EOF
+ gotsys check -f ${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 <<EOF
+gotsys: ${testroot}/wt/gotsys.conf: line 4: the default hash algorithm can only be specified once
+EOF
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
test_done "$testroot" "0"
}
test_done "$testroot" "$ret"
}
+test_default_hash_algo() {
+ local testroot=`test_init default_hash_algo 1`
+ got checkout -q $testroot/${GOTSYS_REPO} $testroot/wt >/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 <<EOF
+group slackers
+
+user ${GOTSYSD_TEST_USER} {
+ password "${crypted_vm_pw}"
+ authorized key ${sshkey}
+}
+user ${GOTSYSD_DEV_USER} {
+ password "${crypted_pw}"
+ authorized key ${sshkey}
+}
+
+repository gotsys.git {
+ hash algorithm "${GOT_TEST_ALGO}"
+ permit rw ${GOTSYSD_TEST_USER}
+ permit rw ${GOTSYSD_DEV_USER}
+}
+
+hash algorithm $OTHER_ALGO
+
+repository other-algo {
+ # hash algorithm was overidden by global setting
+ permit rw ${GOTSYSD_TEST_USER}
+ permit rw ${GOTSYSD_DEV_USER}
+}
+EOF
+ (cd ${testroot}/wt && got commit -m "set 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 <<EOF
+remote "origin" {
+ server ${GOTSYSD_DEV_USER}@${VMIP}
+ protocol ssh
+ repository "other-algo.git"
+ branch "main"
+}
+EOF
+ got send -q -i ${GOTSYSD_SSH_KEY} -r ${testroot}/other-algo.git
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got send failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
+
test_parseargs "$@"
run_test test_user_add
run_test test_user_mod
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