First set of tests

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
This commit is contained in:
Petr "Stone" Hracek 2017-04-25 13:37:11 +02:00
commit 8c2330e38f
22 changed files with 5095 additions and 12 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.idea
*.py[oc]

35
Dockerfile Normal file
View file

@ -0,0 +1,35 @@
FROM registry.fedoraproject.org/fedora:26
ENV POSTFIX_SMTP_PORT=10025 NAME=postfix ARCH=x86_64
LABEL MAINTAINER "Petr Hracek" <phracek@redhat.com>
LABEL summary="Postfix is a Mail Transport Agent (MTA)." \
name="$FGC/$NAME" \
version="0" \
release="1.$DISTTAG" \
architecture="$ARCH" \
com.redhat.component="$NAME" \
usage="docker run -it -e MYHOSTNAME=localhost -p 25:10025 -v $(pwd)/tmp/postfix:/var/spool/postfix -v $(pwd)/tmp/mail:/var/spool/mail postfix" \
help="Runs postfix, which listens on port 25. No dependencies. See Help File belowe for more detailes." \
description="Postfix is mail transfer agent that routes and delivers mail." \
io.k8s.description="Postfix is mail transfer agent that routes and delivers mail." \
io.k8s.diplay-name="Postfix 3.1" \
io.openshift.expose-services="10025:postfix" \
io.openshift.tags="postfix,mail,mta"
RUN dnf install -y --setopt=tsflags=nodocs postfix findutils && \
dnf -y clean all
ADD files /files
ADD README.md /
RUN /files/postfix_config.sh
EXPOSE 10025
# Postfix UID based from Fedora
# USER 89
VOLUME ['/var/spool/postfix']
VOLUME ['/var/spool/mail']
CMD ["/files/start.sh"]

17
Makefile Normal file
View file

@ -0,0 +1,17 @@
.PHONY: build run default
IMAGE_NAME = postfix
MODULEMDURL=file://postfix.yaml
all: run
default: run
build:
docker build --tag=$(IMAGE_NAME) .
run: build
docker run -p 25:10025 -e MYHOSTNAME=localhost $(IMAGE_NAME)
test: build
cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all
cd tests; MODULE=rpm MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all

136
README.md
View file

@ -1,15 +1,127 @@
# postfix
Postfix mail server container.
build-dependencies generated by brt_dep_solver.sh
--------------------------------------------------
* mariadb
* perl-generators
* postgresql
* tinycdb
## Summary
runtime-dependencies generated by brt_dep_solver.sh
-------------------------------------------------
* mariadb
* perl-generators
* postgresql
* tinycdb
- Dockerfile.DOVECOT - build container image with dovecot w/o postfix.
- Dockerfile.POSTFIX - build container image with postfix w/o dovecot.
- Dockerfile.IMAP - build container image with dovecot and postfix installed. Full IMAP server.
- Dockerfile.TLS - build container image with postfix TLS enabled w/o dovecot.
- imap-template.yml - Template for OpenShift to start IMAP server with two containers (postfix and dovecot)
## How to build the container on 25 port
```docker build --tag=postfix .```
## How to build the container with TLS enabled
```docker build -f Docker.TLS --tag=postfix . ```
## How to build the container with dovecot service
```docker build -f Docker.IMAP --tag=postfix .```
## How to use the container over standard 25 port
Command for running postfix docker container:
```
docker run -it -e MYHOSTNAME=localhost \
-p 25:10025\
-v $(pwd)/tmp/postfix:/var/spool/postfix \
-v $(pwd)/tmp/mail:/var/spool/mail postfix
```
## How to use the container over standard TLS
Dockerfile for TLS port is Dockerfile.TLS.
Command for running postfix docker container:
```
docker run -it -e DEBUG_MODE=yes -e MYHOSTNAME=localhost \
-p 25:10025 \
postfix
```
Environment variable DEBUG_MODE is used for debugging proposes
from Postfix and dovecot point of views.
## How to use the container with IMAP with TLS enabled (dovecot and Postfix)
Dockerfile which uses IMAP is Dockerfile.IMAP.
Command for running postfix docker container:
```
docker run -it -e MYHOSTNAME=localhost -e DEBUG_MODE \
-p 25:10025 -p 587:10587 -p 143:10143 \
postfix
```
Environment variable DEBUG_MODE is used for debugging proposes
from Postfix and dovecot point of views.
Docker container does NOT share user from HOST system. Therefore
I prefer to create users in container. This is not yet automated. Will be SOON.
Steps are:
```docker exec -n postfix /bin/bash```
```/file/create_user.sh <user_name>```
Now the user can be used for mail clients.
## How to test the postfix mail server
Commands for testing Postfix docker container:
```telnet localhost 25```
```HELO test.localhost```
```MAIL FROM:<yourname>@<domain.com>```
```RCPT TO:<demo@localhost>```
```DATA``` and type whatever you want
```
Subject: My testing docker container image
Hi, Testing message
regards
Docker
.
```
## How to test the postfix mail server with TLS
Command for testing Postfix docker container with
enabled TLS is ```openssl```.
Telnet has not to be used because of all
communication is encrypted from the beginning.
```
openssl s_client -starttls smtp -crlf -connect localhost:25
```
## How to test the postfix with dovecot service
Command for testing Postfix docker container with
dovecot is ```openssl```.
Telnet has not to be used because of all
communication is encrypted from the beginning.
Testing dovecot service with ```openssl```
```
openssl s_client -starttls imap -connect localhost:143
```
Testing postfix service with ```openssl```
```
openssl s_client -debug -starttls smtp -crlf -connect localhost:25
```

