summaryrefslogtreecommitdiffstats
path: root/nixos/tests/echoip.nix
blob: 0e7747d713c1fb56ab8cce7f0c800f9aff650a72 (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
{ lib, ... }:

{
  name = "echoip";
  meta.maintainers = with lib.maintainers; [ defelo ];

  nodes.machine = {
    services.echoip = {
      enable = true;
      virtualHost = "echoip.local";
    };

    networking.hosts = {
      "127.0.0.1" = [ "echoip.local" ];
      "::1" = [ "echoip.local" ];
    };
  };

  testScript = ''
    machine.wait_for_unit("echoip.service")
    machine.wait_for_open_port(8080)

    resp = machine.succeed("curl -4 http://echoip.local/ip")
    assert resp.strip() == "127.0.0.1"
    resp = machine.succeed("curl -6 http://echoip.local/ip")
    assert resp.strip() == "::1"
  '';
}