Beispiel #1
0
    def test_x224_server_recvConnectionRequest_client_accept_ssl(self):
        """
        @summary:  unit test for X224Server.recvConnectionRequest function
                    test client doesn't support TLS case
        """
        class Transport(object):
            def send(self, data):
                if not isinstance(data, x224.ServerConnectionConfirm):
                    raise X224Test.X224_FAIL()
                if data.protocolNeg.code.value != x224.NegociationType.TYPE_RDP_NEG_FAILURE or data.protocolNeg.failureCode.value != x224.NegotiationFailureCode.SSL_REQUIRED_BY_SERVER:
                    raise X224Test.X224_FAIL()

            def close(self):
                raise X224Test.X224_PASS()

        message = x224.ClientConnectionRequestPDU()
        message.protocolNeg.selectedProtocol.value = x224.Protocols.PROTOCOL_HYBRID
        s = type.Stream()
        s.writeType(message)
        s.pos = 0

        layer = x224.Server(None, "key", "cert", True)
        layer._transport = Transport()
        layer.connect()

        self.assertRaises(X224Test.X224_PASS, layer.recv, s)
Beispiel #2
0
            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()
Beispiel #3
0
    def test_x224_server_recvConnectionRequest_valid(self):
        """
        @summary:  unit test for X224Server.recvConnectionRequest function
        """
        global tls, connect_event
        tls = False
        connect_event = False

        class ServerTLSContext(object):
            def __init__(self, key, cert):
                pass

        x224.ServerTLSContext = ServerTLSContext

        class Transport(object):
            def __init__(self):
                class TLS(object):
                    def startTLS(self, context):
                        global tls
                        tls = True

                self.transport = TLS()

            def send(self, data):
                if not isinstance(data, x224.ServerConnectionConfirm):
                    raise X224Test.X224_FAIL()
                if data.protocolNeg.code.value != x224.NegociationType.TYPE_RDP_NEG_RSP or data.protocolNeg.selectedProtocol.value != x224.Protocols.PROTOCOL_SSL:
                    raise X224Test.X224_FAIL()

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

        message = x224.ClientConnectionRequestPDU()
        message.protocolNeg.selectedProtocol.value = x224.Protocols.PROTOCOL_SSL | x224.Protocols.PROTOCOL_RDP
        s = type.Stream()
        s.writeType(message)
        s.pos = 0

        layer = x224.Server(Presentation(), "key", "cert")
        layer._transport = Transport()
        layer.connect()
        layer.recvConnectionRequest(s)

        self.assertTrue(tls, "TLS not started")
        self.assertTrue(connect_event, "connect event not forwarded")