qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject qpid-dispatch git commit: DISPATCH-1095 - Improved SkipIfNeeded decorator and added it to methods using SASL when it is not installed. This closes #351
Date Thu, 02 Aug 2018 19:57:45 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master ecfd32527 -> a1585a9c3


DISPATCH-1095 - Improved SkipIfNeeded decorator and added it to methods using SASL when it
is not installed. This closes #351


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

Branch: refs/heads/master
Commit: a1585a9c3f3f5ed2aa34c7b95c357256aa9e534a
Parents: ecfd325
Author: Fernando Giorgetti <fgiorget@redhat.com>
Authored: Thu Aug 2 16:29:23 2018 -0300
Committer: Ganesh Murthy <gmurthy@redhat.com>
Committed: Thu Aug 2 15:55:43 2018 -0400

----------------------------------------------------------------------
 tests/system_test.py                       |  29 +++---
 tests/system_tests_auth_service_plugin.py  |  10 +--
 tests/system_tests_authz_service_plugin.py |  19 ++--
 tests/system_tests_distribution.py         | 112 ++++++++++++------------
 tests/system_tests_qdstat.py               |   5 +-
 tests/system_tests_sasl_plain.py           |  34 ++-----
 tests/system_tests_ssl.py                  |   5 +-
 7 files changed, 97 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_test.py
----------------------------------------------------------------------
diff --git a/tests/system_test.py b/tests/system_test.py
index 3159301..5cff90c 100755
--- a/tests/system_test.py
+++ b/tests/system_test.py
@@ -657,33 +657,36 @@ class SkipIfNeeded(object):
     Decorator class that can be used along with test methods
     to provide skip test behavior when using both python2.6 or
     a greater version.
-    This decorator can be used with sub-classes of TestCase and the
-    sub-class must contain a dictionary named "skip" (test_name as key
-    and 0[run] or 1[skip] as the value).
+    This decorator can be used in test methods and a boolean
+    condition must be provided (skip parameter) to define whether
+    or not the test will be skipped.
     """
-    def __init__(self, test_name, reason):
-        self.test_name = test_name
+    def __init__(self, skip, reason):
+        """
+        :param skip: if True the method wont be called
+        :param reason: reason why test was skipped
+        """
+        self.skip = skip
         self.reason = reason
 
     def __call__(self, f):
 
         def wrap(*args, **kwargs):
             """
