コード例 #1
0
 def setup(self):
     if not common.isSSLPresent():
         raise Skipped("No SSL libraries found.")
     self.server = Messenger()
     self.client = Messenger()
     self.server.blocking = False
     self.client.blocking = False
コード例 #2
0
    def testPipelinedClientFail(self):
        if "java" in sys.platform:
            raise Skipped("Proton-J does not support client pipelining")

        # Client
        self.s1.allowed_mechs('ANONYMOUS')
        # Server
        self.s2.allowed_mechs('PLAIN DIGEST-MD5 SCRAM-SHA-1')

        assert self.s1.outcome is None
        assert self.s2.outcome is None

        # Push client bytes into server
        out1 = self.t1.peek(1024)
        self.t1.pop(len(out1))
        self.t2.push(out1)

        out2 = self.t2.peek(1024)
        self.t2.pop(len(out2))

        assert self.s1.outcome is None

        self.t1.push(out2)

        assert self.s1.outcome == SASL.AUTH
        assert self.s2.outcome == SASL.AUTH
コード例 #3
0
        def __init__(self, domain=None, session_details=None):
            if not common.isSSLPresent():
                raise Skipped("No SSL libraries found.")

            self.ssl = None
            self.domain = domain
            self.transport = Transport()
            self.connection = Connection()
            self.transport.bind(self.connection)
            if domain:
                self.ssl = SSL(self.transport, self.domain, session_details)
コード例 #4
0
    def testIdleTimeout(self):
        """
    Verify that a Messenger connection is kept alive using empty idle frames
    when a idle_timeout is advertised by the remote peer.
    """
        if "java" in sys.platform:
            raise Skipped()
        idle_timeout_secs = self.delay

        try:
            idle_server = common.TestServerDrain(
                idle_timeout=idle_timeout_secs)
            idle_server.timeout = self.timeout
            idle_server.start()

            idle_client = Messenger("idle_client")
            idle_client.timeout = self.timeout
            idle_client.start()

            idle_client.subscribe("amqp://%s:%s/foo" %
                                  (idle_server.host, idle_server.port))
            idle_client.work(idle_timeout_secs / 10)

            # wait up to 3x the idle timeout and hence verify that everything stays
            # connected during that time by virtue of no Exception being raised
            duration = 3 * idle_timeout_secs
            deadline = time() + duration
            while time() <= deadline:
                idle_client.work(idle_timeout_secs / 10)
                continue

            # confirm link is still active
            cxtr = idle_server.driver.head_connector()
            assert not cxtr.closed, "Connector has unexpectedly been closed"
            conn = cxtr.connection
            assert conn.state == (Endpoint.LOCAL_ACTIVE
                                  | Endpoint.REMOTE_ACTIVE
                                  ), "Connection has unexpectedly terminated"
            link = conn.link_head(0)
            while link:
                assert link.state != (
                    Endpoint.REMOTE_CLOSED), "Link unexpectedly closed"
                link = link.next(0)

        finally:
            try:
                idle_client.stop()
            except:
                pass
            try:
                idle_server.stop()
            except:
                pass
コード例 #5
0
 def __init__(self, domain=None, session_details=None):
     try:
         self.ssl = None
         self.domain = domain
         self.transport = Transport()
         self.connection = Connection()
         self.transport.bind(self.connection)
         if domain:
             self.ssl = SSL(self.transport, self.domain,
                            session_details)
     except SSLUnavailable, e:
         raise Skipped(e)
コード例 #6
0
    def testSaslAndAmqpInSingleChunk(self):
        if "java" in sys.platform:
            raise Skipped("Proton-J does not support client pipelining")

        self.s1.allowed_mechs('ANONYMOUS')
        self.s2.allowed_mechs('ANONYMOUS')

        # send the server's OK to the client
        # This is still needed for the Java impl
        out2 = self.t2.peek(1024)
        self.t2.pop(len(out2))
        self.t1.push(out2)

        # do some work to generate AMQP data
        c1 = Connection()
        c2 = Connection()
        self.t1.bind(c1)
        c1._transport = self.t1
        self.t2.bind(c2)
        c2._transport = self.t2

        c1.open()

        # get all t1's output in one buffer then pass it all to t2
        out1_sasl_and_amqp = ""
        t1_still_producing = True
        while t1_still_producing:
            out1 = self.t1.peek(1024)
            self.t1.pop(len(out1))
            out1_sasl_and_amqp += out1
            t1_still_producing = out1

        t2_still_consuming = True
        while t2_still_consuming:
            num = min(self.t2.capacity(), len(out1_sasl_and_amqp))
            self.t2.push(out1_sasl_and_amqp[:num])
            out1_sasl_and_amqp = out1_sasl_and_amqp[num:]
            t2_still_consuming = num > 0 and len(out1_sasl_and_amqp) > 0

        assert len(out1_sasl_and_amqp) == 0, (len(out1_sasl_and_amqp),
                                              out1_sasl_and_amqp)

        # check that t2 processed both the SASL data and the AMQP data
        assert self.s2.outcome == SASL.OK
        assert c2.state & Endpoint.REMOTE_ACTIVE
