'Test that the transport disconnects when it receives a bad version.'

def test_badVersion(self):

    def testBad(version):
        self.packets = []
        self.proto.gotVersion = False
        disconnected = [False]
        def stubLoseConnection():
            disconnected[0] = True
        self.transport.loseConnection = stubLoseConnection
        for c in iterbytes((version + '\r\n')):
            self.proto.dataReceived(c)
        self.assertTrue(disconnected[0])
        self.assertEqual(self.packets[0][0], transport.MSG_DISCONNECT)
        self.assertEqual(self.packets[0][1][3:4], chr(transport.DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED))
    testBad('SSH-1.5-OpenSSH')
    testBad('SSH-3.0-Twisted')
    testBad('GET    /    HTTP/1.1')
