From 1ba38bff511fe056a503376ea06472bc1fe47786 Mon Sep 17 00:00:00 2001 From: index-git Date: Wed, 20 Sep 2023 15:28:18 +0200 Subject: [PATCH] Unit test for get_x_forwarded_prefix --- src/layman/util_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/layman/util_test.py b/src/layman/util_test.py index 3535f809c..3ec02cce6 100644 --- a/src/layman/util_test.py +++ b/src/layman/util_test.py @@ -134,3 +134,12 @@ def test__url_for(endpoint, internal, params, expected_url): # pylint: disable=protected-access assert util._url_for(endpoint, server_name=server_name, proxy_server_name=proxy_server_name, internal=internal, **params) == expected_url + + +@pytest.mark.parametrize('headers, exp_result', [ + pytest.param({'X-Forwarded-Prefix': '/layman-proxy'}, '/layman-proxy', id='simple_header'), + pytest.param({}, None, id='without_header'), +]) +def test_get_x_forwarded_prefix(headers, exp_result): + result = util.get_x_forwarded_prefix(headers) + assert result == exp_result