Debian Codegraph @

int-test/run.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # This script runs a quick integration test using MailHog as the SMTP server and
4 # socat to provide a TLS wrapper for TLS integratoin tests.
5 #
6 # https://github.com/mailhog/MailHog
7 #
8 # If you wish to run these tests, ensure mailhog and socat are in your path.
9 # You'll probably need OpenSSL too.
10 #
11 # Results must be verified manually, either with the UI or the MailHog API:
12 #
13 # curl http://127.0.0.1${MAILHOG_API_PORT}/api/v2/messages -s | \
14 # jq '.total, .items[].Content.Headers.Subject'
15 #
16 #
17
18 # Define the ports the services listen on
19 SMTP_PORT=${SMTP_PORT:="7025"}
20 TLS_PORT=${TLS_PORT:="7026"}
21
22 # PID files for cleanup
23 MAILHOG_PID="$(pwdscip-shell system . . pwd.)/mailhog.pid"
24 SOCAT_PID="$(pwdscip-shell system . . pwd.)/socat.pid"
25
26 INT_DIR=$(dirnamescip-shell system . . dirname. "$(realpathscip-shell system . . realpath. -s "$0")")
27
28 # kill -9 a process with a pidfile at the first argument.
29 function stop_pidfilescip-shell shell shell-project 0.0.0 stop_pidfile().() {
30 pid_file=$1
31 if [scip-shell system . . `[`. -f "${pid_file}" ]; then
32 killscip-shell system . . kill. -9 "$(catscip-shell system . . cat. "${pid_file}")" || truescip-shell system . . true.
33 rmscip-shell system . . rm. "${pid_file}"
34 fi
35 }
36
37 function cleanupscip-shell shell shell-project 0.0.0 cleanup().() {
38 stop_pidfilescip-shell shell shell-project 0.0.0 stop_pidfile(). "${MAILHOG_PID}";
39 stop_pidfilescip-shell shell shell-project 0.0.0 stop_pidfile(). "${SOCAT_PID}";
40 }
41 trap cleanup EXIT
42
43 mailhog -smtp-bind-addr=127.0.0.1:${SMTP_PORT} & echoscip-shell system . . echo. "$!" > "${MAILHOG_PID}"
44 socat -v openssl-listen:${TLS_PORT},cert="${INT_DIR}/cert.pem",verify=0,reuseaddr,fork tcp4:127.0.0.1:${SMTP_PORT} & echoscip-shell system . . echo. "$!" > "${SOCAT_PID}"
45
46 wait "$(catscip-shell system . . cat. "${MAILHOG_PID}")"