summary refs log tree commit diff
path: root/nixos/tests/prosody.nix
blob: a39bae7898dc215f7622054b097c82753deed5bb (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
34
35
36
37
38
import ./make-test.nix {
  name = "prosody";

  machine = { pkgs, ... }: {
    services.prosody = {
      enable = true;
      # TODO: use a self-signed certificate
      c2sRequireEncryption = false;
      extraConfig = ''
        storage = "sql"
      '';
      virtualHosts.test = {
        domain = "example.com";
        enabled = true;
      };
    };
    environment.systemPackages = [
      (pkgs.callPackage ./xmpp-sendmessage.nix {})
    ];
  };

  testScript = ''
    $machine->waitForUnit('prosody.service');
    $machine->succeed('prosodyctl status') =~ /Prosody is running/;

    # set password to 'nothunter2' (it's asked twice)
    $machine->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com');
    # set password to 'y'
    $machine->succeed('yes | prosodyctl adduser azurediamond@example.com');
    # correct password to 'hunter2'
    $machine->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com');

    $machine->succeed("send-message");

    $machine->succeed('prosodyctl deluser cthon98@example.com');
    $machine->succeed('prosodyctl deluser azurediamond@example.com');
  '';
}