3 # Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ..
/cmdline
/common.sh
20 test_send_empty_readonly
() {
21 local testroot
=`test_init send_empty`
22 local commit_id
=`git_show_head $testroot/repo`
24 (cd ${GOTD_TEST_REPO} && find .
> $testroot/repo-list.before
)
26 # The gotd-controlled test repository starts out empty.
27 got ref
-l -r ${GOTD_TEST_REPO} > $testroot/ref-list.before
28 echo "HEAD: refs/heads/main" > $testroot/ref-list.expected
29 cmp -s $testroot/ref-list.expected
$testroot/ref-list.before
31 if [ $ret -ne 0 ]; then
32 diff -u $testroot/ref-list.expected
$testroot/ref-list.before
33 test_done
"$testroot" "$ret"
37 got checkout
-q $testroot/repo
$testroot/wt
>/dev
/null
39 if [ $ret -ne 0 ]; then
40 echo "got checkout failed unexpectedly" >&2
41 test_done
"$testroot" 1
45 # send contents of $testroot/repo to ${GOTD_TEST_REPO}
46 cat >> $testroot/wt
/.got
/got.conf
<<EOF
48 server ${GOTD_DEVUSER}@127.0.0.1
49 repository "test-repo"
53 (cd $testroot/wt
&& got send
-q -a gotd
2> $testroot/stderr
)
55 if [ $ret -eq 0 ]; then
56 echo "got send succeeded unexpectedly" >&2
57 test_done
"$testroot" 1
61 # Verify that the send operation failed.
62 # The error returned will differ depending on whether read access
63 # is denied explicitly for GOTD_DEVUSER.
64 if grep -q "permit.*${GOTD_DEVUSER}$" $GOTD_CONF; then
65 echo "got-send-pack: test-repo: Permission denied" \
66 > $testroot/stderr.expected
68 echo 'got-send-pack: no git repository found' \
69 > $testroot/stderr.expected
71 grep '^got-send-pack:' $testroot/stderr
> $testroot/stderr.filtered
72 cmp -s $testroot/stderr.expected
$testroot/stderr.filtered
74 if [ $ret -ne 0 ]; then
75 diff -u $testroot/stderr.expected
$testroot/stderr.filtered
76 test_done
"$testroot" "$ret"
80 # Server should not have created a new reference.
81 got ref
-l -r ${GOTD_TEST_REPO} > $testroot/ref-list.after
82 echo "HEAD: refs/heads/main" > $testroot/ref-list.expected
83 cmp -s $testroot/ref-list.expected
$testroot/ref-list.after
85 if [ $ret -ne 0 ]; then
86 diff -u $testroot/ref-list.expected
$testroot/ref-list.after
87 test_done
"$testroot" "$ret"
91 test_done
"$testroot" "$ret"
95 run_test test_send_empty_readonly