add quota test

This commit is contained in:
Robin Raymond 2017-12-22 16:58:49 +01:00
parent eeb7fd64af
commit 6dd51d6e88

View file

@ -25,6 +25,7 @@ import <nixpkgs/nixos/tests/make-test.nix> {
mailserver = { mailserver = {
enable = true; enable = true;
debug = true;
fqdn = "mail.example.com"; fqdn = "mail.example.com";
domains = [ "example.com" "example2.com" ]; domains = [ "example.com" "example2.com" ];
@ -41,6 +42,10 @@ import <nixpkgs/nixos/tests/make-test.nix> {
"user@example2.com" = { "user@example2.com" = {
hashedPassword = "$6$u61JrAtuI0a$nGEEfTP5.eefxoScUGVG/Tl0alqla2aGax4oTd85v3j3xSmhv/02gNfSemv/aaMinlv9j/ZABosVKBrRvN5Qv0"; hashedPassword = "$6$u61JrAtuI0a$nGEEfTP5.eefxoScUGVG/Tl0alqla2aGax4oTd85v3j3xSmhv/02gNfSemv/aaMinlv9j/ZABosVKBrRvN5Qv0";
}; };
"lowquota@example.com" = {
hashedPassword = "$6$u61JrAtuI0a$nGEEfTP5.eefxoScUGVG/Tl0alqla2aGax4oTd85v3j3xSmhv/02gNfSemv/aaMinlv9j/ZABosVKBrRvN5Qv0";
quota = "1B";
};
}; };
enableImap = true; enableImap = true;
@ -62,6 +67,12 @@ import <nixpkgs/nixos/tests/make-test.nix> {
user 'user1\@example.com' there with password 'user1' is 'root' here user 'user1\@example.com' there with password 'user1' is 'root' here
mda procmail mda procmail
''; '';
fetchmailRcLowQuota =
''
poll SERVER with proto IMAP
user 'lowquota\@example.com' there with password 'user1' is 'root' here
mda procmail
'';
procmailRc = procmailRc =
'' ''
@ -231,6 +242,22 @@ import <nixpkgs/nixos/tests/make-test.nix> {
$client->fail("fetchmail -v"); $client->fail("fetchmail -v");
}; };
subtest "quota", sub {
$client->succeed("rm mail.txt");
$client->succeed("echo '${fetchmailRcLowQuota}' > ~/.fetchmailrc");
$client->succeed("sed -i s/SERVER/`getent hosts server | awk '{ print \$1 }'`/g ~/.fetchmailrc");
$client->succeed("chmod 0700 ~/.fetchmailrc");
$client->succeed("echo '${email2}' > mail.txt");
# send email from chuck to non exsitent account
$client->succeed("msmtp -a test3 --tls=on --tls-certcheck=off --auth=on lowquota\@example.com < mail.txt >&2");
$client->succeed("sleep 5");
# fetchmail returns EXIT_CODE 0 when it retrieves mail
$client->fail("fetchmail -v");
};
''; '';