about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/web-apps/monica.nix
blob: 29f5cb85bb13a479f6045bbed8e60623f996269e (plain) (blame)
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
import ../make-test-python.nix ({pkgs, ...}:
let
  cert = pkgs.runCommand "selfSignedCerts" { nativeBuildInputs = [ pkgs.openssl ]; } ''
    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=localhost' -days 36500
    mkdir -p $out
    cp key.pem cert.pem $out
  '';
in
{
  name = "monica";

  nodes = {
    machine = {pkgs, ...}: {
      services.monica = {
        enable = true;
        hostname = "localhost";
        appKeyFile = "${pkgs.writeText "keyfile" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}";
        nginx = {
          forceSSL = true;
          sslCertificate = "${cert}/cert.pem";
          sslCertificateKey = "${cert}/key.pem";
        };
      };
    };
  };

  testScript = ''
    start_all()
    machine.wait_for_unit("monica-setup.service")
    machine.wait_for_open_port(443)
    machine.succeed("curl -k --fail https://localhost", timeout=10)
  '';
})