about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/magnetico.nix
blob: 6770d32358e833e6db5ebfd40e6f55d0e55d80cc (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
import ./make-test-python.nix ({ pkgs, ...} :

let
  port = 8081;
in
{
  name = "magnetico";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ rnhmjoj ];
  };

  machine = { ... }: {
    imports = [ ../modules/profiles/minimal.nix ];

    networking.firewall.allowedTCPPorts = [ 9000 ];

    services.magnetico = {
      enable = true;
      crawler.port = 9000;
      web.port = port;
      web.credentials.user = "$2y$12$P88ZF6soFthiiAeXnz64aOWDsY3Dw7Yw8fZ6GtiqFNjknD70zDmNe";
    };
  };

  testScript =
    ''
      start_all()
      machine.wait_for_unit("magneticod")
      machine.wait_for_unit("magneticow")
      machine.succeed(
          "${pkgs.curl}/bin/curl "
          + "-u user:password http://localhost:${toString port}"
      )
      assert "Unauthorised." in machine.succeed(
          "${pkgs.curl}/bin/curl "
          + "-u user:wrongpwd http://localhost:${toString port}"
      )
      machine.shutdown()
    '';
})