Commit cc078439 authored by Kevin Morris's avatar Kevin Morris Committed by Lukas Fleischer
Browse files

Makefile: run pytest units



Important note: Python tests will repeatedly clear out tables
that they test against; for this reason, one should always run
the shell tests first. The __init__.py file is necessary for
coverage to collect data from the tests being run.

At this point in FastAPI development, I'd like to encourage a
few things going forward:

1. Any time you contribute to the FastAPI codebase, you **must**
   maintain equal or increased coverage on the overall source.
   Developers are highly appreciated for adding tests in your
   specific domain of addition or modification that may be missing
   coverage. Our goal is 100% coverage, and all newly added files
   **must** have 100% coverage through tests.
2. All source should be formatted with the autopep8 tool and
   kept within an 80 column width, with the exception of HTML
   templates.
Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 6f395d06
......@@ -12,8 +12,11 @@ before_script:
python-pygit2 python-srcinfo python-bleach python-markdown
python-sqlalchemy python-alembic python-pytest python-werkzeug
python-pytest-tap python-fastapi hypercorn nginx python-authlib
python-itsdangerous python-httpx
python-itsdangerous python-httpx python-jinja python-pytest-cov
python-requests python-aiofiles python-python-multipart
python-pytest-asyncio python-coverage
test:
script:
- make -C test
- coverage report --include='aurweb/*'
......@@ -2,11 +2,19 @@ T = $(sort $(wildcard *.t))
PROVE := $(shell command -v prove 2> /dev/null)
MAKEFLAGS = -j1
# IMPORTANT: `sh` should come somewhere AFTER `pytest`.
check: sh pytest
pytest:
cd .. && AUR_CONFIG=conf/config coverage run --append /usr/bin/pytest test
ifdef PROVE
check:
sh:
prove .
else
check: $(T)
sh: $(T)
endif
clean:
......
#!/bin/sh
# This script is used by sharness tests hosted in our `test`
# directory. We require a concrete script to make using this easily,
# because we often call `env` in those tests.
#
# The purpose of this script is to allow sharness tests to gather
# Python coverage when calling scripts within `aurweb`.
#
TOPLEVEL=$(dirname "$0")/../..
# Define a COVERAGE_FILE in our root directory.
COVERAGE_FILE="$TOPLEVEL/.coverage" \
coverage run -L --source="$TOPLEVEL/aurweb" --append "$@"
......@@ -18,6 +18,11 @@ AURBLUP="$TOPLEVEL/aurweb/scripts/aurblup.py"
NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py"
RENDERCOMMENT="$TOPLEVEL/aurweb/scripts/rendercomment.py"
# We reuse some of these scripts when running `env`, so add
# it to PATH; that way, env can pick up the script when loaded.
PATH="${PATH}:${TOPLEVEL}/test/scripts"
export PATH
# Create the configuration file and a dummy notification script.
cat >config <<-EOF
[database]
......
......@@ -4,24 +4,25 @@ test_description='git-auth tests'
. "$(dirname "$0")/setup.sh"
test_expect_success 'Test basic authentication.' '
"$GIT_AUTH" "$AUTH_KEYTYPE_USER" "$AUTH_KEYTEXT_USER" >out &&
cover "$GIT_AUTH" "$AUTH_KEYTYPE_USER" "$AUTH_KEYTEXT_USER" >out &&
grep -q AUR_USER=user out &&
grep -q AUR_PRIVILEGED=0 out
'
test_expect_success 'Test Trusted User authentication.' '
"$GIT_AUTH" "$AUTH_KEYTYPE_TU" "$AUTH_KEYTEXT_TU" >out &&
cover "$GIT_AUTH" "$AUTH_KEYTYPE_TU" "$AUTH_KEYTEXT_TU" >out &&
grep -q AUR_USER=tu out &&
grep -q AUR_PRIVILEGED=1 out
'
test_expect_success 'Test authentication with an unsupported key type.' '
test_must_fail "$GIT_AUTH" ssh-xxx "$AUTH_KEYTEXT_USER"
test_must_fail cover "$GIT_AUTH" ssh-xxx "$AUTH_KEYTEXT_USER"
'
test_expect_success 'Test authentication with a wrong key.' '
"$GIT_AUTH" "$AUTH_KEYTYPE_MISSING" "$AUTH_KEYTEXT_MISSING" >out
cover "$GIT_AUTH" "$AUTH_KEYTYPE_MISSING" "$AUTH_KEYTEXT_MISSING" >out
test_must_be_empty out
'
......
......@@ -2,14 +2,14 @@
test_description='git-serve tests'
. "$(dirname "$0")/setup.sh"
. "$(dirname $0)/setup.sh"
test_expect_success 'Test interactive shell.' '
"$GIT_SERVE" 2>&1 | grep -q "Interactive shell is disabled."
cover "$GIT_SERVE" 2>&1 | grep -q "Interactive shell is disabled."
'
test_expect_success 'Test help.' '
SSH_ORIGINAL_COMMAND=help "$GIT_SERVE" 2>actual &&
SSH_ORIGINAL_COMMAND=help cover "$GIT_SERVE" 2>actual &&
save_IFS=$IFS
IFS=
while read -r line; do
......@@ -25,7 +25,7 @@ test_expect_success 'Test maintenance mode.' '
sed "s/^\(enable-maintenance = \)0$/\\11/" config.old >config &&
test_must_fail \
env SSH_ORIGINAL_COMMAND=help \
"$GIT_SERVE" 2>actual &&
cover "$GIT_SERVE" 2>actual &&
cat >expected <<-EOF &&
The AUR is down due to maintenance. We will be back soon.
EOF
......@@ -34,7 +34,7 @@ test_expect_success 'Test maintenance mode.' '
'
test_expect_success 'Test IP address logging.' '
SSH_ORIGINAL_COMMAND=help AUR_USER=user "$GIT_SERVE" 2>actual &&
SSH_ORIGINAL_COMMAND=help AUR_USER=user cover "$GIT_SERVE" 2>actual &&
cat >expected <<-EOF &&
1.2.3.4
EOF
......@@ -48,7 +48,7 @@ test_expect_success 'Test IP address bans.' '
SSH_CLIENT="1.3.3.7 1337 22" &&
test_must_fail \
env SSH_ORIGINAL_COMMAND=help \
"$GIT_SERVE" 2>actual &&
cover "$GIT_SERVE" 2>actual &&
cat >expected <<-EOF &&
The SSH interface is disabled for your IP address.
EOF
......@@ -58,14 +58,14 @@ test_expect_success 'Test IP address bans.' '
test_expect_success 'Test setup-repo and list-repos.' '
SSH_ORIGINAL_COMMAND="setup-repo foobar" AUR_USER=user \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="setup-repo foobar2" AUR_USER=tu \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -77,7 +77,7 @@ test_expect_success 'Test git-receive-pack.' '
EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -85,7 +85,7 @@ test_expect_success 'Test git-receive-pack with an invalid repository name.' '
test_must_fail \
env SSH_ORIGINAL_COMMAND="git-receive-pack /!.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual
cover "$GIT_SERVE" 2>&1 >actual
'
test_expect_success "Test git-upload-pack." '
......@@ -96,7 +96,7 @@ test_expect_success "Test git-upload-pack." '
EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -108,7 +108,7 @@ test_expect_success "Try to pull from someone else's repository." '
EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -116,7 +116,7 @@ test_expect_success "Try to push to someone else's repository." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="git-receive-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Try to push to someone else's repository as Trusted User." '
......@@ -127,7 +127,7 @@ test_expect_success "Try to push to someone else's repository as Trusted User."
EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -139,40 +139,40 @@ test_expect_success "Test restore." '
foobar
EOF
SSH_ORIGINAL_COMMAND="restore foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual
cover "$GIT_SERVE" 2>&1 >actual
test_cmp expected actual
'
test_expect_success "Try to restore an existing package base." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="restore foobar2" \
env SSH_ORIGINAL_COMMAND="restore foobar2"\
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Disown all package bases." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Adopt a package base as a regular user." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
......@@ -180,119 +180,119 @@ test_expect_success "Adopt an already adopted package base." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="adopt foobar" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Adopt a package base as a Trusted User." '
SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar2
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Disown one's own package base as a regular user." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Disown one's own package base as a Trusted User." '
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Try to steal another user's package as a regular user." '
SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
test_must_fail \
env SSH_ORIGINAL_COMMAND="adopt foobar2" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
cat >expected <<-EOF &&
*foobar2
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Try to steal another user's package as a Trusted User." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
cat >expected <<-EOF &&
*foobar
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Try to disown another user's package as a regular user." '
SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
test_must_fail \
env SSH_ORIGINAL_COMMAND="disown foobar2" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar2
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Try to disown another user's package as a Trusted User." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1
cover "$GIT_SERVE" 2>&1
'
test_expect_success "Adopt a package base and add co-maintainers." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="set-comaintainers foobar user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
5|3|1
6|3|2
......@@ -305,7 +305,7 @@ test_expect_success "Adopt a package base and add co-maintainers." '
test_expect_success "Update package base co-maintainers." '
SSH_ORIGINAL_COMMAND="set-comaintainers foobar user2 user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
4|3|1
5|3|2
......@@ -320,7 +320,7 @@ test_expect_success "Try to add co-maintainers to an orphan package base." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="set-comaintainers foobar2 user2 user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
4|3|1
5|3|2
......@@ -333,12 +333,12 @@ test_expect_success "Try to add co-maintainers to an orphan package base." '
test_expect_success "Disown a package base and check (co-)maintainer list." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
cat >expected <<-EOF &&
5|3|1
......@@ -351,11 +351,11 @@ test_expect_success "Disown a package base and check (co-)maintainer list." '
test_expect_success "Force-disown a package base and check (co-)maintainer list." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user3 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual &&
cat >expected <<-EOF &&
EOF
......@@ -366,7 +366,7 @@ test_expect_success "Force-disown a package base and check (co-)maintainer list.
test_expect_success "Check whether package requests are closed when disowning." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (1, 2, 3, "foobar", 4, "", "");
INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (2, 3, 3, "foobar", 5, "", "");
......@@ -374,7 +374,7 @@ test_expect_success "Check whether package requests are closed when disowning."
EOD
>sendmail.out &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat <<-EOD >expected &&
Subject: [PRQ#1] Orphan Request for foobar Accepted
EOD
......@@ -389,7 +389,7 @@ test_expect_success "Check whether package requests are closed when disowning."
test_expect_success "Flag a package base out-of-date." '
SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
1|Because.
EOF
......@@ -400,7 +400,7 @@ test_expect_success "Flag a package base out-of-date." '
test_expect_success "Unflag a package base as flagger." '
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
0|Because.
EOF
......@@ -411,11 +411,11 @@ test_expect_success "Unflag a package base as flagger." '
test_expect_success "Unflag a package base as maintainer." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
0|Because.
EOF
......@@ -426,9 +426,9 @@ test_expect_success "Unflag a package base as maintainer." '
test_expect_success "Unflag a package base as random user." '
SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user3 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
1|Because.
EOF
......@@ -439,11 +439,11 @@ test_expect_success "Unflag a package base as random user." '
test_expect_success "Flag using a comment which is too short." '
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
test_must_fail \
env SSH_ORIGINAL_COMMAND="flag foobar xx" \
AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
0|Because.
EOF
......@@ -454,7 +454,7 @@ test_expect_success "Flag using a comment which is too short." '
test_expect_success "Vote for a package base." '
SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
3|1
EOF
......@@ -472,7 +472,7 @@ test_expect_success "Vote for a package base." '
test_expect_success "Vote for a package base twice." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
3|1
EOF
......@@ -489,7 +489,7 @@ test_expect_success "Vote for a package base twice." '
test_expect_success "Remove vote from a package base." '
SSH_ORIGINAL_COMMAND="unvote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
......@@ -507,7 +507,7 @@ test_expect_success "Try to remove the vote again." '
test_must_fail \
env SSH_ORIGINAL_COMMAND="unvote foobar" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 &&
cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
EOF
echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
......
......@@ -16,7 +16,7 @@ test_expect_success 'Test update hook on a fresh repository.' '
old=0000000000000000000000000000000000000000 &&
new=$(git -C aur.git rev-parse HEAD^) &&
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cat >expected <<-EOF &&
1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/
1|GPL
......@@ -34,7 +34,7 @@ test_expect_success 'Test update hook on another fresh repository.' '
git -C aur.git checkout -q refs/namespaces/foobar2/refs/heads/master &&
new=$(git -C aur.git rev-parse HEAD) &&
AUR_USER=user AUR_PKGBASE=foobar2 AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cat >expected <<-EOF &&
1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
......@@ -55,7 +55,7 @@ test_expect_success 'Test update hook on an updated repository.' '
old=$(git -C aur.git rev-parse HEAD^) &&
new=$(git -C aur.git rev-parse HEAD) &&
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cat >expected <<-EOF &&
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
3|1|foobar|1-2|aurweb test package.|https://aur.archlinux.org/
......@@ -74,7 +74,7 @@ test_expect_success 'Test update hook on an updated repository.' '
test_expect_success 'Test restore mode.' '
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" restore 2>&1 &&
cover "$GIT_UPDATE" restore 2>&1 &&
cat >expected <<-EOF &&
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
3|1|foobar|1-2|aurweb test package.|https://aur.archlinux.org/
......@@ -97,7 +97,7 @@ test_expect_success 'Test restore mode on a non-existent repository.' '
EOD
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar3 AUR_PRIVILEGED=0 \
"$GIT_UPDATE" restore >actual 2>&1 &&
cover "$GIT_UPDATE" restore >actual 2>&1 &&
test_cmp expected actual
'
......@@ -109,7 +109,7 @@ test_expect_success 'Pushing to a branch other than master.' '
EOD
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/pu "$old" "$new" >actual 2>&1 &&
cover "$GIT_UPDATE" refs/heads/pu "$old" "$new" >actual 2>&1 &&
test_cmp expected actual
'
......@@ -121,7 +121,7 @@ test_expect_success 'Performing a non-fast-forward ref update.' '
EOD
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&
test_cmp expected actual
'
......@@ -133,7 +133,7 @@ test_expect_success 'Performing a non-fast-forward ref update as Trusted User.'
EOD
test_must_fail \
env AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
test_cmp expected actual
'
......@@ -145,7 +145,7 @@ test_expect_success 'Performing a non-fast-forward ref update as normal user wit
EOD
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 AUR_OVERWRITE=1 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 &&
test_cmp expected actual
'
......@@ -153,7 +153,7 @@ test_expect_success 'Performing a non-fast-forward ref update as Trusted User wi
old=$(git -C aur.git rev-parse HEAD) &&
new=$(git -C aur.git rev-parse HEAD^) &&
AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 AUR_OVERWRITE=1 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1
'
test_expect_success 'Removing .SRCINFO.' '
......@@ -164,7 +164,7 @@ test_expect_success 'Removing .SRCINFO.' '
new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&
cover "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&
grep -q "^error: missing .SRCINFO$" actual
'
......@@ -177,7 +177,7 @@ test_expect_success 'Removing .SRCINFO with a follow-up fix.' '
new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&