예제 #1
0
 def test_stop(self):
     s = self._socket()
     c = Connection(s)
     c.stop()
     # no packets should ever be returned after stoping
     # and it should return instantly
     eq_(list(c.packets()), [])
예제 #2
0
    def test_send_packet_escaping(self):
        stream = six.BytesIO()
        c = Connection(stream)

        c.send_packet(1, """"Hello World""" "")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\x0f"\\"Hello World"'))
예제 #3
0
 def test_stop(self):
     s = self._socket()
     c = Connection(s)
     c.stop()
     # no packets should ever be returned after stoping
     # and it should return instantly
     eq_(list(c.packets()), [])
예제 #4
0
    def test_send_packet_escaping(self):
        stream = six.BytesIO()
        c = Connection(stream)

        c.send_packet(1, """"Hello World""""")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\x0f"\\"Hello World"'))
예제 #5
0
    def test_send_packet(self):
        stream = six.BytesIO()

        c = Connection(stream)

        c.send_packet(1, "Hello World")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\r"Hello World"'))
예제 #6
0
    def test_send_packet(self):
        stream = six.BytesIO()

        c = Connection(stream)

        c.send_packet(1, "Hello World")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\r"Hello World"'))
예제 #7
0
    def test_packets(self):
        s, stream = self._with_data(self._dummy_msg)

        c = Connection(s)

        kind, body = six.next(c.packets())

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(self._dummy_msg))
예제 #8
0
    def test_wrong_version(self):
        # Just a header, just reading the invalid
        # number causes an exception.
        # Version = 99, type = 1 len= 5
        msg = six.b('c\x01\x00\x00\x00\x00\x00\x05')
        s, stream = self._with_data(msg)

        c = Connection(s)

        c.read_packet()
예제 #9
0
    def test_packets(self):
        s, stream = self._with_data(self._dummy_msg)

        c = Connection(s)

        kind, body = six.next(c.packets())

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(self._dummy_msg))
예제 #10
0
    def test_wrong_version(self):
        # Just a header, just reading the invalid
        # number causes an exception.
        # Version = 99, type = 1 len= 5
        msg = six.b('c\x01\x00\x00\x00\x00\x00\x05')
        s, stream = self._with_data(msg)

        c = Connection(s)

        c.read_packet()
예제 #11
0
    def test_read_packet(self):
        s = self._socket()
        # Version = 1, type = 't', len = 31
        msg = self._dummy_msg

        s, stream = self._with_data(msg)

        c = Connection(s)

        kind, body = c.read_packet()

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(msg))
예제 #12
0
    def test_read_packet(self):
        s = self._socket()
        # Version = 1, type = 't', len = 31
        msg = self._dummy_msg

        s, stream = self._with_data(msg)

        c = Connection(s)

        kind, body = c.read_packet()

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(msg))
예제 #13
0
    def test_start_with_socket(self):
        import gevent.socket as s
        mck = Mock(spec=s.socket)

        c = Connection(mck)

        mck.makefile.assert_called_once()
예제 #14
0
    def _start(self):
        serv, cli, clifd = get_sockets()
        secret = "__NO_AUTH__"
        if self._secured:  # pragma: nocover
            raise RuntimeError("Secure connections are not supported yet")

        self._proc = open_process(clifd, secret)
        self._con = Connection(serv)
        self._proto = Protocol(self._con,
                               None if not self._secured else secret)
        self._proto.start()
예제 #15
0
    def test_no_packets(self):
        s = self._socket()
        s.closed = True
        c = Connection(s)

        six.next(c.packets())
예제 #16
0
    def test_no_packets(self):
        s = self._socket()
        s.closed = True
        c = Connection(s)

        six.next(c.packets())