summary refs log tree commit diff
path: root/nixos/tests/deluge.nix
blob: 37689c3d91372199e08d8a6a4639fec44baa8c58 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "deluge";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ flokli ];
  };

  nodes = {
    simple = {
      services.deluge = {
        enable = true;
        web = {
          enable = true;
          openFirewall = true;
        };
      };
    };

    declarative =
      { ... }:

      {
        services.deluge = {
          enable = true;
          openFirewall = true;
          declarative = true;
          config = {
            allow_remote = true;
            download_location = "/var/lib/deluge/my-download";
            daemon_port = 58846;
            listen_ports = [ 6881 6889 ];
          };
          web = {
            enable = true;
            port =  3142;
          };
          authFile = pkgs.writeText "deluge-auth" ''
            localclient:a7bef72a890:10
            andrew:password:10
            user3:anotherpass:5
          '';
        };
        environment.systemPackages = [ pkgs.deluge ];
      };

  };

  testScript = ''
    start_all()

    simple.wait_for_unit("deluged")
    simple.wait_for_unit("delugeweb")
    simple.wait_for_open_port("8112")
    declarative.wait_for_unit("network.target")
    declarative.wait_until_succeeds("curl --fail http://simple:8112")

    declarative.wait_for_unit("deluged")
    declarative.wait_for_unit("delugeweb")
    declarative.wait_until_succeeds("curl --fail http://declarative:3142")
    declarative.succeed("deluge-console 'help' | grep -q 'rm - Remove a torrent'")
    declarative.succeed(
        "deluge-console 'connect 127.0.0.1:58846 andrew password; help' | grep -q 'rm - Remove a torrent'"
    )
  '';
})