-
Notifications
You must be signed in to change notification settings - Fork 269
/
postfix_tls.pm
57 lines (47 loc) · 2 KB
/
postfix_tls.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# SUSE's openQA tests
#
# Copyright 2017-2018 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Package: postfix cyrus-sasl cyrus-sasl-saslauthd mailx
# Summary: Test Postfix mail server with SSL enabled
# Note: The test case can be run separately for postfix sanity test,
# or run as stand-alone mail server (together with dovecot)
# in multi-machine test scenario if MAIL_SERVER var set.
# Maintainer: QE Security <none@suse.de>
use base "consoletest";
use strict;
use warnings;
use testapi;
use utils;
use mailtest;
sub run {
my $self = shift;
my $postfix_conf = "/etc/postfix/main.cf";
my $postfix_cert = "/etc/postfix/ssl/postfix.crt";
my $postfix_key = "/etc/postfix/ssl/postfix.key";
select_console "root-console";
prepare_mail_server;
# Install postfix and required packages
zypper_call "in postfix cyrus-sasl cyrus-sasl-saslauthd mailx";
# Configure postfix with TLS support (only smtpd)
assert_script_run "curl " . data_url('postfix/main.cf') . " -o $postfix_conf";
assert_script_run "curl " . data_url('openssl/mail-server-cert.pem') . " -o $postfix_cert";
assert_script_run "curl " . data_url('openssl/mail-server-key.pem') . " -o $postfix_key";
assert_script_run "sed -i 's/^#tlsmgr/tlsmgr/' /etc/postfix/master.cf";
systemctl "restart saslauthd.service";
systemctl "is-active saslauthd.service";
systemctl "restart postfix.service";
systemctl "is-active postfix.service";
# Print service status for debugging
systemctl "-l status saslauthd.service 2>&1 | tee /dev/$serialdev";
systemctl "-l status postfix.service 2>&1 | tee /dev/$serialdev";
script_run "(ss -nltp | grep master) 2>&1 | tee /dev/$serialdev";
systemctl 'stop ' . $self->firewall;
# Send testing mail
mailx_setup(ssl => "yes", host => $mail_server_name);
mailx_send_mail(subject => "openQA Testing", to => "$username\@$mail_server_name");
# Verify mail received
assert_script_run "postfix flush; grep 'openQA Testing' /var/mail/$username";
}
1;