Fix noVNC console access for an IPv6 setup
Following a recent change in websocket proxy code
(commit: fdb73a2d44
),
novnc console access is not working for IPv6 addresses.
This patch fixes the issue by taking into account the way
IPv6 urls are constructed and parsing them accordingly.
Closes-Bug: #1456963
Change-Id: Ia6c50be1e3cbe8a21f0a75b6a7cebd1712d311f8
This commit is contained in:
parent
93811b5ee2
commit
7d5cddf3e4
|
@ -100,7 +100,10 @@ class NovaProxyRequestHandlerBase(object):
|
|||
expected_origin_hostname = self.headers.getheader('Host')
|
||||
if ':' in expected_origin_hostname:
|
||||
e = expected_origin_hostname
|
||||
expected_origin_hostname = e.split(':')[0]
|
||||
if '[' in e and ']' in e:
|
||||
expected_origin_hostname = e.split(']')[0][1:]
|
||||
else:
|
||||
expected_origin_hostname = e.split(':')[0]
|
||||
origin_url = self.headers.getheader('Origin')
|
||||
# missing origin header indicates non-browser client which is OK
|
||||
if origin_url is not None:
|
||||
|
|
|
@ -46,6 +46,16 @@ class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase):
|
|||
else:
|
||||
return
|
||||
|
||||
def _fake_getheader_ipv6(self, header):
|
||||
if header == 'cookie':
|
||||
return 'token="123-456-789"'
|
||||
elif header == 'Origin':
|
||||
return 'https://[2001:db8::1]:6080'
|
||||
elif header == 'Host':
|
||||
return '[2001:db8::1]:6080'
|
||||
else:
|
||||
return
|
||||
|
||||
def _fake_getheader_bad_token(self, header):
|
||||
if header == 'cookie':
|
||||
return 'token="XXX"'
|
||||
|
@ -114,6 +124,24 @@ class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase):
|
|||
self.wh.socket.assert_called_with('node1', 10000, connect=True)
|
||||
self.wh.do_proxy.assert_called_with('<socket>')
|
||||
|
||||
@mock.patch('nova.consoleauth.rpcapi.ConsoleAuthAPI.check_token')
|
||||
def test_new_websocket_client_ipv6_url(self, check_token):
|
||||
check_token.return_value = {
|
||||
'host': 'node1',
|
||||
'port': '10000',
|
||||
'console_type': 'novnc',
|
||||
'access_url': 'https://[2001:db8::1]:6080'
|
||||
}
|
||||
self.wh.socket.return_value = '<socket>'
|
||||
self.wh.path = "http://[2001:db8::1]/?token=123-456-789"
|
||||
self.wh.headers.getheader = self._fake_getheader_ipv6
|
||||
|
||||
self.wh.new_websocket_client()
|
||||
|
||||
check_token.assert_called_with(mock.ANY, token="123-456-789")
|
||||
self.wh.socket.assert_called_with('node1', 10000, connect=True)
|
||||
self.wh.do_proxy.assert_called_with('<socket>')
|
||||
|
||||
@mock.patch('nova.consoleauth.rpcapi.ConsoleAuthAPI.check_token')
|
||||
def test_new_websocket_client_token_invalid(self, check_token):
|
||||
check_token.return_value = False
|
||||
|
|
Loading…
Reference in New Issue