Add end-to-end Test
- Add an infrastructur to run local e2e tests. - Add some tests.
This commit is contained in:
@@ -57,27 +57,6 @@ RUN apt-get update -yqq && \
|
|||||||
openssl \
|
openssl \
|
||||||
sq
|
sq
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" user && \
|
|
||||||
mkdir -p /home/user/ && \
|
|
||||||
usermod -a -G sudo user && \
|
|
||||||
chown -R user:user /home/user
|
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" alice && \
|
|
||||||
mkdir -p /home/alice/ && \
|
|
||||||
chown -R alice:alice /home/alice
|
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" bob && \
|
|
||||||
mkdir -p /home/bob/ && \
|
|
||||||
chown -R bob:bob /home/bob
|
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" carol && \
|
|
||||||
mkdir -p /home/carol/ && \
|
|
||||||
chown -R carol:carol /home/carol
|
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" dave && \
|
|
||||||
mkdir -p /home/dave/ && \
|
|
||||||
chown -R dave:dave /home/dave
|
|
||||||
|
|
||||||
RUN adduser --shell /bin/bash --disabled-password --gecos "" hockeypuck
|
RUN adduser --shell /bin/bash --disabled-password --gecos "" hockeypuck
|
||||||
|
|
||||||
COPY mta_provision/ /
|
COPY mta_provision/ /
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ The mapped binary will be started, alongside `postfix` and `hockeypuck`.
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ docker run -ti --rm \
|
$ docker run -ti --rm \
|
||||||
--mount type=bind,src=$(pwd)/target/release,dst=/opt/husk/mapped/
|
--mount type=bind,src=$(pwd),dst=/opt/husk/mapped/
|
||||||
localhost/mta bash -c "/usr/bin/prepare.sh && bash -i"
|
localhost/mta bash -c "/usr/bin/prepare.sh && bash -i"
|
||||||
```
|
```
|
||||||
@@ -7,8 +7,8 @@ echo "127.0.0.1 " $(hostname) > /etc/hosts
|
|||||||
echo "127.0.0.2 example.com" >> /etc/hosts
|
echo "127.0.0.2 example.com" >> /etc/hosts
|
||||||
|
|
||||||
## build milter
|
## build milter
|
||||||
if [ -f /opt/husk/mapped/husk ] ; then
|
if [ -f /opt/husk/mapped/Cargo.toml ] ; then
|
||||||
HUSK_BIN=/opt/husk/mapped/husk
|
HUSK_BIN=/opt/husk/mapped/target/release/husk
|
||||||
else
|
else
|
||||||
cd /opt/husk
|
cd /opt/husk
|
||||||
git clone https://gitlab.com/husk-project/husk-milter.git
|
git clone https://gitlab.com/husk-project/husk-milter.git
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
docker run -ti \
|
||||||
|
--rm \
|
||||||
|
--mount type=bind,src=$(pwd),dst=/opt/husk/mapped/ \
|
||||||
|
localhost/mta \
|
||||||
|
bash -c "/usr/bin/prepare.sh && bash /opt/husk/mapped/e2e-tests/runner.sh"
|
||||||
|
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
for TEST in ./tests/* ; do
|
||||||
|
if bash $TEST ; then
|
||||||
|
echo "success"
|
||||||
|
else
|
||||||
|
echo "failure"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
echo "Basic: Test if MTA is working"
|
||||||
|
|
||||||
|
adduser --shell /bin/bash --disabled-password --gecos "" mtatest
|
||||||
|
echo "test mail" | sendmail mtatest@example.com
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if [ -f /var/mail/mtatest ] ; then
|
||||||
|
RESULT_CODE=0
|
||||||
|
else
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
deluser --remove-home mtatest
|
||||||
|
|
||||||
|
exit $RESULT_CODE
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
echo "Simple: Test encryption for available certificate"
|
||||||
|
|
||||||
|
# There is an authenticated certificate for bob in the cert store
|
||||||
|
adduser --shell /bin/bash --disabled-password --gecos "" bob
|
||||||
|
echo "test mail" | sendmail bob@example.com
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if [ -f /var/mail/bob ] ; then
|
||||||
|
if grep -q "BEGIN PGP MESSAGE" /var/mail/bob ; then
|
||||||
|
RESULT_CODE=0
|
||||||
|
else
|
||||||
|
echo "no encryption detected"
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "no mail detected"
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
deluser --remove-home bob
|
||||||
|
|
||||||
|
exit $RESULT_CODE
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
echo "Simple: Test encryption for unavailable certificate"
|
||||||
|
|
||||||
|
# There is no authenticated certificate for alice in the cert store
|
||||||
|
adduser --shell /bin/bash --disabled-password --gecos "" alice
|
||||||
|
echo "test mail" | sendmail alice@example.com
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if [ -f /var/mail/alice ] ; then
|
||||||
|
if grep -q "BEGIN PGP MESSAGE" /var/mail/alice ; then
|
||||||
|
echo "encryption detected - that is wrong"
|
||||||
|
RESULT_CODE=1
|
||||||
|
else
|
||||||
|
RESULT_CODE=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "no mail detected"
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
deluser --remove-home alice
|
||||||
|
|
||||||
|
exit $RESULT_CODE
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
echo "Test encryption for certificate an a keyserver"
|
||||||
|
|
||||||
|
# There is a certificate for carol on the keyserver
|
||||||
|
# it's certified by an introducer
|
||||||
|
adduser --shell /bin/bash --disabled-password --gecos "" carol
|
||||||
|
echo "test mail" | sendmail carol@example.com
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if [ -f /var/mail/carol ] ; then
|
||||||
|
if grep -q "BEGIN PGP MESSAGE" /var/mail/carol ; then
|
||||||
|
RESULT_CODE=0
|
||||||
|
else
|
||||||
|
echo "no encryption detected"
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "no mail detected"
|
||||||
|
RESULT_CODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
deluser --remove-home carol
|
||||||
|
|
||||||
|
exit $RESULT_CODE
|
||||||
Reference in New Issue
Block a user