diff tests/sshprotoext.py @ 36253:464bedc0fdb4

wireprotoserver: handle SSH protocol version 2 upgrade requests This commit teaches the SSH server to recognize the "upgrade" request line that clients send when they wish to switch the channel to version 2 of the SSH protocol. Servers don't honor upgrade requests unless an experimental config option is set. Since the built-in server now supports upgrade requests, our test server to test the handshake has been deleted. Existing tests use the built-in server and their output doesn't change. The upgrade is handled in our state machine. The end result is a bit wonky, as the server transitions back to version 1 state immediately after upgrading. But this will change as soon as version 2 has an actual protocol that differs from version 1. Tests demonstrating that the new server is a bit more strict about the upgrade handshake have been added. Differential Revision: https://phab.mercurial-scm.org/D2204
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 12 Feb 2018 16:33:54 -0800
parents 3b3a987bbbaa
children b4d85bc122bd
line wrap: on
line diff
--- a/tests/sshprotoext.py	Thu Feb 08 15:09:59 2018 -0800
+++ b/tests/sshprotoext.py	Mon Feb 12 16:33:54 2018 -0800
@@ -55,37 +55,6 @@
 
         super(prehelloserver, self).serve_forever()
 
-class upgradev2server(wireprotoserver.sshserver):
-    """Tests behavior for clients that issue upgrade to version 2."""
-    def serve_forever(self):
-        name = wireprotoserver.SSHV2
-        l = self._fin.readline()
-        assert l.startswith(b'upgrade ')
-        token, caps = l[:-1].split(b' ')[1:]
-        assert caps == b'proto=%s' % name
-
-        # Filter hello and between requests.
-        l = self._fin.readline()
-        assert l == b'hello\n'
-        l = self._fin.readline()
-        assert l == b'between\n'
-        l = self._fin.readline()
-        assert l == b'pairs 81\n'
-        self._fin.read(81)
-
-        # Send the upgrade response.
-        proto = wireprotoserver.sshv1protocolhandler(self._ui, self._fin,
-                                                     self._fout)
-        self._fout.write(b'upgraded %s %s\n' % (token, name))
-        servercaps = wireproto.capabilities(self._repo, proto)
-        rsp = b'capabilities: %s' % servercaps.data
-        self._fout.write(b'%d\n' % len(rsp))
-        self._fout.write(rsp)
-        self._fout.write(b'\n')
-        self._fout.flush()
-
-        super(upgradev2server, self).serve_forever()
-
 def performhandshake(orig, ui, stdin, stdout, stderr):
     """Wrapped version of sshpeer._performhandshake to send extra commands."""
     mode = ui.config(b'sshpeer', b'handshake-mode')
@@ -118,8 +87,6 @@
         wireprotoserver.sshserver = bannerserver
     elif servermode == b'no-hello':
         wireprotoserver.sshserver = prehelloserver
-    elif servermode == b'upgradev2':
-        wireprotoserver.sshserver = upgradev2server
     elif servermode:
         raise error.ProgrammingError(b'unknown server mode: %s' % servermode)