1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Readability cleanup

This patch makes a few small changes to the tests for readability, such
as changing the arguments to the add_user function.
This commit is contained in:
Alberto Bertogli
2016-10-17 07:41:12 +01:00
parent f38ae47164
commit 6f048027a7
10 changed files with 41 additions and 40 deletions

View File

@@ -6,7 +6,7 @@ They're not expected to be portable, as that gets impractical very quickly.
They also have some dependencies, listed below.
=== Dependencies
## Dependencies
The tests depend on the following things being installed on the system (listed
as Debian package, for consistency):
@@ -15,9 +15,11 @@ as Debian package, for consistency):
- msmtp
- util-linux (for /usr/bin/setsid)
For t-exim (Exim interaction tests):
For t-02-exim (Exim interaction tests):
- gettext-base (for /usr/bin/envsubst)
- The exim binary available somewhere, but it doesn't have to be installed.
There's a script "get-exim4-debian.sh" to get it from the archives.
For some tests, python >= 3.5 is required; they will be skipped if it's not
available.

View File

@@ -6,8 +6,8 @@ set -e
init
generate_certs_for testserver
add_user testserver user secretpassword
add_user testserver someone secretpassword
add_user user@testserver secretpassword
add_user someone@testserver secretpassword
mkdir -p .logs
chasquid -v=2 --log_dir=.logs --config_dir=config &
@@ -22,23 +22,19 @@ mail_diff content .mail/someone@testserver
# At least for now, we allow AUTH over the SMTP port to avoid unnecessary
# complexity, so we expect it to work.
if ! run_msmtp -a smtpport someone@testserver < content 2> /dev/null; then
echo "ERROR: failed auth on the SMTP port"
exit 1
fail "failed auth on the SMTP port"
fi
if run_msmtp nobody@testserver < content 2> /dev/null; then
echo "ERROR: successfuly sent an email to a non-existent user"
exit 1
fail "successfuly sent an email to a non-existent user"
fi
if run_msmtp -a baduser someone@testserver < content 2> /dev/null; then
echo "ERROR: successfully sent an email with a bad password"
exit 1
fail "successfully sent an email with a bad password"
fi
if run_msmtp -a badpasswd someone@testserver < content 2> /dev/null; then
echo "ERROR: successfully sent an email with a bad password"
exit 1
fail "successfully sent an email with a bad password"
fi
success

View File

@@ -28,7 +28,7 @@ set -e
init
if ! .exim4/exim4 --version > /dev/null; then
skip "(exim4 binary at .exim4/exim4 is not functional)"
skip "exim4 binary at .exim4/exim4 is not functional"
exit 0
fi
@@ -38,8 +38,8 @@ mkdir -p .exim4
EXIMDIR="$PWD/.exim4" envsubst < config/exim4.in > .exim4/config
generate_certs_for srv-chasquid
add_user srv-chasquid user secretpassword
add_user srv-chasquid someone secretpassword
add_user user@srv-chasquid secretpassword
add_user someone@srv-chasquid secretpassword
# Launch chasquid at port 1025 (in config).
# Use outgoing port 2025 which is where exim will be at.

View File

@@ -6,7 +6,7 @@ set -e
init
generate_certs_for testserver
add_user testserver user secretpassword
add_user user@testserver secretpassword
mkdir -p .logs
chasquid -v=2 --log_dir=.logs --config_dir=config &

View File

@@ -6,7 +6,7 @@ set -e
init
generate_certs_for testserver
add_user testserver user secretpassword
add_user user@testserver secretpassword
mkdir -p .logs
chasquid -v=2 --log_dir=.logs --config_dir=config &

View File

