Commit 75ecdc6a authored by Łukasz Nowak's avatar Łukasz Nowak

rapid-cdn: c->h: Implement type:notebook

It's just type:websocket without any path and with transparent parameter,
thus resulting with providing X-Real-Ip to the backend.
parent c84bfc34
......@@ -38,7 +38,7 @@ md5sum = cba4d995962f7fbeae3f61c9372c4181
[template-frontend-haproxy-configuration]
_update_hash_filename_ = templates/frontend-haproxy.cfg.in
md5sum = 1777541cb76d1e3982a4b19bef8b2d55
md5sum = e6028533463b9da84c122ceb22ee0423
[template-frontend-haproxy-crt-list]
_update_hash_filename_ = templates/frontend-haproxy-crt-list.in
......
......@@ -124,6 +124,12 @@ backend {{ slave_instance['slave_reference'] }}-{{ scheme }}
{%- if slave_instance['prefer-gzip-encoding-to-backend'] %}
http-request set-header Accept-Encoding gzip if { hdr(Accept-Encoding) -m sub gzip }
{%- endif %}
{%- if slave_instance['type'] == 'notebook' %}
{#- In haproxy world type:notebook is simple type:websocket with default parameters #}
{%- do slave_instance.__setitem__('type', 'websocket') %}
{%- do slave_instance.__setitem__('websocket-path-list', None) %}
{%- do slave_instance.__setitem__('websocket-transparent', True) %}
{%- endif %}
{%- if slave_instance['type'] == 'websocket' %}
{%- if slave_instance['websocket-path-list'] %}
{%- set acl_entry = ['acl is_websocket '] %}
......
......@@ -3271,29 +3271,35 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
)
def test_type_notebook(self):
# CDN's type:notebook in haproxy world is simply like type:websocket on
# default parameters, so test has been adapted
# generally, websocket is possible to be served on any path, which is
# haproxy default
parameter_dict = self.assertSlaveBase('type-notebook')
result = fakeHTTPSResult(
parameter_dict['domain'],
'test-path',
HTTPS_PORT)
parameter_dict['domain'], 'test-path',
headers={'Connection': 'Upgrade'})
self.assertEqual(
self.certificate_pem,
der2pem(result.peercert))
self.assertEqualResultJson(result, 'Path', '/test-path')
result = fakeHTTPSResult(
parameter_dict['domain'],
'test/terminals/websocket/test',
HTTPS_PORT)
self.assertEqualResultJson(
result,
'Path',
'/test-path'
)
try:
j = result.json()
except Exception:
raise ValueError('JSON decode problem in:\n%s' % (result.text,))
self.assertBackendHeaders(j['Incoming Headers'], parameter_dict['domain'])
self.assertEqual(
self.certificate_pem,
der2pem(result.peercert))
self.assertEqualResultJson(result, 'Path', '/terminals/websocket')
'Upgrade',
j['Incoming Headers']['connection']
)
self.assertTrue('x-real-ip' in j['Incoming Headers'])
self.assertFalse(
isHTTP2(parameter_dict['domain']))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment