コード例 #1
0
    def setUp(self):
        class Cnx(object):
            def queue_buffer(self, pkts):
                for p in pkts:
                    self.buf.append(p)

            def __init__(self):
                self.buf = deque()

            def recv(self):
                try:
                    buf = self.buf.popleft()
                    if buf[4] == '\xff':
                        errors.raise_error(buf)
                    else:
                        return buf
                except IndexError:
                    pass

            def send(self, buf, pktnr=None):
                pass

            def open_connection(self):
                pass

        self.cnx = Cnx()
        self.prtcl = protocol.MySQLProtocol(self.cnx)
コード例 #2
0
 def test_handshake(self):
     """lp:524668 Error in server handshake with latest code"""
     
     handshake = '\x47\x00\x00\x00\x0a\x35\x2e\x30\x2e\x33\x30\x2d\x65'\
         '\x6e\x74\x65\x72\x70\x72\x69\x73\x65\x2d\x67\x70\x6c\x2d\x6c\x6f'\
         '\x67\x00\x09\x01\x00\x00\x68\x34\x69\x36\x6f\x50\x21\x4f\x00'\
         '\x2c\xa2\x08\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\
         '\x00\x00\x4c\x6e\x67\x39\x26\x50\x44\x40\x57\x72\x59\x48\x00'
     
     p = protocol.MySQLProtocol()
     try:
         p.parse_handshake(handshake)
     except:
         raise
         self.fail("Failed handling handshake")
コード例 #3
0
ファイル: test_bugs.py プロジェクト: bopopescu/CBAcrawler
    def test_handshake(self):
        """lp:524668 MySQL Version strings with non-digits"""

        handshake = b'\x47\x00\x00\x00\x0a\x35\x2e\x30\x2e\x33\x30\x2d\x65'\
            b'\x6e\x74\x65\x72\x70\x72\x69\x73\x65\x2d\x67\x70\x6c\x2d\x6c\x6f'\
            b'\x67\x00\x09\x01\x00\x00\x68\x34\x69\x36\x6f\x50\x21\x4f\x00'\
            b'\x2c\xa2\x08\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\
            b'\x00\x00\x4c\x6e\x67\x39\x26\x50\x44\x40\x57\x72\x59\x48\x00'

        p = protocol.MySQLProtocol()
        try:
            p.parse_handshake(handshake)
        except:
            raise
            self.fail("Failed handling handshake")
コード例 #4
0
 def setUp(self):
     self._protocol = protocol.MySQLProtocol()