Skip to content

Commit 1318528

Browse files
committed
Fix tests broken due to the firewall being enabled by default
1 parent 017408e commit 1318528

File tree

16 files changed

+52
-25
lines changed

16 files changed

+52
-25
lines changed

nixos/modules/services/continuous-integration/jenkins/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ in {
4343
default = 8080;
4444
type = types.uniq types.int;
4545
description = ''
46-
Specifies port number on which the jenkins HTTP interface listens. The default is 8080
46+
Specifies port number on which the jenkins HTTP interface listens. The default is 8080.
4747
'';
4848
};
4949

nixos/modules/services/networking/avahi-daemon.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ in
142142
services.dbus.enable = true;
143143
services.dbus.packages = [avahi];
144144

145+
# Enabling Avahi without exposing it in the firewall doesn't make
146+
# sense.
147+
networking.firewall.allowedUDPPorts = [ 5353 ];
148+
145149
};
146150

147151
}

nixos/tests/bittorrent.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ in
3333
services.httpd.enable = true;
3434
services.httpd.adminAddr = "foo@example.org";
3535
services.httpd.documentRoot = "/tmp";
36+
37+
networking.firewall.enable = false; # FIXME: figure out what ports we actually need
3638
};
3739

3840
router =
@@ -50,11 +52,13 @@ in
5052
virtualisation.vlans = [ 2 ];
5153
networking.defaultGateway =
5254
nodes.router.config.networking.interfaces.eth2.ipAddress;
55+
networking.firewall.enable = false;
5356
};
5457

5558
client2 =
5659
{ config, pkgs, ... }:
5760
{ environment.systemPackages = [ pkgs.transmission ];
61+
networking.firewall.enable = false;
5862
};
5963
};
6064

@@ -66,8 +70,8 @@ in
6670
# Enable NAT on the router and start miniupnpd.
6771
$router->waitForUnit("nat");
6872
$router->succeed(
69-
"iptables -t nat -N MINIUPNPD",
70-
"iptables -t nat -A PREROUTING -i eth1 -j MINIUPNPD",
73+
"iptables -w -t nat -N MINIUPNPD",
74+
"iptables -w -t nat -A PREROUTING -i eth1 -j MINIUPNPD",
7175
"echo 1 > /proc/sys/net/ipv4/ip_forward",
7276
"miniupnpd -f ${miniupnpdConf nodes}"
7377
);

nixos/tests/containers.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
config =
1818
{ services.httpd.enable = true;
1919
services.httpd.adminAddr = "foo@example.org";
20+
networking.firewall.allowedTCPPorts = [ 80 ];
21+
networking.firewall.allowPing = true;
2022
};
2123
};
2224

@@ -65,7 +67,7 @@
6567
$machine->succeed("nixos-container start $id1");
6668
6769
# Execute commands via the root shell.
68-
$machine->succeed("echo uname | nixos-container root-shell $id1") =~ /Linux/;
70+
$machine->succeed("nixos-container run $id1 -- uname") =~ /Linux/;
6971
$machine->succeed("nixos-container set-root-password $id1 foobar");
7072
7173
# Destroy the containers.

nixos/tests/firewall.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
{ config, pkgs, ... }:
1818
{ services.httpd.enable = true;
1919
services.httpd.adminAddr = "foo@example.org";
20+
networking.firewall.enable = false;
2021
};
2122
};
2223

@@ -33,7 +34,7 @@
3334
$walled->succeed("curl -v http://localhost/ >&2");
3435
3536
# Connections to the firewalled machine should fail.
36-
$attacker->fail("curl -v http://walled/ >&2");
37+
$attacker->fail("curl --fail --connect-timeout 2 http://walled/ >&2");
3738
$attacker->fail("ping -c 1 walled >&2");
3839
3940
# Outgoing connections/pings should still work.

nixos/tests/installer.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ let
7979
virtualisation.writableStore = true;
8080
virtualisation.pathsInNixDB = channelContents ++ [ pkgs.hello.src ];
8181
virtualisation.memorySize = 768;
82+
83+
networking.firewall.allowedTCPPorts = [ 80 ];
8284
};
8385

8486
channelContents = [ pkgs.rlwrap ];

nixos/tests/ipv6.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{ config, pkgs, ... }:
1313
{ services.httpd.enable = true;
1414
services.httpd.adminAddr = "foo@example.org";
15+
networking.firewall.allowedTCPPorts = [ 80 ];
1516
};
1617

1718
router =

nixos/tests/jenkins.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@
33
# 2. jenkins user can be extended on both master and slave
44
# 3. jenkins service not started on slave node
55
{ pkgs, ... }:
6+
67
{
78
nodes = {
8-
master = { pkgs, config, ... }: {
9-
services.jenkins.enable = true;
9+
10+
master =
11+
{ config, pkgs, ... }:
12+
{ services.jenkins.enable = true;
1013

1114
# should have no effect
1215
services.jenkinsSlave.enable = true;
1316

1417
users.extraUsers.jenkins.extraGroups = [ "users" ];
1518
};
16-
slave = { pkgs, config, ... }: {
17-
services.jenkinsSlave.enable = true;
19+
20+
slave =
21+
{ config, pkgs, ... }:
22+
{ services.jenkinsSlave.enable = true;
1823

1924
users.extraUsers.jenkins.extraGroups = [ "users" ];
2025
};
26+
2127
};
2228

2329
testScript = ''

nixos/tests/mumble.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ in
1111
server = { config, pkgs, ... }: {
1212
services.murmur.enable = true;
1313
services.murmur.registerName = "NixOS tests";
14+
networking.firewall.allowedTCPPorts = [ config.services.murmur.port ];
1415
};
1516

1617
client1 = client;

nixos/tests/mysql-replication.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ in
1515
services.mysql.replication.role = "master";
1616
services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
1717
services.mysql.initialScript = pkgs.writeText "initmysql"
18-
''
19-
create user '${replicateUser}'@'%' identified by '${replicatePassword}';
20-
grant replication slave on *.* to '${replicateUser}'@'%';
21-
'';
18+
''
19+
create user '${replicateUser}'@'%' identified by '${replicatePassword}';
20+
grant replication slave on *.* to '${replicateUser}'@'%';
21+
'';
22+
networking.firewall.allowedTCPPorts = [ 3306 ];
2223
};
2324

2425
slave1 =

0 commit comments

Comments
 (0)