You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2018/03/20 08:02:21 UTC

[2/4] qpid-proton git commit: PROTON-1589: [C++ binding] Test no reconnect on authentication failure

PROTON-1589: [C++ binding] Test no reconnect on authentication failure


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9c43d2f3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9c43d2f3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9c43d2f3

Branch: refs/heads/master
Commit: 9c43d2f36bf999e59a369e903e704bcb7c952203
Parents: 0737e42
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Mar 20 03:27:42 2018 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Mar 20 03:29:48 2018 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/reconnect_test.cpp | 50 +++++++++++++++++++++++
 1 file changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c43d2f3/proton-c/bindings/cpp/src/reconnect_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_test.cpp b/proton-c/bindings/cpp/src/reconnect_test.cpp
index 23acc73..f29cd53 100644
--- a/proton-c/bindings/cpp/src/reconnect_test.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_test.cpp
@@ -115,6 +115,12 @@ class server_connection_handler : public proton::messaging_handler {
     void on_connection_close(proton::connection & c) PN_CPP_OVERRIDE {
         done_ = true;
     }
+
+    void on_transport_error(proton::transport & ) PN_CPP_OVERRIDE {
+        // If we get an error then (try to) stop the listener
+        // - this will stop the listener if we didn't already accept a connection
+        listener_.stop();
+    }
 };
 
 class tester : public proton::messaging_handler, public waiter {
@@ -201,10 +207,54 @@ int test_stop_reconnect() {
     return 0;
 }
 
+class authfail_reconnect_tester : public proton::messaging_handler, public waiter {
+  public:
+    authfail_reconnect_tester() :
+        waiter(1), container_(*this, "authfail_reconnect_tester"), errored_(false)
+    {}
+
+    void deferred_stop() {
+        container_.stop();
+    }
+
+    void on_container_start(proton::container& c) PN_CPP_OVERRIDE {
+        // This server won't fail in this test
+        s1.reset(new server_connection_handler(c, 100, *this));
+        c.schedule(proton::duration::SECOND, proton::make_work(&authfail_reconnect_tester::deferred_stop, this));
+    }
+
+    void on_transport_error(proton::transport& t) PN_CPP_OVERRIDE {
+        errored_ = true;
+    }
+
+    void ready() PN_CPP_OVERRIDE {
+        proton::connection_options co;
+        co.sasl_allowed_mechs("PLAIN");
+        co.reconnect(proton::reconnect_options());
+        container_.connect(s1->url(), co);
+    }
+
+    void run() {
+        container_.run();
+        ASSERT(errored_);
+    }
+
+  private:
+    proton::container container_;
+    proton::internal::pn_unique_ptr<server_connection_handler> s1;
+    bool errored_;
+};
+
+int test_auth_fail_reconnect() {
+    authfail_reconnect_tester().run();
+    return 0;
+}
+
 int main(int argc, char** argv) {
     int failed = 0;
     RUN_ARGV_TEST(failed, test_failover_simple());
     RUN_ARGV_TEST(failed, test_stop_reconnect());
+    RUN_ARGV_TEST(failed, test_auth_fail_reconnect());
     return failed;
 }
 


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