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 <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2020-12-21 00:49:15 -08:00
parent 4230772e3b
commit e800cefe95
14 changed files with 175 additions and 145 deletions

View file

@ -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/*'

View file

@ -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:

13
test/scripts/cover Executable file
View file

@ -0,0 +1,13 @@
#!/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 "$@"

View file

@ -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]

View file

@ -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
' '

View file

@ -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.' '
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.' '
' '
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.' '
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.' '
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.' '
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.' '
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." '
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." '
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." '
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."
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." '
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." '
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." '
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." '
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." '
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." '
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 &&
EOF EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user3 AUR_PRIVILEGED=0 \ 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 && test_cmp expected actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&
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." ' test_expect_success "Check whether package requests are closed when disowning." '
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 <<-EOD | sqlite3 aur.db && 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 (1, 2, 3, "foobar", 4, "", "");
INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (2, 3, 3, "foobar", 5, "", ""); 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 EOD
>sendmail.out && >sendmail.out &&
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 <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Orphan Request for foobar Accepted Subject: [PRQ#1] Orphan Request for foobar Accepted
EOD 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." ' test_expect_success "Flag a package base out-of-date." '
SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
1|Because. 1|Because.
EOF EOF
@ -400,7 +400,7 @@ test_expect_success "Flag a package base out-of-date." '
test_expect_success "Unflag a package base as flagger." ' test_expect_success "Unflag a package base as flagger." '
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
0|Because. 0|Because.
EOF EOF
@ -411,11 +411,11 @@ test_expect_success "Unflag a package base as flagger." '
test_expect_success "Unflag a package base as maintainer." ' test_expect_success "Unflag a package base as maintainer." '
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="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \ 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 \ SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
0|Because. 0|Because.
EOF EOF
@ -426,9 +426,9 @@ test_expect_success "Unflag a package base as maintainer." '
test_expect_success "Unflag a package base as random user." ' test_expect_success "Unflag a package base as random user." '
SSH_ORIGINAL_COMMAND="flag foobar Because." AUR_USER=user2 AUR_PRIVILEGED=0 \ 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 \ SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user3 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
1|Because. 1|Because.
EOF 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." ' test_expect_success "Flag using a comment which is too short." '
SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="unflag foobar" AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="flag foobar xx" \ env SSH_ORIGINAL_COMMAND="flag foobar xx" \
AUR_USER=user2 AUR_PRIVILEGED=0 \ AUR_USER=user2 AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
0|Because. 0|Because.
EOF EOF
@ -454,7 +454,7 @@ test_expect_success "Flag using a comment which is too short." '
test_expect_success "Vote for a package base." ' test_expect_success "Vote for a package base." '
SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
3|1 3|1
EOF EOF
@ -472,7 +472,7 @@ test_expect_success "Vote for a package base." '
test_expect_success "Vote for a package base twice." ' test_expect_success "Vote for a package base twice." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \ env SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
3|1 3|1
EOF EOF
@ -489,7 +489,7 @@ test_expect_success "Vote for a package base twice." '
test_expect_success "Remove vote from a package base." ' test_expect_success "Remove vote from a package base." '
SSH_ORIGINAL_COMMAND="unvote foobar" AUR_USER=user AUR_PRIVILEGED=0 \ SSH_ORIGINAL_COMMAND="unvote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 && cover "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
EOF EOF
echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
@ -507,7 +507,7 @@ test_expect_success "Try to remove the vote again." '
test_must_fail \ test_must_fail \
env SSH_ORIGINAL_COMMAND="unvote foobar" \ env SSH_ORIGINAL_COMMAND="unvote foobar" \
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
echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \

View file

@ -16,7 +16,7 @@ test_expect_success 'Test update hook on a fresh repository.' '
old=0000000000000000000000000000000000000000 && old=0000000000000000000000000000000000000000 &&
new=$(git -C aur.git rev-parse HEAD^) && new=$(git -C aur.git rev-parse HEAD^) &&
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 && cat >expected <<-EOF &&
1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/ 1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/
1|GPL 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 && git -C aur.git checkout -q refs/namespaces/foobar2/refs/heads/master &&
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
AUR_USER=user AUR_PKGBASE=foobar2 AUR_PRIVILEGED=0 \ 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 && cat >expected <<-EOF &&
1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/ 1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/
2|2|foobar2|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^) && old=$(git -C aur.git rev-parse HEAD^) &&
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 && cat >expected <<-EOF &&
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
3|1|foobar|1-2|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.' ' test_expect_success 'Test restore mode.' '
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
"$GIT_UPDATE" restore 2>&1 && cover "$GIT_UPDATE" restore 2>&1 &&
cat >expected <<-EOF && cat >expected <<-EOF &&
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
3|1|foobar|1-2|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 EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar3 AUR_PRIVILEGED=0 \ 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 test_cmp expected actual
' '
@ -109,7 +109,7 @@ test_expect_success 'Pushing to a branch other than master.' '
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 test_cmp expected actual
' '
@ -121,7 +121,7 @@ test_expect_success 'Performing a non-fast-forward ref update.' '
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 test_cmp expected actual
' '
@ -133,7 +133,7 @@ test_expect_success 'Performing a non-fast-forward ref update as Trusted User.'
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ 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 test_cmp expected actual
' '
@ -145,7 +145,7 @@ test_expect_success 'Performing a non-fast-forward ref update as normal user wit
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 AUR_OVERWRITE=1 \ 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 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) && old=$(git -C aur.git rev-parse HEAD) &&
new=$(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 \ 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.' ' test_expect_success 'Removing .SRCINFO.' '
@ -164,7 +164,7 @@ test_expect_success 'Removing .SRCINFO.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 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) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 grep -q "^error: missing .SRCINFO$" actual
' '
@ -189,7 +189,7 @@ test_expect_success 'Removing PKGBUILD.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 PKGBUILD$" actual grep -q "^error: missing PKGBUILD$" actual
' '
@ -203,7 +203,7 @@ test_expect_success 'Pushing a tree with a subdirectory.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: the repository must not contain subdirectories$" actual grep -q "^error: the repository must not contain subdirectories$" actual
' '
@ -216,7 +216,7 @@ test_expect_success 'Pushing a tree with a large blob.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: maximum blob size (250.00KiB) exceeded$" actual grep -q "^error: maximum blob size (250.00KiB) exceeded$" actual
' '
@ -232,7 +232,7 @@ test_expect_success 'Pushing .SRCINFO with a non-matching package base.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: invalid pkgbase: foobar2, expected foobar$" actual grep -q "^error: invalid pkgbase: foobar2, expected foobar$" actual
' '
@ -248,7 +248,7 @@ test_expect_success 'Pushing .SRCINFO with invalid syntax.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ env 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
' '
test_expect_success 'Pushing .SRCINFO without pkgver.' ' test_expect_success 'Pushing .SRCINFO without pkgver.' '
@ -263,7 +263,7 @@ test_expect_success 'Pushing .SRCINFO without pkgver.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 mandatory field: pkgver$" actual grep -q "^error: missing mandatory field: pkgver$" actual
' '
@ -279,7 +279,7 @@ test_expect_success 'Pushing .SRCINFO without pkgrel.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 mandatory field: pkgrel$" actual grep -q "^error: missing mandatory field: pkgrel$" actual
' '
@ -294,7 +294,7 @@ test_expect_success 'Pushing .SRCINFO with epoch.' '
) && ) &&
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 && cat >expected <<-EOF &&
2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
3|1|foobar|1:1-2|aurweb test package.|https://aur.archlinux.org/ 3|1|foobar|1:1-2|aurweb test package.|https://aur.archlinux.org/
@ -315,7 +315,7 @@ test_expect_success 'Pushing .SRCINFO with invalid pkgname.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: invalid package name: !$" actual grep -q "^error: invalid package name: !$" actual
' '
@ -331,7 +331,7 @@ test_expect_success 'Pushing .SRCINFO with invalid epoch.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: invalid epoch: !$" actual grep -q "^error: invalid epoch: !$" actual
' '
@ -348,7 +348,7 @@ test_expect_success 'Pushing .SRCINFO with too long URL.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: url field too long: $url\$" actual grep -q "^error: url field too long: $url\$" actual
' '
@ -364,7 +364,7 @@ test_expect_success 'Missing install file.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 install file: install$" actual grep -q "^error: missing install file: install$" actual
' '
@ -380,7 +380,7 @@ test_expect_success 'Missing changelog file.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 changelog file: changelog$" actual grep -q "^error: missing changelog file: changelog$" actual
' '
@ -396,7 +396,7 @@ test_expect_success 'Missing source file.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 source file: file$" actual grep -q "^error: missing source file: file$" actual
' '
@ -413,7 +413,7 @@ test_expect_success 'Pushing .SRCINFO with too long source URL.' '
new=$(git -C aur.git rev-parse HEAD) && new=$(git -C aur.git rev-parse HEAD) &&
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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: source entry too long: $url\$" actual grep -q "^error: source entry too long: $url\$" actual
' '
@ -428,7 +428,7 @@ test_expect_success 'Pushing a blacklisted package.' '
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 test_cmp expected actual
' '
@ -442,7 +442,7 @@ test_expect_success 'Pushing a blacklisted package as Trusted User.' '
warning: package is blacklisted: forbidden warning: package is blacklisted: forbidden
EOD EOD
AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \
"$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 test_cmp expected actual
' '
@ -457,7 +457,7 @@ test_expect_success 'Pushing a package already in the official repositories.' '
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ 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 test_cmp expected actual
' '
@ -471,7 +471,7 @@ test_expect_success 'Pushing a package already in the official repositories as T
warning: package already provided by [core]: official warning: package already provided by [core]: official
EOD EOD
AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \
"$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 test_cmp expected actual
' '
@ -491,7 +491,7 @@ test_expect_success 'Trying to hijack a package.' '
EOD EOD
test_must_fail \ test_must_fail \
env AUR_USER=user AUR_PKGBASE=foobar2 AUR_PRIVILEGED=0 \ env AUR_USER=user AUR_PKGBASE=foobar2 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 test_cmp expected actual
' '

View file

@ -7,7 +7,7 @@ test_description='mkpkglists tests'
test_expect_success 'Test package list generation with no packages.' ' test_expect_success 'Test package list generation with no packages.' '
echo "DELETE FROM Packages;" | sqlite3 aur.db && echo "DELETE FROM Packages;" | sqlite3 aur.db &&
echo "DELETE FROM PackageBases;" | sqlite3 aur.db && echo "DELETE FROM PackageBases;" | sqlite3 aur.db &&
"$MKPKGLISTS" && cover "$MKPKGLISTS" &&
test $(zcat packages.gz | wc -l) -eq 1 && test $(zcat packages.gz | wc -l) -eq 1 &&
test $(zcat pkgbase.gz | wc -l) -eq 1 test $(zcat pkgbase.gz | wc -l) -eq 1
' '
@ -24,7 +24,7 @@ test_expect_success 'Test package list generation.' '
INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (4, 2, "pkg4"); INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (4, 2, "pkg4");
INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (5, 3, "pkg5"); INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (5, 3, "pkg5");
EOD EOD
"$MKPKGLISTS" && cover "$MKPKGLISTS" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
foobar foobar
foobar2 foobar2
@ -45,7 +45,7 @@ test_expect_success 'Test package list generation.' '
' '
test_expect_success 'Test user list generation.' ' test_expect_success 'Test user list generation.' '
"$MKPKGLISTS" && cover "$MKPKGLISTS" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
dev dev
tu tu

View file

@ -15,7 +15,7 @@ test_expect_success 'Test Trusted User vote reminders.' '
INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (4, "Lorem ipsum.", "user", 0, $threedays, 0.00, 2); INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (4, "Lorem ipsum.", "user", 0, $threedays, 0.00, 2);
EOD EOD
>sendmail.out && >sendmail.out &&
"$TUVOTEREMINDER" && cover "$TUVOTEREMINDER" &&
grep -q "Proposal 2" sendmail.out && grep -q "Proposal 2" sendmail.out &&
grep -q "Proposal 3" sendmail.out && grep -q "Proposal 3" sendmail.out &&
test_must_fail grep -q "Proposal 1" sendmail.out && test_must_fail grep -q "Proposal 1" sendmail.out &&
@ -35,7 +35,7 @@ test_expect_success 'Check that only TUs who did not vote receive reminders.' '
INSERT INTO TU_Votes (VoteID, UserID) VALUES (1, 9); INSERT INTO TU_Votes (VoteID, UserID) VALUES (1, 9);
EOD EOD
>sendmail.out && >sendmail.out &&
"$TUVOTEREMINDER" && cover "$TUVOTEREMINDER" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: TU Vote Reminder: Proposal 2 Subject: TU Vote Reminder: Proposal 2
To: tu2@localhost To: tu2@localhost

View file

@ -13,7 +13,7 @@ test_expect_success 'Test package base cleanup script.' '
INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (3, "foobar3", NULL, $now, 0, ""); INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (3, "foobar3", NULL, $now, 0, "");
INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (4, "foobar4", NULL, $threedaysago, 0, ""); INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (4, "foobar4", NULL, $threedaysago, 0, "");
EOD EOD
"$PKGMAINT" && cover "$PKGMAINT" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
foobar foobar
foobar2 foobar2

View file

@ -39,7 +39,7 @@ test_expect_success 'Test official provider update script.' '
EOD EOD
( cd remote/test && bsdtar -czf ../test.db * ) && ( cd remote/test && bsdtar -czf ../test.db * ) &&
mkdir sync && mkdir sync &&
"$AURBLUP" && cover "$AURBLUP" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
foobar|test|foobar foobar|test|foobar
foobar2|test|foobar2 foobar2|test|foobar2

View file

@ -18,7 +18,7 @@ test_expect_success 'Test out-of-date notifications.' '
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1003, 4, 1); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1003, 4, 1);
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" flag 1 1001 && cover "$NOTIFY" flag 1 1001 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Out-of-date Notification for foobar Subject: AUR Out-of-date Notification for foobar
To: tu@localhost To: tu@localhost
@ -39,7 +39,7 @@ test_expect_success 'Test subject and body of reset key notifications.' '
UPDATE Users SET ResetKey = "12345678901234567890123456789012" WHERE ID = 1; UPDATE Users SET ResetKey = "12345678901234567890123456789012" WHERE ID = 1;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" send-resetkey 1 && cover "$NOTIFY" send-resetkey 1 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Password Reset Subject: AUR Password Reset
@ -62,7 +62,7 @@ test_expect_success 'Test subject and body of welcome notifications.' '
UPDATE Users SET ResetKey = "12345678901234567890123456789012" WHERE ID = 1; UPDATE Users SET ResetKey = "12345678901234567890123456789012" WHERE ID = 1;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" welcome 1 && cover "$NOTIFY" welcome 1 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: Welcome to the Arch User Repository Subject: Welcome to the Arch User Repository
@ -88,7 +88,7 @@ test_expect_success 'Test subject and body of comment notifications.' '
UPDATE Users SET CommentNotify = 1 WHERE ID = 2; UPDATE Users SET CommentNotify = 1 WHERE ID = 2;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" comment 1 1001 2001 && cover "$NOTIFY" comment 1 1001 2001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Comment for foobar Subject: AUR Comment for foobar
@ -116,7 +116,7 @@ test_expect_success 'Test subject and body of update notifications.' '
UPDATE Users SET UpdateNotify = 1 WHERE ID = 2; UPDATE Users SET UpdateNotify = 1 WHERE ID = 2;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" update 1 1001 && cover "$NOTIFY" update 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package Update: foobar Subject: AUR Package Update: foobar
@ -139,7 +139,7 @@ test_expect_success 'Test subject and body of update notifications.' '
test_expect_success 'Test subject and body of out-of-date notifications.' ' test_expect_success 'Test subject and body of out-of-date notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" flag 1 1001 && cover "$NOTIFY" flag 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Out-of-date Notification for foobar Subject: AUR Out-of-date Notification for foobar
@ -160,7 +160,7 @@ test_expect_success 'Test subject and body of out-of-date notifications.' '
test_expect_success 'Test subject and body of adopt notifications.' ' test_expect_success 'Test subject and body of adopt notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" adopt 1 1001 && cover "$NOTIFY" adopt 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Ownership Notification for foobar Subject: AUR Ownership Notification for foobar
@ -179,7 +179,7 @@ test_expect_success 'Test subject and body of adopt notifications.' '
test_expect_success 'Test subject and body of disown notifications.' ' test_expect_success 'Test subject and body of disown notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" disown 1 1001 && cover "$NOTIFY" disown 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Ownership Notification for foobar Subject: AUR Ownership Notification for foobar
@ -198,7 +198,7 @@ test_expect_success 'Test subject and body of disown notifications.' '
test_expect_success 'Test subject and body of co-maintainer addition notifications.' ' test_expect_success 'Test subject and body of co-maintainer addition notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" comaintainer-add 1 1001 && cover "$NOTIFY" comaintainer-add 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Co-Maintainer Notification for foobar Subject: AUR Co-Maintainer Notification for foobar
@ -216,7 +216,7 @@ test_expect_success 'Test subject and body of co-maintainer addition notificatio
test_expect_success 'Test subject and body of co-maintainer removal notifications.' ' test_expect_success 'Test subject and body of co-maintainer removal notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" comaintainer-remove 1 1001 && cover "$NOTIFY" comaintainer-remove 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Co-Maintainer Notification for foobar Subject: AUR Co-Maintainer Notification for foobar
@ -234,7 +234,7 @@ test_expect_success 'Test subject and body of co-maintainer removal notification
test_expect_success 'Test subject and body of delete notifications.' ' test_expect_success 'Test subject and body of delete notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" delete 1 1001 && cover "$NOTIFY" delete 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package deleted: foobar Subject: AUR Package deleted: foobar
@ -255,7 +255,7 @@ test_expect_success 'Test subject and body of delete notifications.' '
test_expect_success 'Test subject and body of merge notifications.' ' test_expect_success 'Test subject and body of merge notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" delete 1 1001 1002 && cover "$NOTIFY" delete 1 1001 1002 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package deleted: foobar Subject: AUR Package deleted: foobar
@ -283,7 +283,7 @@ test_expect_success 'Test Cc, subject and body of request open notifications.' '
INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (3001, 1001, "foobar", 2, 1, "This is a request test comment.", ""); INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (3001, 1001, "foobar", 2, 1, "This is a request test comment.", "");
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-open 1 3001 orphan 1001 && cover "$NOTIFY" request-open 1 3001 orphan 1001 &&
grep ^Cc: sendmail.out >actual && grep ^Cc: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Cc: user@localhost, tu@localhost Cc: user@localhost, tu@localhost
@ -309,7 +309,7 @@ test_expect_success 'Test Cc, subject and body of request open notifications.' '
test_expect_success 'Test subject and body of request open notifications for merge requests.' ' test_expect_success 'Test subject and body of request open notifications for merge requests.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-open 1 3001 merge 1001 foobar2 && cover "$NOTIFY" request-open 1 3001 merge 1001 foobar2 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#3001] Merge Request for foobar Subject: [PRQ#3001] Merge Request for foobar
@ -331,7 +331,7 @@ test_expect_success 'Test subject and body of request open notifications for mer
test_expect_success 'Test Cc, subject and body of request close notifications.' ' test_expect_success 'Test Cc, subject and body of request close notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 1 3001 accepted && cover "$NOTIFY" request-close 1 3001 accepted &&
grep ^Cc: sendmail.out >actual && grep ^Cc: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Cc: user@localhost, tu@localhost Cc: user@localhost, tu@localhost
@ -354,7 +354,7 @@ test_expect_success 'Test Cc, subject and body of request close notifications.'
test_expect_success 'Test subject and body of request close notifications (auto-accept).' ' test_expect_success 'Test subject and body of request close notifications (auto-accept).' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 0 3001 accepted && cover "$NOTIFY" request-close 0 3001 accepted &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#3001] Deletion Request for foobar Accepted Subject: [PRQ#3001] Deletion Request for foobar Accepted
@ -374,7 +374,7 @@ test_expect_success 'Test subject and body of request close notifications with c
UPDATE PackageRequests SET ClosureComment = "This is a test closure comment." WHERE ID = 3001; UPDATE PackageRequests SET ClosureComment = "This is a test closure comment." WHERE ID = 3001;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 1 3001 accepted && cover "$NOTIFY" request-close 1 3001 accepted &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#3001] Deletion Request for foobar Accepted Subject: [PRQ#3001] Deletion Request for foobar Accepted
@ -394,7 +394,7 @@ test_expect_success 'Test subject and body of request close notifications with c
test_expect_success 'Test subject and body of TU vote reminders.' ' test_expect_success 'Test subject and body of TU vote reminders.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" tu-vote-reminder 1 && cover "$NOTIFY" tu-vote-reminder 1 &&
grep ^Subject: sendmail.out | head -1 >actual && grep ^Subject: sendmail.out | head -1 >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: TU Vote Reminder: Proposal 1 Subject: TU Vote Reminder: Proposal 1

View file

@ -10,7 +10,7 @@ test_expect_success 'Test comment rendering.' '
INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (1, 1, "Hello world! INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (1, 1, "Hello world!
This is a comment.", ""); This is a comment.", "");
EOD EOD
"$RENDERCOMMENT" 1 && cover "$RENDERCOMMENT" 1 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<p>Hello world! <p>Hello world!
This is a comment.</p> This is a comment.</p>
@ -25,7 +25,7 @@ test_expect_success 'Test Markdown conversion.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (2, 1, "*Hello* [world](https://www.archlinux.org/)!", ""); INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (2, 1, "*Hello* [world](https://www.archlinux.org/)!", "");
EOD EOD
"$RENDERCOMMENT" 2 && cover "$RENDERCOMMENT" 2 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<p><em>Hello</em> <a href="https://www.archlinux.org/">world</a>!</p> <p><em>Hello</em> <a href="https://www.archlinux.org/">world</a>!</p>
EOD EOD
@ -39,7 +39,7 @@ test_expect_success 'Test HTML sanitizing.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (3, 1, "<script>alert(""XSS!"");</script>", ""); INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (3, 1, "<script>alert(""XSS!"");</script>", "");
EOD EOD
"$RENDERCOMMENT" 3 && cover "$RENDERCOMMENT" 3 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
&lt;script&gt;alert("XSS!");&lt;/script&gt; &lt;script&gt;alert("XSS!");&lt;/script&gt;
EOD EOD
@ -61,7 +61,7 @@ test_expect_success 'Test link conversion.' '
[arch]: https://www.archlinux.org/ [arch]: https://www.archlinux.org/
", ""); ", "");
EOD EOD
"$RENDERCOMMENT" 4 && cover "$RENDERCOMMENT" 4 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<p>Visit <a href="https://www.archlinux.org/#_test_">https://www.archlinux.org/#_test_</a>. <p>Visit <a href="https://www.archlinux.org/#_test_">https://www.archlinux.org/#_test_</a>.
Visit <em><a href="https://www.archlinux.org/">https://www.archlinux.org/</a></em>. Visit <em><a href="https://www.archlinux.org/">https://www.archlinux.org/</a></em>.
@ -89,7 +89,7 @@ test_expect_success 'Test Git commit linkification.' '
http://example.com/$oid http://example.com/$oid
", ""); ", "");
EOD EOD
"$RENDERCOMMENT" 5 && cover "$RENDERCOMMENT" 5 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<p><a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:12}">${oid:0:12}</a> <p><a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:12}">${oid:0:12}</a>
<a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:7}">${oid:0:7}</a> <a href="https://aur.archlinux.org/cgit/aur.git/log/?h=foobar&amp;id=${oid:0:7}">${oid:0:7}</a>
@ -116,7 +116,7 @@ test_expect_success 'Test Flyspray issue linkification.' '
https://archlinux.org/?test=FS#1234 https://archlinux.org/?test=FS#1234
", ""); ", "");
EOD EOD
"$RENDERCOMMENT" 6 && cover "$RENDERCOMMENT" 6 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<p><a href="https://bugs.archlinux.org/task/1234567">FS#1234567</a>. <p><a href="https://bugs.archlinux.org/task/1234567">FS#1234567</a>.
<em><a href="https://bugs.archlinux.org/task/1234">FS#1234</a></em> <em><a href="https://bugs.archlinux.org/task/1234">FS#1234</a></em>
@ -142,7 +142,7 @@ test_expect_success 'Test headings lowering.' '
###### Six ###### Six
", ""); ", "");
EOD EOD
"$RENDERCOMMENT" 7 && cover "$RENDERCOMMENT" 7 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
<h5>One</h5> <h5>One</h5>
<h6>Two</h6> <h6>Two</h6>

View file

@ -16,7 +16,7 @@ test_expect_success 'Test removal of login IP addresses.' '
UPDATE Users SET LastLogin = 0, LastLoginIPAddress = "5.6.7.8" WHERE ID = 5; UPDATE Users SET LastLogin = 0, LastLoginIPAddress = "5.6.7.8" WHERE ID = 5;
UPDATE Users SET LastLogin = $tendaysago, LastLoginIPAddress = "6.7.8.9" WHERE ID = 6; UPDATE Users SET LastLogin = $tendaysago, LastLoginIPAddress = "6.7.8.9" WHERE ID = 6;
EOD EOD
"$USERMAINT" && cover "$USERMAINT" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
1.2.3.4 1.2.3.4
3.4.5.6 3.4.5.6
@ -37,7 +37,7 @@ test_expect_success 'Test removal of SSH login IP addresses.' '
UPDATE Users SET LastSSHLogin = 0, LastSSHLoginIPAddress = "5.6.7.8" WHERE ID = 5; UPDATE Users SET LastSSHLogin = 0, LastSSHLoginIPAddress = "5.6.7.8" WHERE ID = 5;
UPDATE Users SET LastSSHLogin = $tendaysago, LastSSHLoginIPAddress = "6.7.8.9" WHERE ID = 6; UPDATE Users SET LastSSHLogin = $tendaysago, LastSSHLoginIPAddress = "6.7.8.9" WHERE ID = 6;
EOD EOD
"$USERMAINT" && cover "$USERMAINT" &&
cat <<-EOD >expected && cat <<-EOD >expected &&
1.2.3.4 1.2.3.4
2.3.4.5 2.3.4.5