From 82b6aebee79e3a4709268a45861069cb87b3f96a Mon Sep 17 00:00:00 2001 From: Alex Savatieiev Date: Wed, 28 Mar 2018 17:56:49 +0200 Subject: [PATCH] VNC harcoded server name removed VNC server can be other than WebSockify, so there is a need to configure it once in a while for various deployments - added config option - updated test Change-Id: I938bae347eaa9fcf76e4118188b325ba6d3efa77 Closes-Bug: #1748339 --- ...-server-name-removed-6f8d1e90a175dc08.yaml | 10 +++++++++ tempest/api/compute/servers/test_novnc.py | 21 ++++++++++++++----- tempest/config.py | 4 ++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/vnc-hardcoded-server-name-removed-6f8d1e90a175dc08.yaml diff --git a/releasenotes/notes/vnc-hardcoded-server-name-removed-6f8d1e90a175dc08.yaml b/releasenotes/notes/vnc-hardcoded-server-name-removed-6f8d1e90a175dc08.yaml new file mode 100644 index 0000000000..0da2ddc3d7 --- /dev/null +++ b/releasenotes/notes/vnc-hardcoded-server-name-removed-6f8d1e90a175dc08.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + New string configuration option ``vnc_server_header`` is added + to ``compute-feature-enabled`` section. It offers to provide VNC server + name that is to be expected in the responce header. For example, obvious + at hand names is 'WebSockify', 'nginx'. +fixes: + - | + Fix VNC server response header issue when it is behind reverse proxy diff --git a/tempest/api/compute/servers/test_novnc.py b/tempest/api/compute/servers/test_novnc.py index d9581e3c41..1dfd0f953b 100644 --- a/tempest/api/compute/servers/test_novnc.py +++ b/tempest/api/compute/servers/test_novnc.py @@ -151,11 +151,22 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest): self.assertTrue( self._websocket.response.startswith(b'HTTP/1.1 101 Switching ' b'Protocols\r\n'), - 'Did not get the expected 101 on the websockify call: ' - + six.text_type(self._websocket.response)) - self.assertTrue( - self._websocket.response.find(b'Server: WebSockify') > 0, - 'Did not get the expected WebSocket HTTP Response.') + 'Did not get the expected 101 on the {} call: {}'.format( + CONF.compute_feature_enabled.vnc_server_header, + six.text_type(self._websocket.response) + ) + ) + # Since every other server type returns Headers with different case + # (for example 'nginx'), lowercase must be applied to eliminate issues. + _desired_header = "server: {0}".format( + CONF.compute_feature_enabled.vnc_server_header + ).lower() + _response = six.text_type(self._websocket.response).lower() + self.assertIn( + _desired_header, + _response, + 'Did not get the expected WebSocket HTTP Response.' + ) @decorators.idempotent_id('c640fdff-8ab4-45a4-a5d8-7e6146cbd0dc') def test_novnc(self): diff --git a/tempest/config.py b/tempest/config.py index 8a6370ac8e..f374c75700 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -404,6 +404,10 @@ ComputeFeaturesGroup = [ default=False, help='Enable VNC console. This configuration value should ' 'be same as [nova.vnc]->vnc_enabled in nova.conf'), + cfg.StrOpt('vnc_server_header', + default='WebSockify', + help='Expected VNC server name (WebSockify, nginx, etc) ' + 'in response header.'), cfg.BoolOpt('spice_console', default=False, help='Enable Spice console. This configuration value should '