From dadbcdbf3f4ae88ce6d4cb9df8f4f95154045416 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sat, 22 Jun 2024 03:05:37 +0200 Subject: [PATCH] feat: add integration test between easywks server and client --- .forgejo/workflows/test.yml | 62 +++++++++++++++++++++++++++++++++++++ test/apache.conf | 24 ++++++++++++++ test/config-v1.1.xml | 22 +++++++++++++ test/dovecot.conf | 8 +++++ test/easywks.yml | 13 ++++++++ test/expect | 19 ++++++++++++ test/transport | 1 + 7 files changed, 149 insertions(+) create mode 100644 test/apache.conf create mode 100644 test/config-v1.1.xml create mode 100644 test/dovecot.conf create mode 100644 test/easywks.yml create mode 100755 test/expect create mode 100644 test/transport diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 8325149..6355a54 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -72,3 +72,65 @@ jobs: gpg --auto-key-locate=clear,wkd,nodefault --locate-keys alice@example.org kill %2 || true kill %1 || true + + easywksserver_easywksclient: + runs-on: docker + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - name: Integration Test against easywks-client + run: | + # General system setup + useradd -d /home/alice -m alice + useradd -d /home/webkey -m webkey + echo alice:supersecurepassword | chpasswd + echo "postfix postfix/mailname string example.org" | debconf-set-selections + echo "postfix postfix/main_mailer_type string 'Local only'" | debconf-set-selections + apt update; apt install --yes gnupg2 ca-certificates python3-pip apache2 dovecot-imapd postfix expect + echo "openpgpkey" > /etc/hostname + echo "127.0.0.1 openpgpkey.example.org openpgpkey example.org" > /etc/hosts + pip3 install --break-system-packages -e .[test] + openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/key.pem -out /etc/ssl/cert.pem -sha256 -days 365 -nodes -subj '/CN=openpgpkey.example.org' -addext 'subjectAltName=DNS:openpgpkey.example.org,DNS:example.org' + cp /etc/ssl/cert.pem /usr/local/share/ca-certificates/local.crt + update-ca-certificates + # Setup Apache + a2enmod ssl proxy_http rewrite + rm /etc/apache2/sites-enabled/000-default.conf + cp test/apache.conf /etc/apache2/sites-enabled/easywks.conf + apache2ctl start + mkdir -p /var/www/html/.well-known/autoconfig/mail/ + cp test/config-v1.1.xml /var/www/html/.well-known/autoconfig/mail/config-v1.1.xml + # Setup Dovecot + cp test/dovecot.conf /etc/dovecot/conf.d/99-local.conf + dovecot -F & + # Setup Postfix + /usr/lib/postfix/configure-instance.sh - + cp test/transport /etc/postfix/transport + postmap /etc/postfix/transport + postconf smtpd_tls_cert_file=/etc/ssl/cert.pem + postconf smtpd_tls_key_file=/etc/ssl/key.pem + postconf transport_maps=hash:/etc/postfix/transport + postconf smtpd_sasl_type=dovecot + postconf smtpd_sasl_path=private/auth + postconf smtpd_sasl_auth_enable=yes + /usr/sbin/postmulti -i - -p start + # Setup EasyWKS + mkdir -p /tmp/easywks + cp test/easywks.yml /tmp/easywks.yml + easywks --config /tmp/easywks.yml init + easywks --config /tmp/easywks.yml webserver & + easywks --config /tmp/easywks.yml lmtpd & + sleep 3 + # Run the test + install -m 0700 -d /tmp/gpg /tmp/cleangpg + export GNUPGHOME=/tmp/gpg + test/genkey.sh alice@example.org + export FINGERPRINT="$(gpg --with-colons --fingerprint alice@example.org | grep -A1 ^pub | grep ^fpr | cut -d: -f10)" + test/expect + gpg --auto-key-locate=clear,wkd,nodefault --locate-keys alice@example.org + # Teardown + apache2ctl stop + doveadm stop + /usr/sbin/postmulti -i - -p stop + kill %1 || true + kill %2 || true + sleep 5 # wait for daemons to terminate diff --git a/test/apache.conf b/test/apache.conf new file mode 100644 index 0000000..b207f3d --- /dev/null +++ b/test/apache.conf @@ -0,0 +1,24 @@ +ServerName example.org + + + ServerName example.org + ServerAlias openpgpkey.example.org + ServerAlias openpgpkey + DocumentRoot /var/www/html + RewriteEngine On + RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} + + + + ServerName example.org + ServerAlias openpgpkey.example.org + ServerAlias openpgpkey + DocumentRoot /var/www/html + + SSLEngine On + SSLCertificateFile /etc/ssl/cert.pem + SSLCertificateKeyFile /etc/ssl/key.pem + + ProxyPass /.well-known/openpgpkey http://localhost:8080/.well-known/openpgpkey + ProxyPassReverse /.well-known/openpgpkey http://localhost:8080/.well-known/openpgpkey + \ No newline at end of file diff --git a/test/config-v1.1.xml b/test/config-v1.1.xml new file mode 100644 index 0000000..50ebbb5 --- /dev/null +++ b/test/config-v1.1.xml @@ -0,0 +1,22 @@ + + + + example.org + EasyWKS Example + Example + + example.org + 993 + SSL + password-cleartext + %EMAILLOCALPART% + + + example.org + 25 + STARTTLS + password-cleartext + %EMAILLOCALPART% + + + \ No newline at end of file diff --git a/test/dovecot.conf b/test/dovecot.conf new file mode 100644 index 0000000..4eaf3c5 --- /dev/null +++ b/test/dovecot.conf @@ -0,0 +1,8 @@ +service auth { + unix_listener /var/spool/postfix/private/auth { + mode = 0666 + } +} +ssl_cert =