Beispiel #1
0
    def test_x224_client_connect(self):
        """
        @summary: unit test for X224Client.connect and sendConnectionRequest function
        """
        class Transport(object):
            def send(self, data):
                s = type.Stream()
                s.writeType(data)
                s.pos = 0
                t = x224.ClientConnectionRequestPDU()
                s.readType(t)

                if t.protocolNeg.code != x224.NegociationType.TYPE_RDP_NEG_REQ:
                    raise X224Test.X224_FAIL()

        def nextAutomata(data):
            raise X224Test.X224_PASS()

        layer = x224.Client(None)
        layer._transport = Transport()
        layer.recvConnectionConfirm = nextAutomata
        layer.connect()

        self.assertRaises(X224Test.X224_PASS, layer.recv,
                          type.String('\x01\x02'))
Beispiel #2
0
 def test_x224_client_recvConnectionConfirm_negotiation_failure(self):
     """
     @summary: unit test for X224Client.recvConnectionConfirm and sendConnectionRequest function
                 check negotiation failure
     """
     message = x224.ServerConnectionConfirm()
     message.protocolNeg.code.value = x224.NegociationType.TYPE_RDP_NEG_FAILURE
     s = type.Stream()
     s.writeType(message)
     s.pos = 0
     layer = x224.Client(None)
     self.assertRaises(error.RDPSecurityNegoFail, layer.recvConnectionConfirm, s)
Beispiel #3
0
 def test_x224_client_recvConnectionConfirm_negotiation_bad_protocol(self):
     """
     @summary:  unit test for X224Client.recvConnectionConfirm and sendConnectionRequest function
                 Server ask another protocol than SSL or RDP
     """
     message = x224.ServerConnectionConfirm()
     message.protocolNeg.selectedProtocol.value = x224.Protocols.PROTOCOL_HYBRID
     s = type.Stream()
     s.writeType(message)
     s.pos = 0
     layer = x224.Client(None)
     self.assertRaises(error.InvalidExpectedDataException,
                       layer.recvConnectionConfirm, s)
Beispiel #4
0
 def __init__(self):
     #list of observer
     self._clientObserver = []
     #PDU layer
     self._pduLayer = pdu_layer.Client(self)
     #secure layer
     self._secLayer = sec.Client(self._pduLayer)
     #multi channel service
     self._mcsLayer = mcs.Client(self._secLayer)
     #transport pdu layer
     self._x224Layer = x224.Client(self._mcsLayer)
     #transport packet (protocol layer)
     self._tpktLayer = tpkt.TPKT(self._x224Layer)
     #fastpath stack
     self._pduLayer.initFastPath(self._secLayer)
     self._secLayer.initFastPath(self._tpktLayer)
     #is pdu layer is ready to send
     self._isReady = False
Beispiel #5
0
    def test_x224_client_recvConnectionConfirm_ok(self):
        """
        @summary: nominal case of protocol negotiation
        """
        global tls_begin, presentation_connect
        tls_begin = False
        presentation_connect = False

        class Transport(object):
            def __init__(self):
                class TLSTransport(object):
                    def startTLS(self, context):
                        global tls_begin
                        tls_begin = True

                self.transport = TLSTransport()

        class Presentation(object):
            def connect(self):
                global presentation_connect
                presentation_connect = True

        def recvData(data):
            raise X224Test.X224_PASS()

        message = x224.ServerConnectionConfirm()
        message.protocolNeg.selectedProtocol.value = x224.Protocols.PROTOCOL_SSL

        s = type.Stream()
        s.writeType(message)
        s.pos = 0
        layer = x224.Client(Presentation())
        layer._transport = Transport()
        layer.recvData = recvData

        layer.recvConnectionConfirm(s)

        self.assertTrue(tls_begin, "TLS is not started")
        self.assertTrue(presentation_connect, "connect event is not forwarded")
        self.assertRaises(X224Test.X224_PASS, layer.recv,
                          type.String('\x01\x02'))