@@ -3,7 +3,7 @@
33# client on the inside network, a server on the outside network, and a
44# router connected to both that performs Network Address Translation
55# for the client.
6−import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
6+import ./make-test-python.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
77 let
88 unit = if withFirewall then "firewall" else "nat";
99
@@ -69,49 +69,52 @@ import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false,
6969 routerDummyNoNatClosure = nodes.routerDummyNoNat.config.system.build.toplevel;
7070 routerClosure = nodes.router.config.system.build.toplevel;
7171 in ''
72− $client->start;
73− $router->start;
74− $server->start;
72+ client.start()
73+ router.start()
74+ server.start()
7575
7676 # The router should have access to the server.
77− $server->waitForUnit("network.target");
78− $server->waitForUnit("httpd");
79− $router->waitForUnit("network.target");
80− $router->succeed("curl --fail http://server/ >&2");
77+ server.wait_for_unit("network.target")
78+ server.wait_for_unit("httpd")
79+ router.wait_for_unit("network.target")
80+ router.succeed("curl --fail http://server/ >&2")
8181
8282 # The client should be also able to connect via the NAT router.
83− $router->waitForUnit("${unit}");
84− $client->waitForUnit("network.target");
85− $client->succeed("curl --fail http://server/ >&2");
86− $client->succeed("ping -c 1 server >&2");
83+ router.wait_for_unit("${unit}")
84+ client.wait_for_unit("network.target")
85+ client.succeed("curl --fail http://server/ >&2")
86+ client.succeed("ping -c 1 server >&2")
8787
8888 # Test whether passive FTP works.
89− $server->waitForUnit("vsftpd");
90− $server->succeed("echo Hello World > /home/ftp/foo.txt");
91− $client->succeed("curl -v ftp://server/foo.txt >&2");
89+ server.wait_for_unit("vsftpd")
90+ server.succeed("echo Hello World > /home/ftp/foo.txt")
91+ client.succeed("curl -v ftp://server/foo.txt >&2")
9292
9393 # Test whether active FTP works.
94− $client->${if withConntrackHelpers then "succeed" else "fail"}(
95− "curl -v -P - ftp://server/foo.txt >&2");
94+ client.${if withConntrackHelpers then "succeed" else "fail"}("curl -v -P - ftp://server/foo.txt >&2")
9695
9796 # Test ICMP.
98− $client->succeed("ping -c 1 router >&2");
99− $router->succeed("ping -c 1 client >&2");
97+ client.succeed("ping -c 1 router >&2")
98+ router.succeed("ping -c 1 client >&2")
10099
101100 # 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");
103− $client->fail("curl --fail --connect-timeout 5 http://server/ >&2");
104− $client->fail("ping -c 1 server >&2");
101+ router.succeed(
102+ "${routerDummyNoNatClosure}/bin/switch-to-configuration test 2>&1"
103+ )
104+ client.fail("curl --fail --connect-timeout 5 http://server/ >&2")
105+ client.fail("ping -c 1 server >&2")
105106
106107 # And make sure that reloading the NAT job works.
107− $router->succeed("${routerClosure}/bin/switch-to-configuration test 2>&1");
108+ router.succeed(
109+ "${routerClosure}/bin/switch-to-configuration test 2>&1"
110+ )
108111 # FIXME: this should not be necessary, but nat.service is not started because
109112 # network.target is not triggered
110113 # (https://github.com/NixOS/nixpkgs/issues/16230#issuecomment-226408359)
111114 ${lib.optionalString (!withFirewall) ''
112− $router->succeed("systemctl start nat.service");
115+ router.succeed("systemctl start nat.service")
113116 ''}
114− $client->succeed("curl --fail http://server/ >&2");
115− $client->succeed("ping -c 1 server >&2");
117+ client.succeed("curl --fail http://server/ >&2")
118+ client.succeed("ping -c 1 server >&2")
116119 '';
117120 })