-            Wraps original test method's invocation looking for an instance
-            attribute named "skip" (should be a dictionary composed by
-            "test_name" as a key and value of 0 [run] or 1 [skip]).
-            When running test with python < 2.7, if the "skip" dictionary
-            contains the given test_name with a value of 1, the original
-            method won't be called. If running python >= 2.7, then
+            Wraps original test method's invocation and dictates whether or
+            not the test will be executed based on value (boolean) of the
+            skip parameter.
+            When running test with python < 2.7, if the "skip" parameter is
+            true, the original method won't be called. If running python >= 2.7, then
             skipTest will be called with given "reason" and original method
             will be invoked.
             :param args:
             :return:
             """
             instance = args[0]
-            if isinstance(instance, TestCase) and hasattr(instance, "skip") and instance.skip[self.test_name]:
+            if self.skip:
                 if sys.version_info < (2, 7):
-                    print("%s -> skipping (python<2.7) ..." % self.test_name)
+                    print("%s -> skipping (python<2.7) [%s] ..." % (f.__name__, self.reason))
                     return
                 else:
                     instance.skipTest(self.reason)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_auth_service_plugin.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_auth_service_plugin.py b/tests/system_tests_auth_service_plugin.py
index 5b48e40..3cb524c 100644
--- a/tests/system_tests_auth_service_plugin.py
+++ b/tests/system_tests_auth_service_plugin.py
@@ -26,7 +26,7 @@ from __future__ import print_function
 import unittest2 as unittest
 import os
 from subprocess import PIPE, Popen
-from system_test import TestCase, Qdrouterd, main_module
+from system_test import TestCase, Qdrouterd, main_module, SkipIfNeeded
 from proton import SASL
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
@@ -88,27 +88,23 @@ sql_select: dummy select
                      ('router', {'mode': 'standalone', 'id': 'router'})
         ])).wait_ready()
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_valid_credentials(self):
         """
         Check authentication succeeds when valid credentials are presented.
 
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         test = SimpleConnect("127.0.0.1:%d" % self.router_port, 'test@domain.com', 'password')
         test.run()
         self.assertEqual(True, test.connected)
         self.assertEqual(None, test.error)
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_invalid_credentials(self):
         """
         Check authentication fails when invalid credentials are presented.
 
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         test = SimpleConnect("127.0.0.1:%d" % self.router_port, 'test@domain.com', 'foo')
         test.run()
         self.assertEqual(False, test.connected)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_authz_service_plugin.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_authz_service_plugin.py b/tests/system_tests_authz_service_plugin.py
index c3180a6..fc5e2bf 100644
--- a/tests/system_tests_authz_service_plugin.py
+++ b/tests/system_tests_authz_service_plugin.py
@@ -25,11 +25,12 @@ from __future__ import print_function
 import unittest2 as unittest
 import os, json
 from subprocess import PIPE, Popen, STDOUT
-from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process
+from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process, SkipIfNeeded
 from proton import Array, Data, Message, SASL, symbol, UNDESCRIBED
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
 
+
 class AuthServicePluginAuthzTest(TestCase):
     @classmethod
     def addUser(cls, user, password):
@@ -84,10 +85,8 @@ mech_list: SCRAM-SHA-1 PLAIN
                                  'saslConfigPath': os.getcwd()})
         ])).wait_ready()
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_authorized(self):
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         container = Container()
         client = ConnectionHandler('foo', 1)
         container.connect("guest:guest@127.0.0.1:%d" % self.router_port, handler=client)
@@ -96,10 +95,8 @@ mech_list: SCRAM-SHA-1 PLAIN
         self.assertEqual(1, client.received)
         self.assertEqual(0, len(client.errors))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_unauthorized(self):
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         container = Container()
         client = ConnectionHandler('bar', 1)
         container.connect("guest:guest@127.0.0.1:%d" % self.router_port, handler=client)
@@ -110,10 +107,8 @@ mech_list: SCRAM-SHA-1 PLAIN
         self.assertEqual('amqp:unauthorized-access', client.errors[0])
         self.assertEqual('amqp:unauthorized-access', client.errors[1])
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_wildcard(self):
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         container = Container()
         client = ConnectionHandler('whatever', 1)
         container.connect("admin:admin@127.0.0.1:%d" % self.router_port, handler=client)
@@ -122,10 +117,8 @@ mech_list: SCRAM-SHA-1 PLAIN
         self.assertEqual(1, client.received)
         self.assertEqual(0, len(client.errors))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_dynamic_source_anonymous_sender(self):
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         container = Container()
         client = DynamicSourceAnonymousSender()
         container.connect("admin:admin@127.0.0.1:%d" % self.router_port, handler=client)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_distribution.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_distribution.py b/tests/system_tests_distribution.py
index 9a2ae71..7ec33e1 100644
--- a/tests/system_tests_distribution.py
+++ b/tests/system_tests_distribution.py
@@ -92,6 +92,37 @@ class AddressCheckerTimeout ( object ):
     def on_timer_task(self, event):
         self.parent.address_check_timeout()
 
+
+class DistributionSkipMapper(object):
+    # 1 means skip that test.
+    skip = {'test_01': 0,
+            'test_02': 0,
+            'test_03': 0,
+            'test_04': 0,
+            'test_05': 0,
+            'test_06': 0,
+            'test_07': 0,
+            'test_08': 0,
+            'test_09': 0,
+            'test_10': 0,
+            'test_11': 0,
+            'test_12': 0,
+            'test_13': 0,
+            'test_14': 0,
+            'test_15': 0,
+            'test_16': 1,
+            'test_17': 1,
+            'test_18': 1,
+            'test_19': 1,
+            'test_20': 1,
+            'test_21': 1,
+            'test_22': 1,
+            'test_23': 0,
+            'test_24': 0,
+            'test_25': 0
+            }
+
+
 #------------------------------------------------
 # END Helper classes for all tests.
 #------------------------------------------------
@@ -499,37 +530,8 @@ class DistributionTests ( TestCase ):
         cls.C_addr = router_C.addresses[0]
         cls.D_addr = router_D.addresses[0]
 
-        # 1 means skip that test.
-        cls.skip = { 'test_01' : 0,
-                     'test_02' : 0,
-                     'test_03' : 0,
-                     'test_04' : 0,
-                     'test_05' : 0,
-                     'test_06' : 0,
-                     'test_07' : 0,
-                     'test_08' : 0,
-                     'test_09' : 0,
-                     'test_10' : 0,
-                     'test_11' : 0,
-                     'test_12' : 0,
-                     'test_13' : 0,
-                     'test_14' : 0,
-                     'test_15' : 0,
-                     'test_16' : 1,
-                     'test_17' : 1,
-                     'test_18' : 1,
-                     'test_19' : 1,
-                     'test_20' : 1,
-                     'test_21' : 1,
-                     'test_22' : 1,
-                     'test_23' : 0,
-                     'test_24' : 0,
-                     'test_25' : 0
-                   }
-
-
-
-    @SkipIfNeeded('test_01', 'Test skipped during development.')
+
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_01'], 'Test skipped during development.')
     def test_01_targeted_sender_AC ( self ):
         name='test_01'
         test = TargetedSenderTest ( name, self.A_addr, self.C_addr, "closest/01" )
@@ -537,7 +539,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_02', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_02'], 'Test skipped during development.')
     def test_02_targeted_sender_DC ( self ):
         name='test_02'
         test = TargetedSenderTest ( name, self.D_addr, self.C_addr, "closest/02" )
@@ -545,7 +547,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_03', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_03'], 'Test skipped during development.')
     def test_03_anonymous_sender_AC ( self ):
         name='test_03'
         test = AnonymousSenderTest ( name, self.A_addr, self.C_addr )
@@ -553,7 +555,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_04', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_04'], 'Test skipped during development.')
     def test_04_anonymous_sender_DC ( self ):
         name='test_04'
         test = AnonymousSenderTest ( name, self.D_addr, self.C_addr )
@@ -561,7 +563,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_05', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_05'], 'Test skipped during development.')
     def test_05_dynamic_reply_to_AC ( self ):
         name='test_05'
         test = DynamicReplyTo ( name, self.A_addr, self.C_addr )
@@ -569,7 +571,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_06', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_06'], 'Test skipped during development.')
     def test_06_dynamic_reply_to_DC ( self ):
         name='test_06'
         test = DynamicReplyTo ( name, self.D_addr, self.C_addr )
@@ -577,7 +579,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_07', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_07'], 'Test skipped during development.')
     def test_07_linkroute ( self ):
         name='test_07'
         test = LinkAttachRouting ( name,
@@ -591,7 +593,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_08', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_08'], 'Test skipped during development.')
     def test_08_linkroute_check_only ( self ):
         name='test_08'
         test = LinkAttachRoutingCheckOnly ( name,
@@ -605,7 +607,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_09', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_09'], 'Test skipped during development.')
     def test_09_closest_linear ( self ):
         name='test_09'
         test = ClosestTest ( name,
@@ -618,7 +620,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_10', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_10'], 'Test skipped during development.')
     def test_10_closest_mesh ( self ):
         name='test_10'
         test = ClosestTest ( name,
@@ -698,7 +700,7 @@ class DistributionTests ( TestCase ):
         #     100     55           33           12
         #
 
-    @SkipIfNeeded('test_11', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_11'], 'Test skipped during development.')
     def test_11_balanced_linear ( self ):
         name='test_11'
         # slop is how much the second two values may diverge from
@@ -730,7 +732,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_12', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_12'], 'Test skipped during development.')
     def test_12_balanced_linear_omit_middle_receiver ( self ):
         name='test_12'
         # If we omit the middle receiver, then router A will count
@@ -826,7 +828,7 @@ class DistributionTests ( TestCase ):
         #       2. B and D sum to 100 - A
         #       3. B and D are both with 1 of their expected values.
         #
-    @SkipIfNeeded('test_13', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_13'], 'Test skipped during development.')
     def test_13_balanced_mesh ( self ):
         name='test_13'
         total      = 100
@@ -851,7 +853,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_14', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_14'], 'Test skipped during development.')
     def test_14_multicast_linear ( self ):
         name='test_14'
         test = MulticastTest ( name,
@@ -864,7 +866,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_15', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_15'], 'Test skipped during development.')
     def test_15_multicast_mesh ( self ):
         name='test_15'
         test = MulticastTest ( name,
@@ -877,7 +879,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_16', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_16'], 'Test skipped during development.')
     def test_16_linkroute_linear_all_local ( self ) :
         name='test_16'
         """
