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 2015/07/18 00:07:28 UTC

[2/3] qpid-proton git commit: NO-JIRA: Skip Extended SASL tests if we can't find saslpasswd2

NO-JIRA: Skip Extended SASL tests if we can't find saslpasswd2


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

Branch: refs/heads/master
Commit: 198af3dbadc5f01f5333bab6313f812ccab0b750
Parents: eec9cb3
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Jul 16 18:32:15 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Jul 17 17:39:37 2015 -0400

----------------------------------------------------------------------
 config.sh.in                        |  5 ++++
 tests/python/proton_tests/common.py | 44 +++++++++++++++++++++-----------
 tests/python/proton_tests/sasl.py   | 11 ++++----
 3 files changed, 39 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/198af3db/config.sh.in
----------------------------------------------------------------------
diff --git a/config.sh.in b/config.sh.in
index 4b60b2f..25d08b1 100755
--- a/config.sh.in
+++ b/config.sh.in
@@ -59,3 +59,8 @@ export PATH="$PATH:$PROTON_HOME/tests/python"
 if [[ -x "$(type -p valgrind)" ]] ; then
     export VALGRIND=$(type -p valgrind)
 fi
+
+# can the test harness use saslpasswd2?
+if [[ -x "$(type -p saslpasswd2)" ]] ; then
+    export SASLPASSWD=$(type -p saslpasswd2)
+fi

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/198af3db/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 857cb50..dab6fba 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -108,31 +108,45 @@ def pump(transport1, transport2, buffer_size=1024):
 def isSSLPresent():
     return SSL.present()
 
+createdSASLDb = False
+
 def _cyrusSetup(conf_dir):
   """Write out simple SASL config.
-     This assumes saslpasswd2 is in the OS path.
   """
-  t = Template("""sasldb_path: ${db}
+  saslpasswd = ""
+  if 'SASLPASSWD' in os.environ:
+    saslpasswd = os.environ['SASLPASSWD']
+  if os.path.exists(saslpasswd):
+    t = Template("""sasldb_path: ${db}
 mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
 """)
-  abs_conf_dir = os.path.abspath(conf_dir)
-  subprocess.call(args=['rm','-rf',abs_conf_dir])
-  os.mkdir(abs_conf_dir)
-  db = os.path.join(abs_conf_dir,'proton.sasldb')
-  conf = os.path.join(abs_conf_dir,'proton-server.conf')
-  f = open(conf, 'w')
-  f.write(t.substitute(db=db))
-  f.close()
-
-  cmd = Template("echo password | saslpasswd2 -c -p -f ${db} -u proton user").substitute(db=db)
-  subprocess.call(args=cmd, shell=True)
-
-  os.environ['PN_SASL_CONFIG_PATH'] = abs_conf_dir
+    abs_conf_dir = os.path.abspath(conf_dir)
+    subprocess.call(args=['rm','-rf',abs_conf_dir])
+    os.mkdir(abs_conf_dir)
+    db = os.path.join(abs_conf_dir,'proton.sasldb')
+    conf = os.path.join(abs_conf_dir,'proton-server.conf')
+    f = open(conf, 'w')
+    f.write(t.substitute(db=db))
+    f.close()
+
+    cmd_template = Template("echo password | ${saslpasswd} -c -p -f ${db} -u proton user")
+    cmd = cmd_template.substitute(db=db, saslpasswd=saslpasswd)
+    subprocess.call(args=cmd, shell=True)
+
+    os.environ['PN_SASL_CONFIG_PATH'] = abs_conf_dir
+    global createdSASLDb
+    createdSASLDb = True
 
 # Globally initialize Cyrus SASL configuration
 if SASL.extended():
   _cyrusSetup('sasl_conf')
 
+def ensureCanTestExtendedSASL():
+  if not SASL.extended():
+    raise Skipped('Extended SASL not supported')
+  if not createdSASLDb:
+    raise Skipped("Can't Test Extended SASL: Couldn't create auth db")
+
 class Test(TestCase):
 
   def __init__(self, name):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/198af3db/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index a072150..9c8c38c 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -313,16 +313,14 @@ class CyrusSASLTest(Test):
     _testSaslMech(self, 'ANONYMOUS', authUser='anonymous')
 
   def testMechCRAMMD5(self):
-    if not SASL.extended():
-      raise Skipped('Extended SASL not supported')
+    common.ensureCanTestExtendedSASL()
 
     self.t1.bind(self.c1)
     self.t2.bind(self.c2)
     _testSaslMech(self, 'CRAM-MD5')
 
   def testMechDIGESTMD5(self):
-    if not SASL.extended():
-      raise Skipped('Extended SASL not supported')
+    common.ensureCanTestExtendedSASL()
 
     self.t1.bind(self.c1)
     self.t2.bind(self.c2)
@@ -332,8 +330,7 @@ class CyrusSASLTest(Test):
 # so not universal and hance need a test for support
 # to keep it in tests.
 #  def testMechSCRAMSHA1(self):
-#    if not SASL.extended():
-#      raise Skipped('Extended SASL not supported')
+#    common.ensureCanTestExtendedSASL()
 #
 #    self.t1.bind(self.c1)
 #    self.t2.bind(self.c2)
@@ -365,6 +362,7 @@ class SSLSASLTest(Test):
       raise Skipped("Proton-J does not support SSL with SASL")
     if not SASL.extended():
       raise Skipped("Simple SASL server does not support PLAIN")
+    common.ensureCanTestExtendedSASL()
 
     clientUser = 'user@proton'
     mech = 'PLAIN'
@@ -383,6 +381,7 @@ class SSLSASLTest(Test):
       raise Skipped("Proton-J does not support SSL with SASL")
     if not SASL.extended():
       raise Skipped("Simple SASL server does not support PLAIN")
+    common.ensureCanTestExtendedSASL()
 
     clientUser = 'usr@proton'
     mech = 'PLAIN'


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