Make static-page test use something else than localhost
This commit is contained in:
parent
ed29aa354a
commit
dfc4ef90c4
2 changed files with 13 additions and 10 deletions
|
@ -10,14 +10,14 @@
|
|||
inherit (lib) mkForce genAttrs const;
|
||||
in
|
||||
{
|
||||
# Setup simple localhost page with an example.com redirect
|
||||
# Setup simple docs.example.com page with an example.com redirect
|
||||
qois.static-page = {
|
||||
enable = true;
|
||||
pages."localhost".domainAliases = [ "example.com" ];
|
||||
pages."docs.example.com".domainAliases = [ "example.com" ];
|
||||
};
|
||||
|
||||
# Disable TLS services
|
||||
services.nginx.virtualHosts = genAttrs [ "localhost" "example.com" ] (const {
|
||||
services.nginx.virtualHosts = genAttrs [ "docs.example.com" "example.com" ] (const {
|
||||
forceSSL = mkForce false;
|
||||
enableACME = mkForce false;
|
||||
});
|
||||
|
|
|
@ -3,11 +3,11 @@ def test(subtest, webserver):
|
|||
webserver.wait_for_open_port(80)
|
||||
|
||||
# Preparations
|
||||
webserverRoot = "/var/lib/nginx-localhost/root"
|
||||
webserverRoot = "/var/lib/nginx-docs.example.com/root"
|
||||
indexContent = "It works!"
|
||||
webserver.succeed(f"mkdir {webserverRoot}")
|
||||
webserver.succeed(f"echo '{indexContent}' > {webserverRoot}/index.html")
|
||||
webserver.succeed(f"chown -R nginx-localhost\: {webserverRoot}")
|
||||
webserver.succeed(f"chown -R nginx-docs.example.com\: {webserverRoot}")
|
||||
|
||||
# Helpers
|
||||
def curl_variable_test(node, variable, expected, url):
|
||||
|
@ -34,12 +34,15 @@ def test(subtest, webserver):
|
|||
"""
|
||||
|
||||
# Tests
|
||||
with subtest("website is successfully served on localhost"):
|
||||
expect_http_code(webserver, "200", "http://localhost/index.html")
|
||||
expect_http_content(webserver, indexContent, "http://localhost/index.html")
|
||||
with subtest("website is successfully served on docs.example.com"):
|
||||
webserver.succeed("grep docs.example.com /etc/hosts")
|
||||
expect_http_code(webserver, "200", "http://docs.example.com/index.html")
|
||||
expect_http_content(
|
||||
webserver, indexContent, "http://docs.example.com/index.html"
|
||||
)
|
||||
|
||||
with subtest("example.com is in hosts file and a redirect to localhost"):
|
||||
webserver.succeed("grep example.com /etc/hosts")
|
||||
with subtest("example.com is a redirect to docs.example.com"):
|
||||
webserver.succeed("grep -e '[^\.]example.com' /etc/hosts")
|
||||
|
||||
url = "http://example.com/index.html"
|
||||
expect_http_code(webserver, "301", url)
|
||||
|
|
Loading…
Add table
Reference in a new issue