@@ -966,7 +968,7 @@ class DistributionTests ( TestCase ):
 
 
 
-    @SkipIfNeeded('test_17', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_17'], 'Test skipped during development.')
     def test_17_linkroute_linear_all_B ( self ) :
         name='test_17'
         """
@@ -1055,7 +1057,7 @@ class DistributionTests ( TestCase ):
 
 
 
-    @SkipIfNeeded('test_18', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_18'], 'Test skipped during development.')
     def test_18_linkroute_linear_all_C ( self ) :
         name='test_18'
         """
@@ -1143,7 +1145,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_19', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_19'], 'Test skipped during development.')
     def test_19_linkroute_linear_kill ( self ) :
         name='test_19'
         """
@@ -1292,7 +1294,7 @@ class DistributionTests ( TestCase ):
 
 
 
-    @SkipIfNeeded('test_20', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_20'], 'Test skipped during development.')
     def test_20_linkroute_mesh_all_local ( self ) :
         name='test_20'
         """
@@ -1394,7 +1396,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_21', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_21'], 'Test skipped during development.')
     def test_21_linkroute_mesh_nonlocal ( self ) :
         name='test_21'
         """
@@ -1498,7 +1500,7 @@ class DistributionTests ( TestCase ):
 
 
 
-    @SkipIfNeeded('test_22', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_22'], 'Test skipped during development.')
     def test_22_linkroute_mesh_kill ( self ) :
         name='test_22'
         """
