nixos/tests/echoip: init

This commit is contained in:
Defelo 2025-01-11 16:57:57 +01:00
parent 6a6d7de921
commit 96dd35f07d
No known key found for this signature in database
GPG Key ID: 2A05272471204DD3
3 changed files with 35 additions and 0 deletions

View File

@ -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;

29
nixos/tests/echoip.nix Normal file
View File

@ -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"
'';
}
)

View File

@ -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";