qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1514465 - in /qpid/trunk/qpid/cpp/src: qpid/broker/amqp/SaslClient.cpp qpid/broker/amqp/SaslClient.h tests/interlink_tests.py
Date Thu, 15 Aug 2013 20:10:49 GMT
Author: gsim
Date: Thu Aug 15 20:10:48 2013
New Revision: 1514465

URL: http://svn.apache.org/r1514465
Log:
QPID-5077: improvement to SASL logic to handle entirely asynchronous dialogue

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.h
    qpid/trunk/qpid/cpp/src/tests/interlink_tests.py

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp?rev=1514465&r1=1514464&r2=1514465&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp Thu Aug 15 20:10:48 2013
@@ -36,7 +36,7 @@ namespace amqp {
 SaslClient::SaslClient(qpid::sys::OutputControl& out_, const std::string& id, boost::shared_ptr<Interconnect>
c, std::auto_ptr<qpid::Sasl> s,
                        const std::string& hostname_, const std::string& mechs, const
qpid::sys::SecuritySettings& t)
     : qpid::amqp::SaslClient(id), out(out_), connection(c), sasl(s),
-      hostname(hostname_), allowedMechanisms(mechs), transport(t), readHeader(true), writeHeader(false),
haveOutput(false), state(NONE) {}
+      hostname(hostname_), allowedMechanisms(mechs), transport(t), readHeader(true), writeHeader(false),
haveOutput(false), initialised(false), state(NONE) {}
 
 SaslClient::~SaslClient()
 {
@@ -67,8 +67,10 @@ std::size_t SaslClient::encode(char* buf
          encoded += writeProtocolHeader(buffer, size);
          writeHeader = !encoded;
     }
-    if (state == NONE && encoded < size) {
-        encoded += write(buffer + encoded, size - encoded);
+    if ((!initialised || state == NONE) && encoded < size) {
+        size_t extra = write(buffer + encoded, size - encoded);
+        encoded += extra;
+        initialised = extra > 0;
     } else if (state == SUCCEEDED) {
         if (securityLayer.get()) encoded += securityLayer->encode(buffer + encoded, size
- encoded);
         else encoded += connection->encode(buffer + encoded, size - encoded);

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.h?rev=1514465&r1=1514464&r2=1514465&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/SaslClient.h Thu Aug 15 20:10:48 2013
@@ -64,6 +64,7 @@ class SaslClient : public qpid::sys::Con
     bool readHeader;
     bool writeHeader;
     bool haveOutput;
+    bool initialised;
     enum {
         NONE, FAILED, SUCCEEDED
     } state;

Modified: qpid/trunk/qpid/cpp/src/tests/interlink_tests.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/interlink_tests.py?rev=1514465&r1=1514464&r2=1514465&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/interlink_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/interlink_tests.py Thu Aug 15 20:10:48 2013
@@ -218,16 +218,22 @@ class AmqpBrokerTest(BrokerTest):
         assert len(domains) == 1
         assert domains[0].name == "BrokerB"
 
-    def test_incoming_link(self):
+    def incoming_link(self, mechanism):
         brokerB = self.amqp_broker()
         agentB = BrokerAgent(brokerB.connect())
         self.agent.create("queue", "q")
         agentB.create("queue", "q")
-        self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":"NONE"})
+        self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":mechanism})
         self.agent.create("incoming", "Link1", {"domain":"BrokerB","source":"q","target":"q"})
         #send to brokerB, receive from brokerA
         self.send_and_receive(send_config=Config(brokerB))
 
+    def test_incoming_link_anonymous(self):
+        self.incoming_link("ANONYMOUS")
+
+    def test_incoming_link_nosasl(self):
+        self.incoming_link("NONE")
+
     def test_outgoing_link(self):
         brokerB = self.amqp_broker()
         agentB = BrokerAgent(brokerB.connect())



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message