Bug 1414882 - Add handshake to Marionette client. r=ato
authorHenrik Skupin <mail@hskupin.info>
Wed, 08 Nov 2017 15:26:50 +0100
changeset 444545 1843a786310a24d555f2cd5083ac94c667685325
parent 444544 065dbcb0a21d4b656edc75c0fb45dd0e900caa18
child 444546 b453363d696813572e8305a73e1f2432d7047891
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1414882
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414882 - Add handshake to Marionette client. r=ato A connection to Marionette server should only be accepted if the application type equals to 'gecko', and the protocol version as returned is supported by the client. MozReview-Commit-ID: LjZCsL4dt8Y
testing/marionette/client/marionette_driver/transport.py
--- a/testing/marionette/client/marionette_driver/transport.py
+++ b/testing/marionette/client/marionette_driver/transport.py
@@ -204,18 +204,28 @@ class TcpTransport(object):
                 raw = self.receive(unmarshal=False)
         except socket.timeout:
             msg = "Connection attempt failed because no data has been received over the socket: {}"
             exc, val, tb = sys.exc_info()
 
             raise exc, msg.format(val), tb
 
         hello = json.loads(raw)
-        self.protocol = hello.get("marionetteProtocol", self.min_protocol_level)
-        self.application_type = hello.get("applicationType")
+        application_type = hello.get("applicationType")
+        protocol = hello.get("marionetteProtocol")
+
+        if application_type != "gecko":
+            raise ValueError("Application type '{}' is not supported".format(application_type))
+
+        if not isinstance(protocol, int) or protocol < self.min_protocol_level:
+            msg = "Earliest supported protocol level is '{}' but got '{}'"
+            raise ValueError(msg.format(self.min_protocol_level, protocol))
+
+        self.application_type = application_type
+        self.protocol = protocol
 
         return (self.protocol, self.application_type)
 
     def send(self, obj):
         """Send message to the remote server.  Allowed input is a
         ``Message`` instance or a JSON serialisable object.
         """
         if not self.sock: