nixos/tests/stalwart: split config into separate file (#427050)

+1 -1
nixos/tests/all-tests.nix
···
ssh-audit = runTest ./ssh-audit.nix;
sssd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd.nix { };
sssd-ldap = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd-ldap.nix { };
-
stalwart-mail = runTest ./stalwart-mail.nix;
+
stalwart-mail = runTest ./stalwart/stalwart-mail.nix;
stargazer = runTest ./web-servers/stargazer.nix;
starship = runTest ./starship.nix;
stash = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stash.nix { };
-155
nixos/tests/stalwart-mail.nix
···
-
# Rudimentary test checking that the Stalwart email server can:
-
# - receive some message through SMTP submission, then
-
# - serve this message through IMAP.
-
-
let
-
certs = import ./common/acme/server/snakeoil-certs.nix;
-
domain = certs.domain;
-
-
in
-
{ lib, ... }:
-
{
-
name = "stalwart-mail";
-
-
nodes.main =
-
{ pkgs, ... }:
-
{
-
security.pki.certificateFiles = [ certs.ca.cert ];
-
-
services.stalwart-mail = {
-
enable = true;
-
settings = {
-
server.hostname = domain;
-
-
certificate."snakeoil" = {
-
cert = "%{file:${certs.${domain}.cert}}%";
-
private-key = "%{file:${certs.${domain}.key}}%";
-
};
-
-
server.tls = {
-
certificate = "snakeoil";
-
enable = true;
-
implicit = false;
-
};
-
-
server.listener = {
-
"smtp-submission" = {
-
bind = [ "[::]:587" ];
-
protocol = "smtp";
-
};
-
-
"imap" = {
-
bind = [ "[::]:143" ];
-
protocol = "imap";
-
};
-
-
"http" = {
-
bind = [ "[::]:80" ];
-
protocol = "http";
-
};
-
};
-
-
session.auth.mechanisms = "[plain]";
-
session.auth.directory = "'in-memory'";
-
storage.directory = "in-memory";
-
-
storage.data = "rocksdb";
-
storage.fts = "rocksdb";
-
storage.blob = "rocksdb";
-
storage.lookup = "rocksdb";
-
-
session.rcpt.directory = "'in-memory'";
-
queue.outbound.next-hop = "'local'";
-
-
store."rocksdb" = {
-
type = "rocksdb";
-
path = "/var/lib/stalwart-mail/data";
-
compression = "lz4";
-
};
-
-
directory."in-memory" = {
-
type = "memory";
-
principals = [
-
{
-
class = "individual";
-
name = "alice";
-
secret = "foobar";
-
email = [ "alice@${domain}" ];
-
}
-
{
-
class = "individual";
-
name = "bob";
-
secret = "foobar";
-
email = [ "bob@${domain}" ];
-
}
-
];
-
};
-
};
-
};
-
-
environment.systemPackages = [
-
(pkgs.writers.writePython3Bin "test-smtp-submission" { } ''
-
from smtplib import SMTP
-
-
with SMTP('localhost', 587) as smtp:
-
smtp.starttls()
-
smtp.login('alice', 'foobar')
-
smtp.sendmail(
-
'alice@${domain}',
-
'bob@${domain}',
-
"""
-
From: alice@${domain}
-
To: bob@${domain}
-
Subject: Some test message
-
-
This is a test message.
-
""".strip()
-
)
-
'')
-
-
(pkgs.writers.writePython3Bin "test-imap-read" { } ''
-
from imaplib import IMAP4
-
-
with IMAP4('localhost') as imap:
-
imap.starttls()
-
status, [caps] = imap.login('bob', 'foobar')
-
assert status == 'OK'
-
imap.select()
-
status, [ref] = imap.search(None, 'ALL')
-
assert status == 'OK'
-
[msgId] = ref.split()
-
status, msg = imap.fetch(msgId, 'BODY[TEXT]')
-
assert status == 'OK'
-
assert msg[0][1].strip() == b'This is a test message.'
-
'')
-
];
-
};
-
-
testScript = # python
-
''
-
main.wait_for_unit("stalwart-mail.service")
-
main.wait_for_open_port(587)
-
main.wait_for_open_port(143)
-
main.wait_for_open_port(80)
-
-
main.succeed("test-smtp-submission")
-
-
# restart stalwart to test rocksdb compaction of existing database
-
main.succeed("systemctl restart stalwart-mail.service")
-
main.wait_for_open_port(587)
-
main.wait_for_open_port(143)
-
-
main.succeed("test-imap-read")
-
-
main.succeed("test -d /var/cache/stalwart-mail/STALWART_WEBADMIN")
-
main.succeed("curl --fail http://localhost")
-
'';
-
-
meta = {
-
maintainers = with lib.maintainers; [
-
happysalada
-
euxane
-
onny
-
];
-
};
-
}
+81
nixos/tests/stalwart/stalwart-mail-config.nix
···
+
{ pkgs, lib, ... }:
+
+
let
+
certs = import ../common/acme/server/snakeoil-certs.nix;
+
domain = certs.domain;
+
in
+
{
+
security.pki.certificateFiles = [ certs.ca.cert ];
+
+
services.stalwart-mail = {
+
enable = true;
+
settings = {
+
server.hostname = domain;
+
+
certificate."snakeoil" = {
+
cert = "%{file:${certs.${domain}.cert}}%";
+
private-key = "%{file:${certs.${domain}.key}}%";
+
};
+
+
server.tls = {
+
certificate = "snakeoil";
+
enable = true;
+
implicit = false;
+
};
+
+
server.listener = {
+
"smtp-submission" = {
+
bind = [ "[::]:587" ];
+
protocol = "smtp";
+
};
+
+
"imap" = {
+
bind = [ "[::]:143" ];
+
protocol = "imap";
+
};
+
+
"http" = {
+
bind = [ "[::]:80" ];
+
protocol = "http";
+
};
+
};
+
+
session.auth.mechanisms = "[plain]";
+
session.auth.directory = "'in-memory'";
+
storage.directory = "in-memory";
+
+
storage.data = "rocksdb";
+
storage.fts = "rocksdb";
+
storage.blob = "rocksdb";
+
storage.lookup = "rocksdb";
+
+
session.rcpt.directory = "'in-memory'";
+
queue.outbound.next-hop = "'local'";
+
+
store."rocksdb" = {
+
type = "rocksdb";
+
path = "/var/lib/stalwart-mail/data";
+
compression = "lz4";
+
};
+
+
directory."in-memory" = {
+
type = "memory";
+
principals = [
+
{
+
class = "individual";
+
name = "alice";
+
secret = "foobar";
+
email = [ "alice@${domain}" ];
+
}
+
{
+
class = "individual";
+
name = "bob";
+
secret = "foobar";
+
email = [ "bob@${domain}" ];
+
}
+
];
+
};
+
};
+
};
+
+
}
+85
nixos/tests/stalwart/stalwart-mail.nix
···
+
# Rudimentary test checking that the Stalwart email server can:
+
# - receive some message through SMTP submission, then
+
# - serve this message through IMAP.
+
+
let
+
certs = import ../common/acme/server/snakeoil-certs.nix;
+
domain = certs.domain;
+
in
+
{ lib, ... }:
+
{
+
name = "stalwart-mail";
+
+
nodes.main =
+
{ pkgs, ... }:
+
{
+
imports = [
+
./stalwart-mail-config.nix
+
];
+
+
environment.systemPackages = [
+
(pkgs.writers.writePython3Bin "test-smtp-submission" { } ''
+
from smtplib import SMTP
+
+
with SMTP('localhost', 587) as smtp:
+
smtp.starttls()
+
smtp.login('alice', 'foobar')
+
smtp.sendmail(
+
'alice@${domain}',
+
'bob@${domain}',
+
"""
+
From: alice@${domain}
+
To: bob@${domain}
+
Subject: Some test message
+
+
This is a test message.
+
""".strip()
+
)
+
'')
+
+
(pkgs.writers.writePython3Bin "test-imap-read" { } ''
+
from imaplib import IMAP4
+
+
with IMAP4('localhost') as imap:
+
imap.starttls()
+
status, [caps] = imap.login('bob', 'foobar')
+
assert status == 'OK'
+
imap.select()
+
status, [ref] = imap.search(None, 'ALL')
+
assert status == 'OK'
+
[msgId] = ref.split()
+
status, msg = imap.fetch(msgId, 'BODY[TEXT]')
+
assert status == 'OK'
+
assert msg[0][1].strip() == b'This is a test message.'
+
'')
+
];
+
};
+
+
testScript = # python
+
''
+
main.wait_for_unit("stalwart-mail.service")
+
main.wait_for_open_port(587)
+
main.wait_for_open_port(143)
+
main.wait_for_open_port(80)
+
+
main.succeed("test-smtp-submission")
+
+
# restart stalwart to test rocksdb compaction of existing database
+
main.succeed("systemctl restart stalwart-mail.service")
+
main.wait_for_open_port(587)
+
main.wait_for_open_port(143)
+
+
main.succeed("test-imap-read")
+
+
main.succeed("test -d /var/cache/stalwart-mail/STALWART_WEBADMIN")
+
main.succeed("curl --fail http://localhost")
+
'';
+
+
meta = {
+
maintainers = with lib.maintainers; [
+
happysalada
+
euxane
+
onny
+
];
+
};
+
}