summaryrefslogtreecommitdiff
path: root/smoketest
diff options
context:
space:
mode:
authorAlex W <embezzle.dev@proton.me>2024-05-21 23:25:06 +0100
committerAlex W <embezzle.dev@proton.me>2024-05-21 23:25:06 +0100
commite1450096b4c667a4c33a3fcd8f67ebf6a39d441d (patch)
tree5c503636e7e8a31176341f560dfdff9a17734b8e /smoketest
parentbc345404b411ac066383e796936de704078787b2 (diff)
downloadvyos-1x-e1450096b4c667a4c33a3fcd8f67ebf6a39d441d.tar.gz
vyos-1x-e1450096b4c667a4c33a3fcd8f67ebf6a39d441d.zip
reverse-proxy: T6370: Set custom HTTP headers in reverse-proxy responses
Diffstat (limited to 'smoketest')
-rwxr-xr-xsmoketest/scripts/cli/test_load-balancing_reverse-proxy.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py b/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
index c8b17316f..370a9276a 100755
--- a/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
+++ b/smoketest/scripts/cli/test_load-balancing_reverse-proxy.py
@@ -385,5 +385,26 @@ class TestLoadBalancingReverseProxy(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'mode {mode}', config)
self.assertIn(f'server {bk_name} {bk_server}:{bk_server_port}', config)
+ def test_07_lb_reverse_proxy_http_response_headers(self):
+ # Setup base
+ self.configure_pki()
+ self.base_config()
+
+ # Set example headers in both frontend and backend
+ self.cli_set(base_path + ['service', 'https_front', 'http-response-headers', 'Cache-Control', 'value', 'max-age=604800'])
+ self.cli_set(base_path + ['backend', 'bk-01', 'http-response-headers', 'Proxy-Backend-ID', 'value', 'bk-01'])
+ self.cli_commit()
+
+ # Test headers are present in generated configuration file
+ config = read_file(HAPROXY_CONF)
+ self.assertIn('http-response set-header Cache-Control \'max-age=604800\'', config)
+ self.assertIn('http-response set-header Proxy-Backend-ID \'bk-01\'', config)
+
+ # Test setting alongside modes other than http is blocked by validation conditions
+ self.cli_set(base_path + ['service', 'https_front', 'mode', 'tcp'])
+ with self.assertRaises(ConfigSessionError) as e:
+ self.cli_commit()
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)