@@ -3,7 +3,7 @@
3# client on the inside network, a server on the outside network, and a
3# client on the inside network, a server on the outside network, and a
4# router connected to both that performs Network Address Translation
4# router connected to both that performs Network Address Translation
5# for the client.
5# for the client.
6−import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
6+import ./make-test-python.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
8 unit = if withFirewall then "firewall" else "nat";
8 unit = if withFirewall then "firewall" else "nat";
@@ -69,49 +69,52 @@ import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false,
69 routerDummyNoNatClosure = nodes.routerDummyNoNat.config.system.build.toplevel;
69 routerDummyNoNatClosure = nodes.routerDummyNoNat.config.system.build.toplevel;
70 routerClosure = nodes.router.config.system.build.toplevel;
70 routerClosure = nodes.router.config.system.build.toplevel;
72− $client->start;
72+ client.start()
73− $router->start;
73+ router.start()
74− $server->start;
74+ server.start()
76 # The router should have access to the server.
76 # The router should have access to the server.
77− $server->waitForUnit("network.target");
77+ server.wait_for_unit("network.target")
78− $server->waitForUnit("httpd");
78+ server.wait_for_unit("httpd")
79− $router->waitForUnit("network.target");
79+ router.wait_for_unit("network.target")
80− $router->succeed("curl --fail http://server/ >&2");
80+ router.succeed("curl --fail http://server/ >&2")
82 # The client should be also able to connect via the NAT router.
82 # The client should be also able to connect via the NAT router.
83− $router->waitForUnit("${unit}");
83+ router.wait_for_unit("${unit}")
84− $client->waitForUnit("network.target");
84+ client.wait_for_unit("network.target")
85− $client->succeed("curl --fail http://server/ >&2");
85+ client.succeed("curl --fail http://server/ >&2")
86− $client->succeed("ping -c 1 server >&2");
86+ client.succeed("ping -c 1 server >&2")
88 # Test whether passive FTP works.
88 # Test whether passive FTP works.
89− $server->waitForUnit("vsftpd");
89+ server.wait_for_unit("vsftpd")
90− $server->succeed("echo Hello World > /home/ftp/foo.txt");
90+ server.succeed("echo Hello World > /home/ftp/foo.txt")
91− $client->succeed("curl -v ftp://server/foo.txt >&2");
91+ client.succeed("curl -v ftp://server/foo.txt >&2")
93 # Test whether active FTP works.
93 # Test whether active FTP works.
94− $client->${if withConntrackHelpers then "succeed" else "fail"}(
94+ client.${if withConntrackHelpers then "succeed" else "fail"}("curl -v -P - ftp://server/foo.txt >&2")
95− "curl -v -P - ftp://server/foo.txt >&2");
97 # Test ICMP.
96 # Test ICMP.
98− $client->succeed("ping -c 1 router >&2");
97+ client.succeed("ping -c 1 router >&2")
99− $router->succeed("ping -c 1 client >&2");
98+ router.succeed("ping -c 1 client >&2")
101 # If we turn off NAT, the client shouldn't be able to reach the server.
100 # If we turn off NAT, the client shouldn't be able to reach the server.
102− $router->succeed("${routerDummyNoNatClosure}/bin/switch-to-configuration test 2>&1");
102+ "${routerDummyNoNatClosure}/bin/switch-to-configuration test 2>&1"
103− $client->fail("curl --fail --connect-timeout 5 http://server/ >&2");
104+ client.fail("curl --fail --connect-timeout 5 http://server/ >&2")
104− $client->fail("ping -c 1 server >&2");
105+ client.fail("ping -c 1 server >&2")
106 # And make sure that reloading the NAT job works.
107 # And make sure that reloading the NAT job works.
107− $router->succeed("${routerClosure}/bin/switch-to-configuration test 2>&1");
109+ "${routerClosure}/bin/switch-to-configuration test 2>&1"
108 # FIXME: this should not be necessary, but nat.service is not started because
111 # FIXME: this should not be necessary, but nat.service is not started because
109 # network.target is not triggered
112 # network.target is not triggered
110 # (https://github.com/NixOS/nixpkgs/issues/16230#issuecomment-226408359)
113 # (https://github.com/NixOS/nixpkgs/issues/16230#issuecomment-226408359)
111 ${lib.optionalString (!withFirewall) ''
114 ${lib.optionalString (!withFirewall) ''
112− $router->succeed("systemctl start nat.service");
115+ router.succeed("systemctl start nat.service")
114− $client->succeed("curl --fail http://server/ >&2");
117+ client.succeed("curl --fail http://server/ >&2")
115− $client->succeed("ping -c 1 server >&2");
118+ client.succeed("ping -c 1 server >&2")