mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-20 12:43:52 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
82 lines
2.2 KiB
Nix
82 lines
2.2 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
{
|
|
name = "nginx-status-page";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ h7x4 ];
|
|
};
|
|
|
|
nodes = {
|
|
webserver =
|
|
{ ... }:
|
|
{
|
|
virtualisation.vlans = [ 1 ];
|
|
|
|
networking = {
|
|
useNetworkd = true;
|
|
useDHCP = false;
|
|
firewall.enable = false;
|
|
};
|
|
|
|
systemd.network.networks."01-eth1" = {
|
|
name = "eth1";
|
|
networkConfig.Address = "10.0.0.1/24";
|
|
};
|
|
|
|
services.nginx = {
|
|
enable = true;
|
|
statusPage = true;
|
|
virtualHosts."localhost".locations."/index.html".return = "200 'hello world\n'";
|
|
};
|
|
|
|
environment.systemPackages = with pkgs; [ curl ];
|
|
};
|
|
|
|
client =
|
|
{ ... }:
|
|
{
|
|
virtualisation.vlans = [ 1 ];
|
|
|
|
networking = {
|
|
useNetworkd = true;
|
|
useDHCP = false;
|
|
firewall.enable = false;
|
|
};
|
|
|
|
systemd.network.networks."01-eth1" = {
|
|
name = "eth1";
|
|
networkConfig.Address = "10.0.0.2/24";
|
|
};
|
|
|
|
environment.systemPackages = with pkgs; [ curl ];
|
|
};
|
|
};
|
|
|
|
testScript =
|
|
{ nodes, ... }:
|
|
''
|
|
start_all()
|
|
|
|
webserver.wait_for_unit("nginx")
|
|
webserver.wait_for_open_port(80)
|
|
|
|
def expect_http_code(node, code, url):
|
|
http_code = node.succeed(f"curl -w '%{{http_code}}' '{url}'")
|
|
assert http_code.split("\n")[-1].strip() == code, \
|
|
f"expected {code} but got following response:\n{http_code}"
|
|
|
|
with subtest("localhost can access status page"):
|
|
expect_http_code(webserver, "200", "http://localhost/nginx_status")
|
|
|
|
with subtest("localhost can access other page"):
|
|
expect_http_code(webserver, "200", "http://localhost/index.html")
|
|
|
|
with subtest("client can not access status page"):
|
|
expect_http_code(client, "403", "http://10.0.0.1/nginx_status")
|
|
|
|
with subtest("client can access other page"):
|
|
expect_http_code(client, "200", "http://10.0.0.1/index.html")
|
|
'';
|
|
}
|
|
)
|