Repository: qpid-dispatch
Updated Branches:
  refs/heads/master bbd6be1fe -> b46e5de3d


DISPATCH-883 - Prevent the router from crashing when the connection properties 
is not PN_STRING or PN_SYMBOL or PN_INTEGER. Also added a few system tests


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

Branch: refs/heads/master
Commit: b46e5de3def3b26ebe3cbb45d8c03cbe2e163598
Parents: bbd6be1
Author: Ganesh Murthy <gmur...@redhat.com>
Authored: Tue Nov 21 12:59:13 2017 -0500
Committer: Ganesh Murthy <gmur...@redhat.com>
Committed: Tue Nov 21 12:59:13 2017 -0500

----------------------------------------------------------------------
 src/router_core/agent_connection.c | 14 ++++---
 tests/system_tests_one_router.py   | 66 +++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b46e5de3/src/router_core/agent_connection.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_connection.c 
b/src/router_core/agent_connection.c
index fd7aa5d..810cbae 100644
--- a/src/router_core/agent_connection.c
+++ b/src/router_core/agent_connection.c
@@ -212,12 +212,14 @@ static void 
qdr_connection_insert_column_CT(qdr_connection_t *conn, int col, qd_
                     // We are assuming for now that all values are either 
strings or integers
                     qd_get_next_pn_data(&data, &value_string, &value_int);
 
-                    qd_compose_insert_string(body, key);
-
-                    if (value_string)
-                        qd_compose_insert_string(body, value_string);
-                    else if (value_int)
-                        qd_compose_insert_int(body, value_int);
+                    // We now have the key and the value. Do not insert the 
key or the value if key is empty
+                    if (key) {
+                        qd_compose_insert_string(body, key);
+                        if (value_string)
+                            qd_compose_insert_string(body, value_string);
+                        else if (value_int)
+                            qd_compose_insert_int(body, value_int);
+                    }
 
                 }
             }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b46e5de3/tests/system_tests_one_router.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py
index f9beed5..47cd3ef 100644
--- a/tests/system_tests_one_router.py
+++ b/tests/system_tests_one_router.py
@@ -18,14 +18,18 @@
 #
 
 import unittest
-from proton import Condition, Message, Delivery, PENDING, ACCEPTED, REJECTED, 
Url
+from proton import Condition, Message, Delivery, PENDING, ACCEPTED, REJECTED, 
Url, symbol
 from system_test import TestCase, Qdrouterd, main_module, TIMEOUT
 from proton.handlers import MessagingHandler, TransactionHandler
 from proton.reactor import Container, AtMostOnce, AtLeastOnce
 from proton.utils import BlockingConnection, SyncRequestResponse
 from qpid_dispatch.management.client import Node
 
-CONNECTION_PROPERTIES = {u'connection': u'properties', u'int_property': 6451}
+CONNECTION_PROPERTIES_UNICODE_STRING = {u'connection': u'properties', 
u'int_property': 6451}
+CONNECTION_PROPERTIES_SYMBOL = dict()
+CONNECTION_PROPERTIES_SYMBOL[symbol("connection")] = symbol("properties")
+CONNECTION_PROPERTIES_BINARY = {'client_identifier': 'policy_server'}
+
 
 class OneRouterTest(TestCase):
     """System tests involving a single router"""
@@ -1156,10 +1160,13 @@ class OneRouterTest(TestCase):
         test.run()
         self.assertTrue(test.received_error)
 
-    def test_connection_properties(self):
+    def test_connection_properties_unicode_string(self):
+        """
+        Tests connection property that is a map of unicode strings and integers
+        """
         connection = BlockingConnection(self.router.addresses[0],
                                         timeout=60,
-                                        properties=CONNECTION_PROPERTIES)
+                                        
properties=CONNECTION_PROPERTIES_UNICODE_STRING)
         client = SyncRequestResponse(connection)
 
         node = Node.connect(self.router.addresses[0])
@@ -1176,6 +1183,57 @@ class OneRouterTest(TestCase):
         self.assertTrue(found)
         client.connection.close()
 
+    def test_connection_properties_symbols(self):
+        """
+        Tests connection property that is a map of symbols
+        """
+        connection = BlockingConnection(self.router.addresses[0],
+                                        timeout=60,
+                                        
properties=CONNECTION_PROPERTIES_SYMBOL)
+        client = SyncRequestResponse(connection)
+
+        node = Node.connect(self.router.addresses[0])
+
+        results = node.query(type='org.apache.qpid.dispatch.connection', 
attribute_names=[u'properties']).results
+
+        found = False
+        for result in results:
+            if u'connection' in result[0]:
+                if result[0][u'connection'] == u'properties':
+                    found = True
+                    break
+
+        self.assertTrue(found)
+
+        client.connection.close()
+
+    def test_connection_properties_binary(self):
+        """
+        Tests connection property that is a binary map. The router ignores 
AMQP binary data type.
+        Router should not return anything for connection properties
+        """
+        connection = BlockingConnection(self.router.addresses[0],
+                                        timeout=60,
+                                        
properties=CONNECTION_PROPERTIES_BINARY)
+        client = SyncRequestResponse(connection)
+
+        node = Node.connect(self.router.addresses[0])
+
+        results = node.query(type='org.apache.qpid.dispatch.connection', 
attribute_names=[u'properties']).results
+
+        results_found = True
+
+        for result in results:
+            if not result[0]:
+                results_found = False
+            else:
+                results_found = True
+                break
+
+        self.assertFalse(results_found)
+
+        client.connection.close()
+
 
 class Timeout(object):
     def __init__(self, parent):


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

Reply via email to