4287
files/ca-bundle.crt Normal file

File diff suppressed because it is too large Load diff

53
files/common.sh Normal file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
SERVICES="/etc/services"
MASTER="/etc/postfix/master.cf"
function modify_master_cf(){
echo "Changing postfix $MASTER configuration file."
MASTER="/etc/postfix/master.cf"
grep 'docker_smtp' "$MASTER"
if [[ $? -eq 1 ]]; then
sed -i 's/^smtp\(\s*\)inet\(.*\)/docker_smtp\1inet\tn\ty\tn\t-\t-\tsmtpd -v/g' "$MASTER"
fi
}
function modify_etc_services() {
SERVICES="/etc/services"
echo "Changing $SERVICES file."
grep -n '$POSTFIX_SMTP_PORT/tcp' "$SERVICES"
if [[ $? -eq 1 ]]; then
echo "Add docker_smtp port into $SERVICES."
echo "docker_smtp $POSTFIX_SMTP_PORT/tcp mail" >> "$SERVICES"
echo "docker_smtp $POSTFIX_SMTP_PORT/udp mail" >> "$SERVICES"
else
echo "docker_smtp port already exists in $SERVICES file."
fi
grep -n '$POSTFIX_IMAP_PORT/tcp' "$SERVICES"
if [[ $? -eq 1 ]]; then
echo "Add docker_imap port into $SERVICES."
echo "docker_imap $POSTFIX_IMAP_PORT/tcp imap2" >> "$SERVICES"
echo "docker_imap $POSTFIX_IMAP_PORT/udp imap2" >> "$SERVICES"
else
echo "docker_imap port already exists in $SERVICES file."
fi
grep -n '$POSTFIX_SUBM_PORT/tcp' "$SERVICES"
if [[ $? -eq 1 ]]; then
echo "Add docker_imap port into $SERVICES."
echo "docker_submission $POSTFIX_SUBM_PORT/tcp msa" >> "$SERVICES"
echo "docker_submission $POSTFIX_SUBM_PORT/udp msa" >> "$SERVICES"
else
echo "docker_submission port already exists in $SERVICES file."
fi
}
update_dovecot_conf() {
option=$1
value=$2
file_name="/etc/dovecot/dovecot.conf"
doveconf -n | grep "^$option"
if [[ $? -eq 1 ]]; then
echo "$option = $value" >> $file_name
fi
}

10
files/create_user.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
grep $1 /etc/passwd
if [[ $? -ne 0 ]]; then
useradd $1 && usermod -a -G mail $1 && passwd $1
echo "$1: postmaster" >> /etc/aliases
newaliases
postmap /etc/aliases
postfix reload
fi

