summaryrefslogtreecommitdiffstats
path: root/nixos/tests/ifm.nix
blob: 0ef0b76cb1d3013c04a040a227180b7871df7fb0 (plain)
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
{ pkgs, ... }:

{
  name = "ifm";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ litchipi ];
  };

  nodes = {
    server =
      { config, ... }:
      {
        services.ifm = {
          enable = true;
          port = 9001;
          dataDir = "/data";
        };

        systemd.tmpfiles.settings = {
          ifm-data-dir = {
            ${config.services.ifm.dataDir}.d = {
              mode = "0777";
              user = "root";
              group = "root";
            };
          };
        };
      };
  };

  testScript =
    # python
    ''
      start_all()
      server.wait_for_unit("ifm.service")
      server.wait_for_open_port(9001)
      server.succeed("curl --fail http://localhost:9001")

      server.succeed('echo "testfile" > testfile')
      server.succeed("shasum testfile | tee checksums")

      server.succeed('curl --fail http://localhost:9001 -X POST -F "api=upload" -F "dir=" -F "file=@testfile" | grep "OK"');
      server.succeed("rm testfile")

      server.succeed('curl --fail http://localhost:9001 -X POST -F "api=download" -F "filename=testfile" -F "dir=" --output testfile');
      server.succeed("shasum --check checksums")
    '';
}