diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index be546f2acc3a..5d6d92415bfd 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -294,6 +294,7 @@ in { early-mount-options = handleTest ./early-mount-options.nix {}; ec2-config = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-config or {}; ec2-nixops = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-nixops or {}; + echoip = handleTest ./echoip.nix {}; ecryptfs = handleTest ./ecryptfs.nix {}; fscrypt = handleTest ./fscrypt.nix {}; fastnetmon-advanced = runTest ./fastnetmon-advanced.nix; diff --git a/nixos/tests/echoip.nix b/nixos/tests/echoip.nix new file mode 100644 index 000000000000..036018b26438 --- /dev/null +++ b/nixos/tests/echoip.nix @@ -0,0 +1,29 @@ +import ./make-test-python.nix ( + { 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" + ''; + } +) diff --git a/pkgs/by-name/ec/echoip/package.nix b/pkgs/by-name/ec/echoip/package.nix index 688237ecbba1..0b533cc7b3b2 100644 --- a/pkgs/by-name/ec/echoip/package.nix +++ b/pkgs/by-name/ec/echoip/package.nix @@ -3,6 +3,7 @@ buildGoModule, fetchFromGitHub, makeWrapper, + nixosTests, }: buildGoModule { @@ -26,6 +27,10 @@ buildGoModule { --add-flags "-t $out/share/echoip/html" ''; + passthru = { + tests = { inherit (nixosTests) echoip; }; + }; + meta = { description = "IP address lookup service"; homepage = "https://github.com/mpolden/echoip";