@@ -14,12 +14,12 @@ skip_if_python_is_too_old
# B - listens on :2015, hosts srv-ü
CONFDIR=A generate_certs_for srv-ñ
CONFDIR=A add_user srv-ñ ñangapirí antaño
CONFDIR=A add_user nadaA nadaA nadaA
CONFDIR=A add_user ñangapirí@srv-ñ antaño
CONFDIR=A add_user nadaA@nadaA nadaA
CONFDIR=B generate_certs_for srv-ü
CONFDIR=B add_user srv-ü pingüino velóz
CONFDIR=B add_user nadaB nadaB nadaB
CONFDIR=B add_user pingüino@srv-ü velóz
CONFDIR=B add_user nadaB@nadaB nadaB
mkdir -p .logs-A .logs-B

View File

@@ -15,10 +15,10 @@ generate_certs_for ñoños
# Intentionally have a config directory for upper case; this should be
# normalized to lowercase internally (and match the cert accordingly).
add_user ñoñOS ñangapirí antaño
add_user ñangapirí@ñoñOS antaño
# Python doesn't support UTF8 for auth, use an ascii user and domain.
add_user nada nada nada
add_user nada@nada nada
mkdir -p .logs
chasquid -v=2 --log_dir=.logs --config_dir=config &

View File

@@ -15,7 +15,7 @@ rm -rf .data-A .data-B .mail
# userA -> aliasB -> aliasA -> aliasB -> ...
CONFDIR=A generate_certs_for srv-A
CONFDIR=A add_user srv-A userA userA
CONFDIR=A add_user userA@srv-A userA
CONFDIR=B generate_certs_for srv-B

View File

@@ -6,9 +6,9 @@ set -e
init
generate_certs_for testserver
add_user testserver user secretpassword
add_user testserver someone secretpassword
add_user testserver blockme secretpassword
add_user user@testserver secretpassword
add_user someone@testserver secretpassword
add_user blockme@testserver secretpassword
mkdir -p .logs
chasquid -v=2 --log_dir=.logs --config_dir=config &
@@ -23,14 +23,12 @@ wait_for_file .mail/someone@testserver
mail_diff content .mail/someone@testserver
if ! grep -q "X-Post-Data: success" .mail/someone@testserver; then
echo "missing X-Post-Data header"
exit 1
fail "missing X-Post-Data header"
fi
function check() {
if ! grep -q "$1" .data/post-data.out; then
echo missing: $1
exit 1
fail "missing: $1"
fi
}
@@ -48,8 +46,7 @@ check "REMOTE_ADDR="
# Check that a failure in the script results in failing delivery.
if run_msmtp blockme@testserver < content 2>/dev/null; then
echo "ERROR: hook did not block email as expected"
exit 1
fail "ERROR: hook did not block email as expected"
fi
# Check that the bad hooks don't prevent delivery.

View File

@@ -40,11 +40,12 @@ function chasquid() {
function add_user() {
CONFDIR="${CONFDIR:-config}"
mkdir -p "${CONFDIR}/domains/${1}/"
DOMAIN=$(echo $1 | cut -d @ -f 2)
mkdir -p "${CONFDIR}/domains/$DOMAIN/"
go run ${TBASE}/../../cmd/chasquid-util/chasquid-util.go \
-C "${CONFDIR}" \
user-add "$2@$1" \
--password "${3}" \
user-add "$1" \
--password "$2" \
>> .add_user_logs
}
@@ -65,11 +66,17 @@ function mail_diff() {
}
function success() {
echo "SUCCESS"
echo success
}
function skip() {
echo "SKIPPED" $*
echo skipped: $*
exit 0
}
function fail() {
echo FAILED: $*
exit 1
}
# Wait until there's something listening on the given port.
@@ -103,8 +110,7 @@ function generate_certs_for() {
function skip_if_python_is_too_old() {
# We need Python >= 3.5 to be able to use SMTPUTF8.
check='import sys; sys.exit(0 if sys.version_info >= (3, 5) else 1)'
if ! python3 -c "${check}"; then
if ! python3 -c "${check}" > /dev/null 2>&1; then
skip "python3 >= 3.5 not available"
exit 0
fi
}