Skip to content

Commit 49e04f8

Browse files
committed
haproxy: T8931: Add simple smoketest for websocket backend
1 parent 607208c commit 49e04f8

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

smoketest/scripts/cli/test_load-balancing_haproxy.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,34 @@ def test_reverse_proxy_backend_ssl_no_verify(self):
335335
with self.assertRaises(ConfigSessionError) as e:
336336
self.cli_commit()
337337

338+
def test_reverse_proxy_backend_websocket(self):
339+
t_tunnel = '3600'
340+
opt_server_close = 'http-server-close'
341+
342+
# Setup base
343+
self.configure_pki()
344+
self.base_config()
345+
346+
# Set minimal backend websocket configuration
347+
self.cli_set(base_path + ['backend', haproxy_backend_name, opt_server_close])
348+
self.cli_set(base_path + ['backend', haproxy_backend_name, 'timeout', 'tunnel', t_tunnel])
349+
self.cli_set(base_path + ['backend', haproxy_backend_name, 'ssl', 'no-verify'])
350+
351+
self.cli_commit()
352+
353+
# Ensure 'http-server-close' is not used in tcp mode, to test config validation
354+
self.cli_set(base_path + ['backend', haproxy_backend_name, 'mode', 'tcp'])
355+
with self.assertRaises(ConfigSessionError) as e:
356+
self.cli_commit()
357+
358+
config = read_file(HAPROXY_CONF)
359+
self.assertIn(f'option {opt_server_close}', config)
360+
self.assertIn(f'timeout tunnel {t_tunnel}s', config)
361+
self.assertIn('option forwardfor', config)
362+
self.assertIn(' http-request set-header X-Forwarded-Port %[dst_port]', config)
363+
self.assertIn('http-request add-header X-Forwarded-Proto https if { ssl_fc }', config)
364+
self.assertIn(f'server {haproxy_backend_name} 192.0.2.11:9090 send-proxy ssl verify none', config)
365+
338366
def test_reverse_proxy_backend_http_check(self):
339367
# Setup base
340368
self.base_config()

0 commit comments

Comments
 (0)