mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2025-05-26 04:20:57 +05:00
test/relay: init
Co-authored-by: Michael Lohmann <michael@lohmann.sh>
This commit is contained in:
parent
e4c6e6e2ee
commit
5648001ef3
@ -36,6 +36,7 @@
|
|||||||
"internal"
|
"internal"
|
||||||
"ldap"
|
"ldap"
|
||||||
"multiple"
|
"multiple"
|
||||||
|
"domainsWithoutMailbox"
|
||||||
];
|
];
|
||||||
|
|
||||||
genTest = testName: release: let
|
genTest = testName: release: let
|
||||||
|
81
tests/domainsWithoutMailbox.nix
Normal file
81
tests/domainsWithoutMailbox.nix
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# This tests is used to test features requiring several mail domains.
|
||||||
|
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
hashPassword = password: pkgs.runCommand
|
||||||
|
"password-${password}-hashed"
|
||||||
|
{ buildInputs = [ pkgs.mkpasswd ]; inherit password; }
|
||||||
|
''
|
||||||
|
mkpasswd -sm bcrypt <<<"$password" > $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
password = pkgs.writeText "password" "password";
|
||||||
|
|
||||||
|
domainGenerator = domain: {
|
||||||
|
imports = [ ../default.nix ];
|
||||||
|
virtualisation.memorySize = 1024;
|
||||||
|
mailserver = {
|
||||||
|
enable = true;
|
||||||
|
fqdn = "mail.${domain}";
|
||||||
|
domains = [ domain ];
|
||||||
|
localDnsResolver = false;
|
||||||
|
loginAccounts = {
|
||||||
|
"user@${domain}" = {
|
||||||
|
hashedPasswordFile = hashPassword "password";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
enableImap = true;
|
||||||
|
enableImapSsl = true;
|
||||||
|
};
|
||||||
|
services = {
|
||||||
|
dnsmasq = {
|
||||||
|
enable = true;
|
||||||
|
settings.mx-host = [ "domain1.com,domain1,10" "domain2.com,domain2,10" ];
|
||||||
|
};
|
||||||
|
# disable rspamd graylisting and other stuff hardful top tests
|
||||||
|
rspamd.extraConfig = ''
|
||||||
|
actions {
|
||||||
|
reject = null; # Disable rejects, default is 15
|
||||||
|
add_header = 6; # Add header when reaching this score
|
||||||
|
greylist = null; # Disable greylisting
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "domainsWithoutMailbox";
|
||||||
|
nodes = {
|
||||||
|
domain1 = {
|
||||||
|
imports = [
|
||||||
|
../default.nix
|
||||||
|
(domainGenerator "domain1.com")
|
||||||
|
];
|
||||||
|
mailserver.domainsWithoutMailbox = [ "relay.domain1.com" ];
|
||||||
|
# ip of itself
|
||||||
|
services.postfix.networks = [ "[2001:db8:1::1]/128" ];
|
||||||
|
};
|
||||||
|
domain2 = domainGenerator "domain2.com";
|
||||||
|
client = { pkgs, ... }: {
|
||||||
|
environment.systemPackages = [
|
||||||
|
(pkgs.writeScriptBin "mail-check" ''
|
||||||
|
${pkgs.python3}/bin/python ${../scripts/mail-check.py} $@
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
domain1.wait_for_unit("multi-user.target")
|
||||||
|
domain2.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
# user@domain1.com sends a mail to user@domain2.com
|
||||||
|
client.succeed(
|
||||||
|
"mail-check send-and-read --smtp-port 25 --smtp-starttls --smtp-host domain1 --from-addr user@relay.domain1.com --imap-host domain2 --to-addr user@domain2.com --dst-password-file ${password} --ignore-dkim-spf"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user