@@ -1655,7 +1657,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual ( None, test.error )
 
 
-    @SkipIfNeeded('test_23', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_23'], 'Test skipped during development.')
     def test_23_waypoint ( self ) :
         name='test_23'
         test = WaypointTest ( name,
@@ -1669,7 +1671,7 @@ class DistributionTests ( TestCase ):
         self.assertEqual(None, test.error)
 
 
-    @SkipIfNeeded('test_24', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_24'], 'Test skipped during development.')
     def test_24_serial_waypoint_test ( self ):
         name='test_24'
         test = SerialWaypointTest ( name,
@@ -1682,7 +1684,7 @@ class DistributionTests ( TestCase ):
         test.run()
         self.assertEqual(None, test.error)
 
-    @SkipIfNeeded('test_25', 'Test skipped during development.')
+    @SkipIfNeeded(DistributionSkipMapper.skip['test_25'], 'Test skipped during development.')
     def test_25_parallel_waypoint_test ( self ):
         name='test_25'
         test = ParallelWaypointTest ( name,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_qdstat.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py
index a043d9f..7ce1052 100644
--- a/tests/system_tests_qdstat.py
+++ b/tests/system_tests_qdstat.py
@@ -28,7 +28,7 @@ import system_test
 import unittest
 from subprocess import PIPE
 from proton import Url, SSLDomain, SSLUnavailable, SASL
-from system_test import main_module
+from system_test import main_module, SkipIfNeeded
 
 
 class QdstatTest(system_test.TestCase):
@@ -351,9 +351,8 @@ try:
         def ssl_test_bad(self, url_name, arg_names):
             self.assertRaises(AssertionError, self.ssl_test, url_name, arg_names)
 
+        @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
         def test_ssl_cert_to_auth_fail_no_sasl_external(self):
-            if not SASL.extended():
-                self.skipTest("Cyrus library not available. skipping test")
             self.ssl_test_bad('auth_s', ['client_cert_all'])
 
         def test_ssl_trustfile_cert_to_auth_fail_no_sasl_external(self):

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_sasl_plain.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_sasl_plain.py b/tests/system_tests_sasl_plain.py
index 2285eee..95b1ecd 100644
--- a/tests/system_tests_sasl_plain.py
+++ b/tests/system_tests_sasl_plain.py
@@ -24,7 +24,7 @@ from __future__ import print_function
 
 import unittest2 as unittest, os
 from subprocess import PIPE, Popen
-from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT
+from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, SkipIfNeeded
 from qpid_dispatch.management.client import Node
 from proton import SASL
 
@@ -110,6 +110,7 @@ class RouterTestPlainSasl(RouterTestPlainSaslCommon):
 
         cls.routers[1].wait_router_connected('QDR.X')
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_inter_router_plain_exists(self):
         """
         Check authentication of inter-router link is PLAIN.
@@ -121,9 +122,6 @@ class RouterTestPlainSasl(RouterTestPlainSaslCommon):
 
         """
 
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         p = self.popen(
             ['qdstat', '-b', str(self.routers[0].addresses[1]), '-c'],
             name='qdstat-'+self.id(), stdout=PIPE, expect=None,
@@ -135,14 +133,12 @@ class RouterTestPlainSasl(RouterTestPlainSaslCommon):
         self.assertIn("inter-router", out)
         self.assertIn("test@domain.com(PLAIN)", out)
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_qdstat_connect_sasl(self):
         """
         Make qdstat use sasl plain authentication.
         """
 
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         p = self.popen(
             ['qdstat', '-b', str(self.routers[0].addresses[2]), '-c', '--sasl-mechanisms=PLAIN',
              '--sasl-username=test@domain.com', '--sasl-password=password'],
@@ -161,13 +157,11 @@ class RouterTestPlainSasl(RouterTestPlainSaslCommon):
         self.assertEqual(1, split_list.count("inter-router"))
         self.assertEqual(1, split_list.count("normal"))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_qdstat_connect_sasl_password_file(self):
         """
         Make qdstat use sasl plain authentication with client password specified in a file.
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         password_file = os.getcwd() + '/sasl-client-password-file.txt'
         # Create a SASL configuration file.
         with open(password_file, 'w') as sasl_client_password_file:
@@ -268,13 +262,11 @@ class RouterTestPlainSaslOverSsl(RouterTestPlainSaslCommon):
 
         cls.routers[1].wait_router_connected('QDR.X')
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_aaa_qdstat_connect_sasl_over_ssl(self):
         """
         Make qdstat use sasl plain authentication over ssl.
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         p = self.popen(
             ['qdstat', '-b', str(self.routers[0].addresses[2]), '-c',
              # The following are SASL args
@@ -302,6 +294,7 @@ class RouterTestPlainSaslOverSsl(RouterTestPlainSaslCommon):
         self.assertEqual(1, split_list.count("inter-router"))
         self.assertEqual(1, split_list.count("normal"))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_inter_router_plain_over_ssl_exists(self):
         """The setUpClass sets up two routers with SASL PLAIN enabled over TLS.
 
@@ -313,9 +306,6 @@ class RouterTestPlainSaslOverSsl(RouterTestPlainSaslCommon):
         Also makes sure that TLSv1.x was used as sslProto
 
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT)
         results = local_node.query(type='org.apache.qpid.dispatch.connection').results
 
@@ -404,15 +394,13 @@ class RouterTestVerifyHostNameYes(RouterTestPlainSaslCommon):
         except:
             pass
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_no_inter_router_connection(self):
         """
         Tests to make sure that there are no 'inter-router' connections.
         The connection to the other router will not happen because the connection failed
         due to setting 'verifyHostname': 'yes'
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
         results = local_node.query(type='org.apache.qpid.dispatch.connection').results
         # There should be only two connections.
@@ -528,26 +516,22 @@ class RouterTestVerifyHostNameNo(RouterTestPlainSaslCommon):
         # user must be test@domain.com
         self.assertEqual(u'test@domain.com', results[N][8])
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_inter_router_plain_over_ssl_exists(self):
         """
         Tests to make sure that an inter-router connection exists between the routers since
verifyHostname is 'no'.
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT)
 
         results = local_node.query(type='org.apache.qpid.dispatch.connection').results
 
         self.common_asserts(results)
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_zzz_delete_create_ssl_profile(self):
         """
         Deletes a connector and its corresponding ssl profile and recreates both
         """
-        if not SASL.extended():
-            self.skipTest("Cyrus library not available. skipping test")
-
         local_node = self.routers[1].management
 
         connections = local_node.query(type='org.apache.qpid.dispatch.connection').get_entities()

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a1585a9c/tests/system_tests_ssl.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_ssl.py b/tests/system_tests_ssl.py
index a0e2dbc..f38ae6d 100644
--- a/tests/system_tests_ssl.py
+++ b/tests/system_tests_ssl.py
@@ -23,7 +23,7 @@ Provides tests related with allowed TLS protocol version restrictions.
 import os
 from subprocess import Popen, PIPE
 from qpid_dispatch.management.client import Node
-from system_test import TestCase, main_module, Qdrouterd, DIR
+from system_test import TestCase, main_module, Qdrouterd, DIR, SkipIfNeeded
 from proton import SASL, Url, SSLDomain
 from proton.utils import BlockingConnection
 import proton
@@ -371,6 +371,7 @@ class RouterTestSslClient(RouterTestSslBase):
         """
         self.assertEqual(False, self.is_proto_allowed(self.PORT_SSL3, 'SSLv3'))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_ssl_sasl_client_valid(self):
         """
         Attempts to connect a Proton client using a valid SASL authentication info
@@ -383,6 +384,7 @@ class RouterTestSslClient(RouterTestSslBase):
         self.assertTrue(self.is_ssl_sasl_client_accepted(self.PORT_TLS_SASL, "TLSv1"))
         self.assertTrue(self.is_ssl_sasl_client_accepted(self.PORT_TLS_SASL, "TLSv1.2"))
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_ssl_sasl_client_invalid(self):
         """
         Attempts to connect a Proton client using a valid SASL authentication info
@@ -592,6 +594,7 @@ class RouterTestSslInterRouter(RouterTestSslBase):
         node.close()
         return router_nodes
 
+    @SkipIfNeeded(not SASL.extended(), "Cyrus library not available. skipping test")
     def test_connected_tls_sasl_routers(self):
         """
         Validates if all expected routers are connected in the network


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


Mime
View raw message