コード例 #7
0
ファイル: messenger.py プロジェクト: datawire/qpid-proton
    def testSelectable(self, count=1):
        if os.name == "nt":
            # Conflict between native OS select() in Pump and IOCP based pn_selector_t
            # makes this fail on Windows (see PROTON-668).
            raise Skipped("Invalid test on Windows with IOCP.")

        mrcv = Messenger()
        mrcv.passive = True
        mrcv.subscribe("amqp://~0.0.0.0:1234")

        msnd = Messenger()
        msnd.passive = True
        m = Message()
        m.address = "amqp://127.0.0.1:1234"

        for i in range(count):
            m.body = u"Hello World! %s" % i
            msnd.put(m)

        p = Pump(msnd, mrcv)
        p.pump()

        assert msnd.outgoing == count
        assert mrcv.incoming == 0

        mrcv.recv()

        mc = Message()

        try:
            for i in range(count):
                while mrcv.incoming == 0:
                    p.pump()
                assert mrcv.incoming > 0, (count, msnd.outgoing, mrcv.incoming)
                mrcv.get(mc)
                assert mc.body == u"Hello World! %s" % i, (i, mc.body)
        finally:
            mrcv.stop()
            msnd.stop()
            assert not mrcv.stopped
            assert not msnd.stopped
            p.pump()
            assert mrcv.stopped
            assert msnd.stopped
コード例 #8
0
    def testPipelined2(self):
        if "java" in sys.platform:
            raise Skipped("Proton-J does not support client pipelining")

        out1 = self.t1.peek(1024)
        self.t1.pop(len(out1))
        self.t2.push(out1)

        self.s2.allowed_mechs('ANONYMOUS')
        c2 = Connection()
        c2.open()
        self.t2.bind(c2)

        out2 = self.t2.peek(1024)
        self.t2.pop(len(out2))
        self.t1.push(out2)

        out1 = self.t1.peek(1024)
        assert len(out1) > 0
コード例 #9
0
ファイル: messenger.py プロジェクト: kaffepanna/Proton
    def testIdleTimeout(self):
        """
    Verify that a Messenger connection is kept alive using empty idle frames
    when a idle_timeout is advertised by the remote peer.
    """
        if "java" in sys.platform:
            raise Skipped()
        idle_timeout_secs = self.delay

        try:
            idle_server = common.TestServer(idle_timeout=idle_timeout_secs)
            idle_server.timeout = self.timeout
            idle_server.start()

            idle_client = Messenger("idle_client")
            idle_client.timeout = self.timeout
            idle_client.start()

            idle_client.subscribe("amqp://%s:%s/foo" %
                                  (idle_server.host, idle_server.port))
            idle_client.work(idle_timeout_secs / 10)

            # wait up to 3x the idle timeout and hence verify that everything stays
            # connected during that time by virtue of no Exception being raised
            duration = 3 * idle_timeout_secs
            deadline = time() + duration
            while time() <= deadline:
                idle_client.work(idle_timeout_secs / 10)
                continue

            # confirm link is still active
            assert not idle_server.conditions, idle_server.conditions
        finally:
            try:
                idle_client.stop()
            except:
                pass
            try:
                idle_server.stop()
            except:
                pass
コード例 #10
0
 def test_server_credentials(self,
                             cert="server-certificate.pem",
                             key="server-private-key.pem",
                             password="******",
                             exception=None):
     import sys
     # java doesn't do validation in the same way (yet)
     if exception and "java" in sys.platform:
         raise Skipped()
     self.server.certificate = _testpath(cert)
     self.server.private_key = _testpath(key)
     self.server.password = password
     try:
         self.server.start()
         self.server.subscribe("amqps://~0.0.0.0:12345")
         if exception is not None:
             assert False, "expected failure did not occur"
     except MessengerException, e:
         if exception:
             assert exception in str(e), str(e)
         else:
             raise e
コード例 #11
0
 def setup(self):
     if not common.isSSLPresent():
         raise Skipped("No SSL libraries found.")
     self.server_domain = SSLDomain(SSLDomain.MODE_SERVER)
     self.client_domain = SSLDomain(SSLDomain.MODE_CLIENT)
コード例 #12
0
 def _ssl_check(self):
     if not isSSLPresent():
         raise Skipped("No SSL libraries found.")
コード例 #13
0
 def setup(self):
     try:
         self.server_domain = SSLDomain(SSLDomain.MODE_SERVER)
         self.client_domain = SSLDomain(SSLDomain.MODE_CLIENT)
     except SSLUnavailable, e:
         raise Skipped(e)