nixosTests.nginx-globalredirect: migrate to runTest

Part of #386873
This commit is contained in:
Piotr Kwiecinski 2025-03-29 23:50:31 +01:00
parent 8638fa379f
commit 69df9598cb
No known key found for this signature in database
GPG key ID: EC0DE1CB9D5258B4
2 changed files with 23 additions and 25 deletions

View file

@ -801,7 +801,7 @@ in {
nginx-auth = runTest ./nginx-auth.nix;
nginx-etag = runTest ./nginx-etag.nix;
nginx-etag-compression = runTest ./nginx-etag-compression.nix;
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {};
nginx-globalredirect = runTest ./nginx-globalredirect.nix;
nginx-http3 = handleTest ./nginx-http3.nix {};
nginx-mime = handleTest ./nginx-mime.nix {};
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};

View file

@ -1,29 +1,27 @@
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "nginx-globalredirect";
{ ... }:
{
name = "nginx-globalredirect";
nodes = {
webserver =
{ pkgs, lib, ... }:
{
services.nginx = {
enable = true;
virtualHosts.localhost = {
globalRedirect = "other.example.com";
# Add an exception
locations."/noredirect".return = "200 'foo'";
};
nodes = {
webserver =
{ pkgs, lib, ... }:
{
services.nginx = {
enable = true;
virtualHosts.localhost = {
globalRedirect = "other.example.com";
# Add an exception
locations."/noredirect".return = "200 'foo'";
};
};
};
};
};
testScript = ''
webserver.wait_for_unit("nginx")
webserver.wait_for_open_port(80)
testScript = ''
webserver.wait_for_unit("nginx")
webserver.wait_for_open_port(80)
webserver.succeed("curl --fail -si http://localhost/alf | grep '^Location:.*/alf'")
webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'")
'';
}
)
webserver.succeed("curl --fail -si http://localhost/alf | grep '^Location:.*/alf'")
webserver.fail("curl --fail -si http://localhost/noredirect | grep '^Location:'")
'';
}