Merge "Make novnc test compatible with RFB3.3"
This commit is contained in:
commit
74c14ae82c
@ -87,29 +87,48 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
|||||||
'Token must be invalid because the connection '
|
'Token must be invalid because the connection '
|
||||||
'closed.')
|
'closed.')
|
||||||
# Parse the RFB version from the data to make sure it is valid
|
# Parse the RFB version from the data to make sure it is valid
|
||||||
# and greater than or equal to 3.3
|
# and belong to the known supported RFB versions.
|
||||||
version = float("%d.%d" % (int(data[4:7], base=10),
|
version = float("%d.%d" % (int(data[4:7], base=10),
|
||||||
int(data[8:11], base=10)))
|
int(data[8:11], base=10)))
|
||||||
self.assertTrue(version >= 3.3, 'Bad RFB Version: ' + str(version))
|
# Add the max RFB versions supported
|
||||||
# Send our RFB version to the server, which we will just go with 3.3
|
supported_versions = [3.3, 3.8]
|
||||||
|
self.assertIn(version, supported_versions,
|
||||||
|
'Bad RFB Version: ' + str(version))
|
||||||
|
# Send our RFB version to the server
|
||||||
self._websocket.send_frame(data)
|
self._websocket.send_frame(data)
|
||||||
# Get the sever authentication type and make sure None is supported
|
# Get the sever authentication type and make sure None is supported
|
||||||
data = self._websocket.receive_frame()
|
data = self._websocket.receive_frame()
|
||||||
self.assertIsNotNone(data, 'Expected authentication type None.')
|
self.assertIsNotNone(data, 'Expected authentication type None.')
|
||||||
|
data_length = len(data)
|
||||||
|
if version == 3.3:
|
||||||
|
# For RFB 3.3: in the security handshake, rather than a two-way
|
||||||
|
# negotiation, the server decides the security type and sends a
|
||||||
|
# single word(4 bytes).
|
||||||
|
self.assertEqual(
|
||||||
|
data_length, 4, 'Expected authentication type None.')
|
||||||
|
self.assertIn(1, [ord_func(data[i]) for i in (0, 3)],
|
||||||
|
'Expected authentication type None.')
|
||||||
|
else:
|
||||||
self.assertGreaterEqual(
|
self.assertGreaterEqual(
|
||||||
len(data), 2, 'Expected authentication type None.')
|
len(data), 2, 'Expected authentication type None.')
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
1, [ord_func(data[i + 1]) for i in range(ord_func(data[0]))],
|
1,
|
||||||
|
[ord_func(data[i + 1]) for i in range(ord_func(data[0]))],
|
||||||
'Expected authentication type None.')
|
'Expected authentication type None.')
|
||||||
# Send to the server that we only support authentication type None
|
# Send to the server that we only support authentication
|
||||||
|
# type None
|
||||||
self._websocket.send_frame(six.int2byte(1))
|
self._websocket.send_frame(six.int2byte(1))
|
||||||
# The server should send 4 bytes of 0's if security handshake succeeded
|
|
||||||
|
# The server should send 4 bytes of 0's if security
|
||||||
|
# handshake succeeded
|
||||||
data = self._websocket.receive_frame()
|
data = self._websocket.receive_frame()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(data), 4, 'Server did not think security was successful.')
|
len(data), 4,
|
||||||
|
'Server did not think security was successful.')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[ord_func(i) for i in data], [0, 0, 0, 0],
|
[ord_func(i) for i in data], [0, 0, 0, 0],
|
||||||
'Server did not think security was successful.')
|
'Server did not think security was successful.')
|
||||||
|
|
||||||
# Say to leave the desktop as shared as part of client initialization
|
# Say to leave the desktop as shared as part of client initialization
|
||||||
self._websocket.send_frame(six.int2byte(1))
|
self._websocket.send_frame(six.int2byte(1))
|
||||||
# Get the server initialization packet back and make sure it is the
|
# Get the server initialization packet back and make sure it is the
|
||||||
|
Loading…
Reference in New Issue
Block a user