mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 12:53:59 +03:00
nixos/tests/nat: add test for conntrack helper autoloading
This commit is contained in:
parent
8322a12ef2
commit
2d9152d509
@ -273,6 +273,7 @@ in rec {
|
||||
tests.mysql = callTest tests/mysql.nix {};
|
||||
tests.mysqlReplication = callTest tests/mysql-replication.nix {};
|
||||
tests.nat.firewall = callTest tests/nat.nix { withFirewall = true; };
|
||||
tests.nat.firewall-conntrack = callTest tests/nat.nix { withFirewall = true; withConntrackHelpers = true; };
|
||||
tests.nat.standalone = callTest tests/nat.nix { withFirewall = false; };
|
||||
tests.networking.networkd = callSubTests tests/networking.nix { networkd = true; };
|
||||
tests.networking.scripted = callSubTests tests/networking.nix { networkd = false; };
|
||||
|
@ -3,12 +3,13 @@
|
||||
# client on the inside network, a server on the outside network, and a
|
||||
# router connected to both that performs Network Address Translation
|
||||
# for the client.
|
||||
import ./make-test.nix ({ pkgs, withFirewall, ... }:
|
||||
import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
|
||||
let
|
||||
unit = if withFirewall then "firewall" else "nat";
|
||||
in
|
||||
{
|
||||
name = "nat${if withFirewall then "WithFirewall" else "Standalone"}";
|
||||
name = "nat" + (if withFirewall then "WithFirewall" else "Standalone")
|
||||
+ (lib.optionalString withConntrackHelpers "withConntrackHelpers");
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ eelco chaoflow rob wkennington ];
|
||||
};
|
||||
@ -16,21 +17,33 @@ import ./make-test.nix ({ pkgs, withFirewall, ... }:
|
||||
nodes =
|
||||
{ client =
|
||||
{ config, pkgs, nodes, ... }:
|
||||
lib.mkMerge [
|
||||
{ virtualisation.vlans = [ 1 ];
|
||||
networking.firewall.allowPing = true;
|
||||
networking.defaultGateway =
|
||||
(pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address;
|
||||
};
|
||||
}
|
||||
(lib.optionalAttrs withConntrackHelpers {
|
||||
networking.firewall.connectionTrackingModules = [ "ftp" ];
|
||||
networking.firewall.autoLoadConntrackHelpers = true;
|
||||
})
|
||||
];
|
||||
|
||||
router =
|
||||
{ config, pkgs, ... }:
|
||||
lib.mkMerge [
|
||||
{ virtualisation.vlans = [ 2 1 ];
|
||||
networking.firewall.enable = withFirewall;
|
||||
networking.firewall.allowPing = true;
|
||||
networking.nat.enable = true;
|
||||
networking.nat.internalIPs = [ "192.168.1.0/24" ];
|
||||
networking.nat.externalInterface = "eth1";
|
||||
};
|
||||
}
|
||||
(lib.optionalAttrs withConntrackHelpers {
|
||||
networking.firewall.connectionTrackingModules = [ "ftp" ];
|
||||
networking.firewall.autoLoadConntrackHelpers = true;
|
||||
})
|
||||
];
|
||||
|
||||
server =
|
||||
{ config, pkgs, ... }:
|
||||
@ -65,6 +78,10 @@ import ./make-test.nix ({ pkgs, withFirewall, ... }:
|
||||
$server->succeed("echo Hello World > /home/ftp/foo.txt");
|
||||
$client->succeed("curl -v ftp://server/foo.txt >&2");
|
||||
|
||||
# Test whether active FTP works.
|
||||
$client->${if withConntrackHelpers then "succeed" else "fail"}(
|
||||
"curl -v -P - ftp://server/foo.txt >&2");
|
||||
|
||||
# Test ICMP.
|
||||
$client->succeed("ping -c 1 router >&2");
|
||||
$router->succeed("ping -c 1 client >&2");
|
||||
|
Loading…
Reference in New Issue
Block a user