change test
This commit is contained in:
@@ -3,13 +3,9 @@
|
||||
'''
|
||||
from twisted.internet import protocol
|
||||
from rdpy.network.type import String, UInt8, UInt16Be, UInt32Be
|
||||
from rdpy.network.layer import RawLayer
|
||||
from rdpy.network.layer import RawLayer, LayerMode
|
||||
from message import *
|
||||
|
||||
class ProtocolMode(object):
|
||||
CLIENT = 0
|
||||
SERVER = 1
|
||||
|
||||
class Rfb(RawLayer):
|
||||
'''
|
||||
implements rfb protocol
|
||||
@@ -18,15 +14,10 @@ class Rfb(RawLayer):
|
||||
def __init__(self, mode):
|
||||
'''
|
||||
constructor
|
||||
mode can be only client or server mode
|
||||
in this RDPY version only client mode is supported
|
||||
@param mode: ProtocolMode.CLIENT | ProtocolMode.SERVER
|
||||
'''
|
||||
RawLayer.__init__(self)
|
||||
RawLayer.__init__(self, mode)
|
||||
#usefull for rfb protocol
|
||||
self._callbackBody = None
|
||||
#mode of automata
|
||||
self._mode = mode
|
||||
#protocol version negociated
|
||||
self._version = ProtocolVersion.RFB003008
|
||||
#nb security launch by server
|
||||
@@ -91,7 +82,7 @@ class Rfb(RawLayer):
|
||||
in Client mode -> wait protocol version
|
||||
in Server mode -> send protocol version
|
||||
'''
|
||||
if self._mode == ProtocolMode.CLIENT:
|
||||
if self._mode == LayerMode.CLIENT:
|
||||
self.expect(12, self.recvProtocolVersion)
|
||||
else:
|
||||
self.send(self._version)
|
||||
|
||||
@@ -3,10 +3,14 @@ Created on 4 sept. 2013
|
||||
|
||||
@author: sylvain
|
||||
'''
|
||||
|
||||
import sys, os
|
||||
# Change path so we find rdpy
|
||||
sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
||||
|
||||
from rdpy.protocol.rdp import rdp
|
||||
from rdpy.network.layer import LayerMode
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from twisted.internet import reactor
|
||||
#reactor.connectTCP("127.0.0.1", 5901, factory.RfbFactory(protocol))
|
||||
|
||||
@@ -66,102 +66,18 @@ class TypeCase(unittest.TestCase):
|
||||
self.assertRaises(Exception, s.readType, TestType(conditional = lambda:False))
|
||||
|
||||
|
||||
def test_sizeof_uint8_conditional_true(self):
|
||||
def test_sizeof_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of UInt8 is 1 when type is conditional true
|
||||
test if sizeof of simple type is init value(4) when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt8(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 1, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint8_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of UInt8 is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt8(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint16Le_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint16Le is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt16Le(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 2, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint16Le_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint16Le is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt16Le(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint16Be_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint16Be is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt16Be(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 2, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint16Be_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint16Be is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt16Be(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint24Le_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint24Le is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt24Le(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 3, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint24Le_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint24Le is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt24Le(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint24Be_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint24Be is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt24Be(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 3, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint24Be_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint24Be is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt24Be(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint32Le_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint32Le is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt32Le(conditional = lambda:True)
|
||||
v = rdpy.network.type.SimpleType("I", 4, False, 0, conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 4, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint32Le_conditional_false(self):
|
||||
def test_sizeof_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint32Le is 1 when type is conditional false
|
||||
test if sizeof of simple type is 0 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt32Le(conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint32Be_conditional_true(self):
|
||||
'''
|
||||
test if sizeof of uint32Be is 1 when type is conditional true
|
||||
'''
|
||||
v = rdpy.network.type.UInt32Be(conditional = lambda:True)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 4, "invalid sizeof")
|
||||
|
||||
def test_sizeof_uint32Be_conditional_false(self):
|
||||
'''
|
||||
test if sizeof of uint32Be is 1 when type is conditional false
|
||||
'''
|
||||
v = rdpy.network.type.UInt32Be(conditional = lambda:False)
|
||||
v = rdpy.network.type.SimpleType("I", 4, False, 0, conditional = lambda:False)
|
||||
self.assertEqual(rdpy.network.type.sizeof(v), 0, "invalid sizeof")
|
||||
|
||||
def test_sizeof_list(self):
|
||||
|
||||
@@ -10,6 +10,7 @@ sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
||||
from PyQt4 import QtGui
|
||||
from rdpy.display.qt import RfbAdaptor, QRemoteDesktop
|
||||
from rdpy.protocol.rfb import rfb
|
||||
from rdpy.network.layer import LayerMode
|
||||
|
||||
if __name__ == '__main__':
|
||||
#create application
|
||||
@@ -20,12 +21,12 @@ if __name__ == '__main__':
|
||||
qt4reactor.install()
|
||||
|
||||
#create rfb protocol
|
||||
factory = rfb.Factory(rfb.ProtocolMode.CLIENT)
|
||||
factory = rfb.Factory(LayerMode.CLIENT)
|
||||
w = QRemoteDesktop(RfbAdaptor(factory._protocol))
|
||||
w.resize(1000, 700)
|
||||
w.setWindowTitle('vncclient')
|
||||
w.show()
|
||||
from twisted.internet import reactor
|
||||
reactor.connectTCP("127.0.0.1", 5901, factory)
|
||||
reactor.connectTCP("127.0.0.1", 5903, factory)
|
||||
reactor.run()
|
||||
sys.exit(app.exec_())
|
||||
Reference in New Issue
Block a user