diff --git a/tests/test_app.py b/tests/test_app.py
index 158c088..1754f5b 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -292,6 +292,18 @@ def test_nonroot_root(testpriv):
resp.mustcontain("easy_install -i http://nonroot/priv/simple/ PACKAGE")
+def test_nonroot_root_with_x_forwarded_host(testapp):
+ resp = testapp.get("/", headers={"X-Forwarded-Host": "forward.ed/priv/"})
+ resp.mustcontain("easy_install -i http://forward.ed/priv/simple/ PACKAGE")
+ resp.mustcontain("""here""")
+
+
+def test_nonroot_root_with_x_forwarded_host_without_tailing_slash(testapp):
+ resp = testapp.get("/", headers={"X-Forwarded-Host": "forward.ed/priv/"})
+ resp.mustcontain("easy_install -i http://forward.ed/priv/simple/ PACKAGE")
+ resp.mustcontain("""here""")
+
+
def test_nonroot_simple_index(root, testpriv):
root.join("foobar-1.0.zip").write("")
resp = testpriv.get("/priv/simple/foobar/")
@@ -300,6 +312,14 @@ def test_nonroot_simple_index(root, testpriv):
assert links[0]["href"].startswith("/priv/packages/foobar-1.0.zip#")
+def test_nonroot_simple_index_with_x_forwarded_host(root, testapp):
+ root.join("foobar-1.0.zip").write("")
+ resp = testapp.get("/simple/foobar/", headers={"X-Forwarded-Host": "forwarded.ed/priv/"})
+ links = resp.html("a")
+ assert len(links) == 1
+ assert links[0]["href"].startswith("/priv/packages/foobar-1.0.zip#")
+
+
def test_nonroot_simple_packages(root, testpriv):
root.join("foobar-1.0.zip").write("123")
resp = testpriv.get("/priv/packages/")
@@ -308,6 +328,14 @@ def test_nonroot_simple_packages(root, testpriv):
assert links[0]["href"].startswith("/priv/packages/foobar-1.0.zip#")
+def test_nonroot_simple_packages_with_x_forwarded_host(root, testapp):
+ root.join("foobar-1.0.zip").write("123")
+ resp = testapp.get("/packages/", headers={"X-Forwarded-Host": "forwarded/priv/"})
+ links = resp.html("a")
+ assert len(links) == 1
+ assert links[0]["href"].startswith("/priv/packages/foobar-1.0.zip#")
+
+
def test_root_no_relative_paths(testpriv):
"""https://github.com/pypiserver/pypiserver/issues/25"""
resp = testpriv.get("/priv/")