Commit Diff


commit - 38593aa7708aaf3555b8769576a06d7b98bd16f2e794700a37920a9cf375b9c1
commit + 1f011542bba73f3c01b674a1630e9a2df9bc5b31a41bd620b39ee4f410fe715e
blob - ac9d41d902211b9e797bf592c6ec88d9431f8af89d40d06876a58af6be0a25c4
blob + b6bf90d0f30abc3ab290ba8c0f79c10d0ede37d3c61b14c2dd9e98e53ff43df3
--- regress/gotsysd/test_gotwebd.sh	
+++ regress/gotsysd/test_gotwebd.sh	
@@ -1104,8 +1104,242 @@ EOF
 	test_done "$testroot" "$ret"
 }
 
+test_utf8_site_owner() {
+	local testroot=`test_init utf8_site_owner 1`
+
+	GOTSYS_ECDSA_HOST_FP=$(ssh -i ${GOTSYSD_SSH_KEY} \
+		${GOTSYSD_TEST_USER}@${VMIP} \
+		ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub | \
+		cut -d' ' -f2)
+	GOTSYS_ED25519_HOST_FP=$(ssh -i ${GOTSYSD_SSH_KEY} \
+		${GOTSYSD_TEST_USER}@${VMIP} \
+		ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub | \
+		cut -d' ' -f2)
+	GOTSYS_RSA_HOST_FP=$(ssh -i ${GOTSYSD_SSH_KEY} \
+		${GOTSYSD_TEST_USER}@${VMIP} \
+		ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub | \
+		cut -d' ' -f2)
+
+	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
+
+	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
+user ${GOTSYSD_TEST_USER} {
+	password "${crypted_vm_pw}" 
+	authorized key ${sshkey}
+}
+user ${GOTSYSD_DEV_USER} {
+	password "${crypted_pw}" 
+	authorized key ${sshkey}
+}
+repository gotsys.git {
+	permit rw ${GOTSYSD_TEST_USER}
+	permit rw ${GOTSYSD_DEV_USER}
+}
+repository public.git {
+	permit rw ${GOTSYSD_TEST_USER}
+	permit rw ${GOTSYSD_DEV_USER}
+}
+repository gottestdev.git {
+	permit rw ${GOTSYSD_DEV_USER}
+}
+repository gottest.git {
+	permit rw ${GOTSYSD_TEST_USER}
+}
+repository hidden.git {
+	permit rw ${GOTSYSD_TEST_USER}
+}
+web server "${VMIP}" {
+	repository public {
+		disable authentication
+	}
+	repository gottestdev.git {
+		permit ${GOTSYSD_DEV_USER}
+		deny ${GOTSYSD_TEST_USER}
+	}
+	repository gottest.git {
+		permit ${GOTSYSD_TEST_USER}
+	}
+	repository hidden {
+		permit ${GOTSYSD_TEST_USER}
+		deny ${GOTSYSD_DEV_USER}
+		hide repository on
+	}
+EOF
+	cp  ${testroot}/wt/gotsys.conf ${testroot}/wt/gotsys.conf.bad
+
+	# "honey bear" in German, in UTF-8 encoding
+	printf '\tsite owner "Honigb\xc3\xa4r"\n' >> ${testroot}/wt/gotsys.conf
+
+	# "honey bear" in German, in Latin1 encoding
+	printf '\tsite owner "Honigb\xe4r"\n' >> ${testroot}/wt/gotsys.conf.bad
+
+	printf '}\n' >> ${testroot}/wt/gotsys.conf.bad
+	printf '}\n' >> ${testroot}/wt/gotsys.conf
+
+	(cd ${testroot}/wt && gotsys check -q \
+		-f ${testroot}/wt/gotsys.conf.bad 2> ${testroot}/stderr)
+	ret=$?
+	if [ $ret -eq 0 ]; then
+		echo "bad gotsys.conf accepted by gotsys check" >&2
+		test_done "$testroot" 1
+		return 1
+	fi
+	cat > $testroot/stderr.expected <<EOF
+gotsys: ${testroot}/wt/gotsys.conf.bad: line 42: invalid UTF-8 string
+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
+
+	(cd ${testroot}/wt && gotsys check -q)
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		echo "bad gotsys.conf written by test" >&2
+		test_done "$testroot" 1
+		return 1
+	fi
+
+	(cd ${testroot}/wt && got commit -m "add UTF-8 strings" >/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
+
+	got init $testroot/public.git > /dev/null
+	mkdir -p $testroot/public
+
+	cat > $testroot/public/readme.txt <<EOF
+Testing the summary page of gotwebd
+EOF
+	got import -m init -r $testroot/public.git $testroot/public > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		echo "got import failed unexpectedly" >&2
+		return 1
+	fi
+	local commit_id=`git_show_head $testroot/public.git`
+	local short_commit_id=`trim_obj_id 10 $commit_id`
+
+	cat > $testroot/public.git/got.conf <<EOF
+remote "origin" {
+	server "${GOTSYSD_DEV_USER}@$VMIP"
+	protocol ssh
+	repository "public"
+}
+EOF
+	got send -q -i ${GOTSYSD_SSH_KEY} -b main -f -r $testroot/public.git
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		echo "got send failed unexpectedly" >&2
+		return 1
+	fi
+
+	# Attempt to access a public repository's summary
+	w3m -O UTF-8 "http://${VMIP}/?action=summary&path=public.git" -dump \
+		> $testroot/stdout
+
+	cat > $testroot/stdout.expected <<EOF
+[got]
+Repositories / public.git / summary
+
+Clone URL:
+
+    ssh://${GOTSYSD_TEST_USER}@${VMIP}/public.git
+
+ECDSA:
+
+    ${GOTSYS_ECDSA_HOST_FP}
+
+ED25519:
+
+    ${GOTSYS_ED25519_HOST_FP}
+
+RSA:
+
+    ${GOTSYS_RSA_HOST_FP}
+
+Commit Briefs
+
+right now $short_commit_id Flan Hacker
+
+init (main)
+
+diff | patch | tree
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+Branches
+
+right now
+main
+summary | commit briefs | commits
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+Tags
+
+This repository contains no tags
+
+Tree
+
+readme.txt commits | blame
+
+readme.txt
+
+Testing the summary page of gotwebd
+
+Honigbär
+
+EOF
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	test_done "$testroot" "$ret"
+}
+
 test_parseargs "$@"
 run_test test_login
 run_test test_access_rules_index_page
 run_test test_access_rules_tree_page
 run_test test_summary_page
+run_test test_utf8_site_owner