48
files/dovecot_config.sh Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
DOVECOT_CONF="/etc/dovecot/dovecot.conf"
VIRTUAL="/var/mail"
function modify_main_cf() {
# Configuration changes needed in main.cf
echo "Changing postfix the /etc/postfix/main.cf configuration file."
postconf -e inet_interfaces=all
postconf -e smtpd_tls_auth_only=yes
postconf -e smtpd_tls_CAfile=/etc/postfix/ca-bundle.crt
postconf -e smtpd_tls_key_file=/etc/postfix/test.pem
postconf -e smtpd_tls_cert_file=/etc/postfix/test.pem
postconf -e smtpd_tls_loglevel=3
postconf -e smtpd_tls_received_header=yes
postconf -e smtpd_tls_session_cache_timeout=3600s
postconf -e smtpd_tls_security_level=may
postconf -e smtpd_sasl_type=dovecot
postconf -e smtpd_sasl_path=private/auth
postconf -e smtpd_sasl_auth_enable=yes
postconf -e broken_sasl_auth_clients=yes
postconf -e smtpd_sasl_security_options=noanonymous
postconf -e myorigin=${MYHOSTNAME}
postconf -e mydomain=${MYHOSTNAME}
postconf -e myhostname=mail.${MYHOSTNAME}
postconf -e mydestination=${MYHOSTNAME}
postconf -e debug_peer_level=3
postconf -e debug_peer_list=${MYHOSTNAME}
}
if [[ -f "/var/run/nologin" ]]; then
rm -f /var/run/nologin
fi
if [[ -z ${MYHOSTNAME} ]]; then
MYHOSTNAME=localhost
fi
source /files/common.sh
mkdir -p /var/certs
chown root:root /var/certs
cp /files/*.{crt,pem} /etc/postfix/
modify_etc_services
modify_main_cf
modify_master_cf

15
files/dovecot_imap.conf Normal file
View file

@ -0,0 +1,15 @@
service imap-login {
process_min_avail = 16
inet_listener imap {
port = 10143
}
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user=postfix
}
}

96
files/imap_config.sh Executable file
View file

@ -0,0 +1,96 @@
#!/usr/bin/env bash
DOVECOT_CONF="/etc/dovecot/dovecot.conf"
VIRTUAL="/var/mail"
function modify_main_cf() {
# Configuration changes needed in main.cf
echo "Changing postfix the /etc/postfix/main.cf configuration file."
postconf -e inet_interfaces=all
postconf -e smtpd_tls_auth_only=yes
postconf -e smtpd_tls_CAfile=/etc/postfix/ca-bundle.crt
postconf -e smtpd_tls_key_file=/etc/postfix/test.pem
postconf -e smtpd_tls_cert_file=/etc/postfix/test.pem
postconf -e smtpd_tls_loglevel=3
postconf -e smtpd_tls_received_header=yes
postconf -e smtpd_tls_session_cache_timeout=3600s
postconf -e smtpd_tls_security_level=may
postconf -e smtpd_sasl_type=dovecot
postconf -e smtpd_sasl_path=private/auth
postconf -e smtpd_sasl_auth_enable=yes
postconf -e broken_sasl_auth_clients=yes
postconf -e smtpd_sasl_security_options=noanonymous
postconf -e myorigin=${MYHOSTNAME}
postconf -e mydomain=${MYHOSTNAME}
postconf -e myhostname=mail.${MYHOSTNAME}
postconf -e mydestination=${MYHOSTNAME}
postconf -e debug_peer_level=3
postconf -e debug_peer_list=${MYHOSTNAME}
}
function modify_dovecot_conf() {
update_dovecot_conf "mail_location" "mbox:~/mail:INBOX=/var/mail/%u"
update_dovecot_conf "disable_plaintext_auth" "no"
update_dovecot_conf "auth_mechanisms" "plain login"
update_dovecot_conf "mail_privileged_group" "mail"
update_dovecot_conf "auth_debug" "yes"
update_dovecot_conf "auth_verbose" "yes"
update_dovecot_conf "mail_debug" "yes"
update_dovecot_conf "debug_log_path" "/var/dovecot/dovecot-debug.log"
update_dovecot_conf "info_log_path" "/var/dovecot/dovecot-info.log"
update_dovecot_conf "log_path" "/var/dovecot/dovecot.log"
update_dovecot_conf "protocols" "imap"
doveconf -n | grep "ssl"
if [[ $? -eq 1 ]]; then
echo "ssl = yes" >> /etc/dovecot/conf.d/10-ssl.conf
else
sed -i 's/^ssl\(\s*\)=\(\s*\).*/ssl\1=\2yes/g' /etc/dovecot/conf.d/10-ssl.conf
fi
doveconf -n | grep "service imap-login"
if [[ $? -eq 1 ]]; then
cat /files/dovecot_imap.conf >> /etc/dovecot/conf.d/10-master.conf
fi
echo "docker_submission inet n y n - - smtpd -v
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_tls_wrappermode=no
-o smtpd_sasl_type=dovecot
-o smtpd_sasl_path=private/auth
-o smtpd_sasl_local_domain=localhost" >> /etc/postfix/master.cf
}
if [[ -f "/var/run/nologin" ]]; then
rm -f /var/run/nologin
fi
DOVECOT_PKI="/etc/pki/dovecot"
if [[ ! -f "$DOVECOT_PKI/private/dovecot.pem" ]]; then
SSLDIR=$DOVECOT_PKI OPENSSLCONFIG="$DOVECOT_PKI/dovecot-openssl.cnf" \
/usr/libexec/dovecot/mkcert.sh /dev/null 2>&1
fi
if [[ ! -f "/var/lib/dovecot/ssl-parametrs.dat" ]]; then
/usr/libexec/dovecot/ssl-params >/dev/null 2>&1
fi
if [[ -z ${MYHOSTNAME} ]]; then
MYHOSTNAME=localhost
fi
source /files/common.sh
mkdir -p /var/certs
chown root:root /var/certs
mkdir -p /var/dovecot
chown root:root /var/dovecot
cp /files/*.{crt,pem} /etc/postfix/
modify_etc_services
modify_main_cf
modify_master_cf
modify_dovecot_conf
dovecot -n

27
files/postfix_config.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
function modify_main_cf() {
# Configuration changes needed in main.cf
echo "Changing postfix configuration"
postconf -e inet_interfaces=all
postconf -e myorigin=/etc/mailname
postconf -e mynetworks='127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8'
postconf -e smtpd_relay_restrictions='permit_mynetworks permit_sasl_authenticated defer_unauth_destination'
postconf -e mydomain=${MYHOSTNAME}
postconf -e myhostname=mail.${MYHOSTNAME}
postconf -e mydestination=${MYHOSTNAME}
}
if [[ -z ${MYHOSTNAME} ]]; then
MYHOSTNAME=localhost
fi
source /files/common.sh
modify_etc_services
modify_main_cf
modify_master_cf

48
files/postfix_config_imap.sh Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
DOVECOT_CONF="/etc/dovecot/dovecot.conf"
VIRTUAL="/var/mail"
function modify_main_cf() {
# Configuration changes needed in main.cf
echo "Changing postfix the /etc/postfix/main.cf configuration file."
postconf -e inet_interfaces=all
postconf -e smtpd_tls_auth_only=yes
postconf -e smtpd_tls_CAfile=/etc/postfix/ca-bundle.crt
postconf -e smtpd_tls_key_file=/etc/postfix/test.pem
postconf -e smtpd_tls_cert_file=/etc/postfix/test.pem
postconf -e smtpd_tls_loglevel=3
postconf -e smtpd_tls_received_header=yes
postconf -e smtpd_tls_session_cache_timeout=3600s
postconf -e smtpd_tls_security_level=may
postconf -e smtpd_sasl_type=dovecot
postconf -e smtpd_sasl_path=private/auth
postconf -e smtpd_sasl_auth_enable=yes
postconf -e broken_sasl_auth_clients=yes
postconf -e smtpd_sasl_security_options=noanonymous
postconf -e myorigin=${MYHOSTNAME}
postconf -e mydomain=${MYHOSTNAME}
postconf -e myhostname=mail.${MYHOSTNAME}
postconf -e mydestination=${MYHOSTNAME}
postconf -e debug_peer_level=3
postconf -e debug_peer_list=${MYHOSTNAME}
}
if [[ -f "/var/run/nologin" ]]; then
rm -f /var/run/nologin
fi
if [[ -z ${MYHOSTNAME} ]]; then
MYHOSTNAME=localhost
fi
source /files/common.sh
mkdir -p /var/certs
chown root:root /var/certs
cp /files/*.{crt,pem} /etc/postfix/
modify_etc_services
modify_main_cf
modify_master_cf

36
files/postfix_config_tls.sh Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
function modify_main_cf() {
# Configuration changes needed in main.cf
echo "Changing postfix the /etc/postfix/main.cf configuration file."
postconf -e inet_interfaces=all
postconf -e smtpd_use_tls=yes
postconf -e smtpd_tls_auth_only=no
postconf -e myorigin=/etc/mailname
postconf -e mydomain=${MYHOSTNAME}
postconf -e myhostname="mail.$MYHOSTNAME"
postconf -e mydestination=${MYHOSTNAME}
postconf -e smtpd_tls_CAfile=/etc/postfix/cacert.pem
postconf -e smtpd_tls_key_file=/etc/postfix/test.pem
postconf -e smtpd_tls_cert_file=/etc/postfix/test.pem
postconf -e smtpd_tls_loglevel=3
postconf -e smtpd_tls_received_header=yes
postconf -e smtpd_tls_session_cache_timeout=3600s
postconf -e smtpd_tls_security_level=may
postconf -e tls_random_source=dev:/dev/urandom
postconf -e smtpd_relay_restrictions='permit_mynetworks permit_tls_clientcerts reject_unauth_destination'
}
if [[ -z ${MYHOSTNAME} ]]; then
MYHOSTNAME=localhost
fi
source /files/common.sh
mkdir -p /var/certs
chown root:root /var/certs
modify_etc_services
modify_main_cf
modify_master_cf

22
files/start.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
# Wait before postfix is really started.
postfix start
while true; do
state=$(script -c 'postfix status' | grep postfix/postfix-script)
echo $state
if [[ "$state" != "${state/is running/}" ]]; then
PID=${state//[^0-9]/}
if [[ -z $PID ]]; then
continue
fi
if [[ ! -d "/proc/$PID" ]]; then
echo "Postfix proces $PID does not exist."
break
fi
else
echo "Postfix is not running."
break
fi
done

39
files/start_dovecot.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# Copy all certificates
#cp /var/certs/*.{crt,pem} /etc/postfix/
# Wait before postfix is really started.
if [[ ! -z "${DEBUG_MODE}" ]]; then
rpm -q syslog-ng
if [[ $? -ne 0 ]]; then
dnf -y --setopt=tsflags=nodocs install syslog-ng && \
dnf -y clean all
syslog-ng
fi
fi
postfix start
dovecot
while true; do
state=$(script -c 'postfix status' | grep postfix/postfix-script)
echo $state
dovecot_pid=$(cat /var/run/dovecot/master.pid)
echo $dovecot_pid
if [[ "$state" != "${state/is running/}" ]]; then
PID=${state//[^0-9]/}
if [[ -z $PID ]]; then
continue
fi
if [[ ! -d "/proc/$PID" ]]; then
echo "Postfix proces $PID does not exist."
break
fi
sleep 10
else
echo "Postfix is not running."
break
fi
done

39
files/start_imap.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# Copy all certificates
#cp /var/certs/*.{crt,pem} /etc/postfix/
# Wait before postfix is really started.
if [[ ! -z "${DEBUG_MODE}" ]]; then
rpm -q syslog-ng
if [[ $? -ne 0 ]]; then
dnf -y --setopt=tsflags=nodocs install syslog-ng && \
dnf -y clean all
syslog-ng
fi
fi
postfix start
dovecot
while true; do
state=$(script -c 'postfix status' | grep postfix/postfix-script)
echo $state
dovecot_pid=$(cat /var/run/dovecot/master.pid)
echo $dovecot_pid
if [[ "$state" != "${state/is running/}" ]]; then
PID=${state//[^0-9]/}
if [[ -z $PID ]]; then
continue
fi
if [[ ! -d "/proc/$PID" ]]; then
echo "Postfix proces $PID does not exist."
break
fi
sleep 10
else
echo "Postfix is not running."
break
fi
done

35
files/start_postfix.sh Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
# Copy all certificates
#cp /var/certs/*.{crt,pem} /etc/postfix/
# Wait before postfix is really started.
if [[ ! -z "${DEBUG_MODE}" ]]; then
rpm -q syslog-ng
if [[ $? -ne 0 ]]; then
dnf -y --setopt=tsflags=nodocs install syslog-ng && \
dnf -y clean all
syslog-ng
fi
fi
postfix start
while true; do
state=$(script -c 'postfix status' | grep postfix/postfix-script)
echo $state
if [[ "$state" != "${state/is running/}" ]]; then
PID=${state//[^0-9]/}
if [[ -z $PID ]]; then
continue
fi
if [[ ! -d "/proc/$PID" ]]; then
echo "Postfix proces $PID does not exist."
break
fi
sleep 10
else
echo "Postfix is not running."
break
fi
done

25
files/start_tls.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
# Copy all certificates
#cp /var/certs/*.{crt,pem} /etc/postfix/
# Wait before postfix is really started.
postfix start
while true; do
state=$(script -c 'postfix status' | grep postfix/postfix-script)
echo $state
if [[ "$state" != "${state/is running/}" ]]; then
PID=${state//[^0-9]/}
if [[ -z $PID ]]; then
continue
fi
if [[ ! -d "/proc/$PID" ]]; then
echo "Postfix proces $PID does not exist."
break
fi
else
echo "Postfix is not running."
break
fi
done

53
files/test.pem Normal file
View file

@ -0,0 +1,53 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDAPcnLcD0wzswe
S+mf+uBiBM5AcZwbYbBsYTLR6rF9p7dT5fAqcjM6mX29JACK797vOo1SPJG6pP4M
wqRXVSwKbwglbGO20q6Nc5sPKQE2PpZz7uxoB2D6UqsFYftGmceeJLGk/r11fL/m
G+sMHlwLNCFFDuZnlU23vrUfi8zEsqQJxny0hhQ1qEzDY6vwzaPMnd+ueC/a8zA9
TljrHIqfXjfd+94W/MvFNlNsAc00sLWi2izIqM8E5Gv0bP32sZkgVayNLartRdvt
1EckqfUjwYL5a7mWgbB15JZTQWC0fesUHs5ayTY0ZuOD1N6lWStD5TtLQKRRzBEd
9SV35+ZRAgMBAAECggEAXU8gXXBzIvedN69dDFu3AZyXh8wdG2VFPrXG9wDVecoo
P77B3bhkiTLrRxzsboOTT8a5xYrEqTVgYk0ve3xJzh6qc4+yrpCATQQp5SfgALZM
TKVRdgTu21G41PoD/vaxX18sIovK5fXRJx2x7sXlo0KAS4a56tkbSe5094ThtS6v
nUGFalBXJxojJpk61WESv1yPAKoSVqv+mDNY15It2tznNTs2Q9bJv3FwYtKALA7O
okUZKsWtBgWBW/ZbduDbqkWhlU/dYNb3Gq45mauGBW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29aMLwRHItOSu7Idtul5KWDOJS+lWGd5
u7/YoxAsqw3ZfJdT9BT211J0NwQqwsWssnWgptZ5Nb8adPINLZiUU+Avq6OjtZ8O
pky0kePX1jdUcIn+A5dmjutJ1QMw5uqQjVi6ESy+fUSmwgVvAfGHJaB2h1JQbJ8Z
x/daeksGzxpwqk/Ir1kVaQuMNMH5zToF/RLJZR8uUBFSNm4yP1pHxnaLht3rrthJ
pw==
-----END CERTIFICATE-----

6
tests/Makefile Normal file
View file

@ -0,0 +1,6 @@
MODULE_LINT=/usr/share/moduleframework/tools/modulelint.py
CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py
#
all:
$(CMD)

21
tests/config.yaml Normal file
View file

@ -0,0 +1,21 @@
document: modularity-testing
version: 1
name: postfix
modulemd-url: http://raw.githubusercontent.com/container-images/postfix/master/postfix.yaml
service:
port: 25
packages:
rpms:
- postfix
testdependecies:
rpms:
- nc
module:
docker:
start: "docker run -e MYHOSTNAME=localhost -p 25:10025"
source: https://github.com/container-images/postfix.git
container: docker.io/modularitycontainers/postfix
rpm:
start: systemctl start postfix
stop: systemctl stop postfix
status: systemctl status postfix

58
tests/sanity1.py Normal file
View file

@ -0,0 +1,58 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# This Modularity Testing Framework helps you to write tests for modules
# Copyright (C) 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Authors: Jan Scotka <jscotka@redhat.com>
#
import socket
from avocado import main
from avocado.core import exceptions
from moduleframework import module_framework
class SanityCheck1(module_framework.AvocadoTest):
"""
:avocado: enable
"""
def testConnectToPostfix(self):
self.start()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', self.getConfig()['service']['port']))
s.sendall("HELO test.localhost")
s.close()
def testPostfixExists(self):
self.start()
self.run("ls -la /usr/sbin/postfix")
def testPostfixConfiguration(self):
self.start()
self.run("postconf -n mydomain | grep localhost")
self.run("postconf -n myhostname | grep mail.localhost")
self.run("postconf -n mydestination | grep localhost")
def testPostfixSkipped(self):
module_framework.skipTestIf("postfix" not in self.getActualProfile())
self.start()
self.run("postconf -n")
if __name__ == '__main__':
main()