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: ...@@ -12,8 +12,11 @@ before_script:
python-pygit2 python-srcinfo python-bleach python-markdown python-pygit2 python-srcinfo python-bleach python-markdown
python-sqlalchemy python-alembic python-pytest python-werkzeug python-sqlalchemy python-alembic python-pytest python-werkzeug
python-pytest-tap python-fastapi hypercorn nginx python-authlib 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: test:
script: script:
- make -C test - make -C test
- coverage report --include='aurweb/*'
...@@ -2,11 +2,19 @@ T = $(sort $(wildcard *.t)) ...@@ -2,11 +2,19 @@ T = $(sort $(wildcard *.t))
PROVE := $(shell command -v prove 2> /dev/null) 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 ifdef PROVE
check: sh:
prove . prove .
else else
check: $(T) sh: $(T)
endif endif
clean: 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" ...@@ -18,6 +18,11 @@ AURBLUP="$TOPLEVEL/aurweb/scripts/aurblup.py"
NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py" NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py"
RENDERCOMMENT="$TOPLEVEL/aurweb/scripts/rendercomment.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. # Create the configuration file and a dummy notification script.
cat >config <<-EOF cat >config <<-EOF
[database] [database]
......
...@@ -4,24 +4,25 @@ test_description='git-auth tests' ...@@ -4,24 +4,25 @@ test_description='git-auth tests'
. "$(dirname "$0")/setup.sh" . "$(dirname "$0")/setup.sh"
test_expect_success 'Test basic authentication.' ' 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_USER=user out &&
grep -q AUR_PRIVILEGED=0 out grep -q AUR_PRIVILEGED=0 out
' '
test_expect_success 'Test Trusted User authentication.' ' 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_USER=tu out &&
grep -q AUR_PRIVILEGED=1 out grep -q AUR_PRIVILEGED=1 out
' '
test_expect_success 'Test authentication with an unsupported key type.' ' 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.' ' 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 test_must_be_empty out
' '
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
test_description='git-serve tests' test_description='git-serve tests'
. "$(dirname "$0")/setup.sh" . "$(dirname $0)/setup.sh"
test_expect_success 'Test interactive shell.' ' 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.' ' 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 save_IFS=$IFS
IFS= IFS=
while read -r line; do while read -r line; do
...@@ -25,7 +25,7 @@ test_expect_success 'Test maintenance mode.' ' ...@@ -25,7 +25,7 @@ test_expect_success 'Test maintenance mode.' '
sed "s/^\(enable-maintenance = \)0$/\\11/" config.old >config && sed "s/^\(enable-maintenance = \)0$/\\11/" config.old >config &&
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND=help \ env SSH_ORIGINAL_COMMAND=help \
"$GIT_SERVE" 2>actual && cover "$GIT_SERVE" 2>actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
The AUR is down due to maintenance. We will be back soon. The AUR is down due to maintenance. We will be back soon.
EOF EOF
...@@ -34,7 +34,7 @@ test_expect_success 'Test maintenance mode.' ' ...@@ -34,7 +34,7 @@ test_expect_success 'Test maintenance mode.' '
' '
test_expect_success 'Test IP address logging.' ' 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 && cat >expected <<-EOF &&
1.2.3.4 1.2.3.4
EOF EOF
...@@ -48,7 +48,7 @@ test_expect_success 'Test IP address bans.' ' ...@@ -48,7 +48,7 @@ test_expect_success 'Test IP address bans.' '
SSH_CLIENT="1.3.3.7 1337 22" && SSH_CLIENT="1.3.3.7 1337 22" &&
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND=help \ env SSH_ORIGINAL_COMMAND=help \
"$GIT_SERVE" 2>actual && cover "$GIT_SERVE" 2>actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
The SSH interface is disabled for your IP address. The SSH interface is disabled for your IP address.
EOF EOF
...@@ -58,14 +58,14 @@ test_expect_success 'Test IP address bans.' ' ...@@ -58,14 +58,14 @@ test_expect_success 'Test IP address bans.' '
test_expect_success 'Test setup-repo and list-repos.' ' test_expect_success 'Test setup-repo and list-repos.' '
SSH_ORIGINAL_COMMAND="setup-repo foobar" AUR_USER=user \ 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 \ SSH_ORIGINAL_COMMAND="setup-repo foobar2" AUR_USER=tu \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar *foobar
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user \ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user \
"$GIT_SERVE" 2>&1 >actual && cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
...@@ -77,7 +77,7 @@ test_expect_success 'Test git-receive-pack.' ' ...@@ -77,7 +77,7 @@ test_expect_success 'Test git-receive-pack.' '
EOF EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \ SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual && cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
...@@ -85,7 +85,7 @@ test_expect_success 'Test git-receive-pack with an invalid repository name.' ' ...@@ -85,7 +85,7 @@ test_expect_success 'Test git-receive-pack with an invalid repository name.' '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="git-receive-pack /!.git/" \ env SSH_ORIGINAL_COMMAND="git-receive-pack /!.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual cover "$GIT_SERVE" 2>&1 >actual
' '
test_expect_success "Test git-upload-pack." ' test_expect_success "Test git-upload-pack." '
...@@ -96,7 +96,7 @@ test_expect_success "Test git-upload-pack." ' ...@@ -96,7 +96,7 @@ test_expect_success "Test git-upload-pack." '
EOF EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar.git/" \ SSH_ORIGINAL_COMMAND="git-upload-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual && cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
...@@ -108,7 +108,7 @@ test_expect_success "Try to pull from someone else's repository." ' ...@@ -108,7 +108,7 @@ test_expect_success "Try to pull from someone else's repository." '
EOF EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar2.git/" \ SSH_ORIGINAL_COMMAND="git-upload-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual && cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
...@@ -116,7 +116,7 @@ test_expect_success "Try to push to someone else's repository." ' ...@@ -116,7 +116,7 @@ test_expect_success "Try to push to someone else's repository." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="git-receive-pack /foobar2.git/" \ env SSH_ORIGINAL_COMMAND="git-receive-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \ 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." ' 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." ...@@ -127,7 +127,7 @@ test_expect_success "Try to push to someone else's repository as Trusted User."
EOF EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \ SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=tu AUR_PRIVILEGED=1 \ AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual && cover "$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual test_cmp expected actual
' '
...@@ -139,40 +139,40 @@ test_expect_success "Test restore." ' ...@@ -139,40 +139,40 @@ test_expect_success "Test restore." '
foobar foobar
EOF EOF
SSH_ORIGINAL_COMMAND="restore foobar" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual
' '
test_expect_success "Try to restore an existing package base." ' test_expect_success "Try to restore an existing package base." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="restore foobar2" \ env SSH_ORIGINAL_COMMAND="restore foobar2"\
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 cover "$GIT_SERVE" 2>&1
' '
test_expect_success "Disown all package bases." ' test_expect_success "Disown all package bases." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \ 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 \ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual &&
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual
' '
test_expect_success "Adopt a package base as a regular user." ' test_expect_success "Adopt a package base as a regular user." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar *foobar
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual
' '
...@@ -180,119 +180,119 @@ test_expect_success "Adopt an already adopted package base." ' ...@@ -180,119 +180,119 @@ test_expect_success "Adopt an already adopted package base." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="adopt foobar" \ env SSH_ORIGINAL_COMMAND="adopt foobar" \
AUR_USER=user AUR_PRIVILEGED=0 \ 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." ' test_expect_success "Adopt a package base as a Trusted User." '
SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar2 *foobar2
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual
' '
test_expect_success "Disown one's own package base as a regular user." ' test_expect_success "Disown one's own package base as a regular user." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual
' '
test_expect_success "Disown one's own package base as a Trusted User." ' test_expect_success "Disown one's own package base as a Trusted User." '
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual
' '
test_expect_success "Try to steal another user's package as a regular user." ' 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 \ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="adopt foobar2" \ env SSH_ORIGINAL_COMMAND="adopt foobar2" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar2 *foobar2
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \ 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." ' 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 \ 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 \ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar *foobar
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \ 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." ' 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 \ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="disown foobar2" \ env SSH_ORIGINAL_COMMAND="disown foobar2" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar2 *foobar2
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \ 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_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \ 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." ' 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 \ 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 \ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \ 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_cmp expected actual &&
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \ 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." ' test_expect_success "Adopt a package base and add co-maintainers." '
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \ 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" \ SSH_ORIGINAL_COMMAND="set-comaintainers foobar user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
5|3|1 5|3|1
6|3|2 6|3|2
...@@ -305,7 +305,7 @@ test_expect_success "Adopt a package base and add co-maintainers." ' ...@@ -305,7 +305,7 @@ test_expect_success "Adopt a package base and add co-maintainers." '
test_expect_success "Update package base co-maintainers." ' test_expect_success "Update package base co-maintainers." '
SSH_ORIGINAL_COMMAND="set-comaintainers foobar user2 user3 user4" \ SSH_ORIGINAL_COMMAND="set-comaintainers foobar user2 user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
4|3|1 4|3|1
5|3|2 5|3|2
...@@ -320,7 +320,7 @@ test_expect_success "Try to add co-maintainers to an orphan package base." ' ...@@ -320,7 +320,7 @@ test_expect_success "Try to add co-maintainers to an orphan package base." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="set-comaintainers foobar2 user2 user3 user4" \ env SSH_ORIGINAL_COMMAND="set-comaintainers foobar2 user2 user3 user4" \
AUR_USER=user AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
4|3|1 4|3|1
5|3|2 5|3|2
...@@ -333,12 +333,12 @@ test_expect_success "Try to add co-maintainers to an orphan package base." ' ...@@ -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." ' test_expect_success "Disown a package base and check (co-)maintainer list." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
*foobar *foobar
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user2 AUR_PRIVILEGED=0 \ 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 && test_cmp expected actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
5|3|1 5|3|1
...@@ -351,11 +351,11 @@ test_expect_success "Disown a package base and check (co-)maintainer list." ' ...@@ -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." ' test_expect_success "Force-disown a package base and check (co-)maintainer list." '
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&