Add minimal (internal) tests
This commit is contained in:
parent
a592881b8b
commit
9687dbaae1
3 changed files with 62 additions and 0 deletions
|
|
@ -32,6 +32,15 @@
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
|
checks = let
|
||||||
|
tests = ["internal"];
|
||||||
|
genTest = testName: {
|
||||||
|
"name" = testName;
|
||||||
|
"value" = import (./tests + "/${testName}.nix") {inherit pkgs;};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.lib.listToAttrs (map genTest tests);
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
alejandra
|
alejandra
|
||||||
|
|
|
||||||
13
tests/common/server.nix
Normal file
13
tests/common/server.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{...}: {
|
||||||
|
imports = [./../../mailsystem];
|
||||||
|
config = {
|
||||||
|
virtualisation.memorySize = 1024;
|
||||||
|
mailsystem = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
roundcube.enable = false;
|
||||||
|
rspamd.webUi.enable = false;
|
||||||
|
certificateScheme = "selfsigned";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
40
tests/internal.nix
Normal file
40
tests/internal.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{pkgs, ...}:
|
||||||
|
pkgs.nixosTest {
|
||||||
|
name = "internal";
|
||||||
|
nodes.machine = {...}: {
|
||||||
|
imports = [./common/server.nix];
|
||||||
|
mailsystem = {
|
||||||
|
fqdn = "mail.example.com";
|
||||||
|
domains = ["example.com"];
|
||||||
|
accounts = {};
|
||||||
|
vmailUserName = "vmail";
|
||||||
|
vmailGroupName = "vmail";
|
||||||
|
vmailUID = 5000;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
testScript = {nodes, ...}: let
|
||||||
|
pkgs = nodes.machine.nixpkgs.pkgs;
|
||||||
|
in ''
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
with subtest("imap is only available via port 993 and is encrypted"):
|
||||||
|
machine.wait_for_closed_port(143)
|
||||||
|
machine.wait_for_open_port(993)
|
||||||
|
machine.succeed(
|
||||||
|
"echo | ${pkgs.openssl}/bin/openssl s_client -connect localhost:993 | grep 'New, TLS'"
|
||||||
|
)
|
||||||
|
|
||||||
|
with subtest("smtp is only available via port 465 and is encrypted"):
|
||||||
|
machine.wait_for_closed_port(587)
|
||||||
|
machine.wait_for_open_port(465)
|
||||||
|
machine.succeed(
|
||||||
|
"echo | ${pkgs.openssl}/bin/openssl s_client -connect localhost:465 | grep 'New, TLS'"
|
||||||
|
)
|
||||||
|
|
||||||
|
with subtest("`postfix check` succeeds"):
|
||||||
|
machine.succeed(
|
||||||
|
"${pkgs.postfix}/bin/postfix check"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue