You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/06/18 22:15:36 UTC

[31/50] [abbrv] qpid-proton git commit: PROTON-909: Rearrange the test code to create the Cyrus SASL configuration - Make the Cyrus SASL configuration global for all the testing - This fixes test failures against earlier versions of the Cyrus library - T

PROTON-909: Rearrange the test code to create the Cyrus SASL configuration
- Make the Cyrus SASL configuration global for all the testing
- This fixes test failures against earlier versions of the Cyrus library
- The bug this fixes relates to PROTON-862


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

Branch: refs/heads/kgiusti-python3
Commit: 0f90a7e4c9cc5a1decd7f6896c16d9b8b0653316
Parents: 56af118
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Jun 16 14:25:16 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Jun 16 14:54:13 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/common.py | 28 +++++++++++++++++++++-
 tests/python/proton_tests/sasl.py   | 40 --------------------------------
 2 files changed, 27 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f90a7e4/tests/python/proton_tests/common.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/common.py b/tests/python/proton_tests/common.py
index 83a39f8..11bea85 100644
--- a/tests/python/proton_tests/common.py
+++ b/tests/python/proton_tests/common.py
@@ -22,10 +22,11 @@ from random import randint
 from threading import Thread
 from socket import socket, AF_INET, SOCK_STREAM
 from subprocess import Popen,PIPE,STDOUT
-import sys, os, string
+import sys, os, string, subprocess
 from proton import Connection, Transport, SASL, Endpoint, Delivery, SSL
 from proton.reactor import Container
 from proton.handlers import CHandshaker, CFlowController
+from string import Template
 
 
 def free_tcp_ports(count=1):
@@ -86,6 +87,31 @@ def pump(transport1, transport2, buffer_size=1024):
 def isSSLPresent():
     return SSL.present()
 
+def _cyrusSetup(conf_dir):
+  """Write out simple SASL config.
+     This assumes saslpasswd2 is in the OS path.
+  """
+  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
+
+# Globally initialize Cyrus SASL configuration
+if SASL.extended():
+  _cyrusSetup('sasl_conf')
+
 class Test(TestCase):
 
   def __init__(self, name):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f90a7e4/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 91b3e69..7f1e7ad 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -18,8 +18,6 @@
 #
 
 import sys, os, common
-from string import Template
-import subprocess
 
 from proton import *
 from common import pump, Skipped
@@ -32,23 +30,6 @@ def _sslCertpath(file):
     return os.path.join(os.path.dirname(__file__),
                         "ssl_db/%s" % file)
 
-def _cyrusSetup(conf_dir):
-  """Write out simple SASL config
-  """
-  t = Template("""sasldb_path: ${db}
-mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
-""")
-  subprocess.call(args=['rm','-rf',conf_dir])
-  os.mkdir(conf_dir)
-  db = os.path.abspath(os.path.join(conf_dir,'proton.sasldb'))
-  conf = os.path.abspath(os.path.join(conf_dir,'proton.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)
-
 def _testSaslMech(self, mech, clientUser='user@proton', authUser='user@proton', encrypted=False, authenticated=True):
   self.s1.allowed_mechs(mech)
   self.c1.open()
@@ -92,13 +73,6 @@ class SaslTest(Test):
     self.t2 = Transport(Transport.SERVER)
     self.s2 = SASL(self.t2)
 
-    if not SASL.extended():
-      return
-
-    _cyrusSetup('sasl_conf')
-    self.s2.config_name('proton')
-    self.s2.config_path(os.path.abspath('sasl_conf'))
-
   def pump(self):
     pump(self.t1, self.t2, 1024)
 
@@ -325,13 +299,6 @@ class CyrusSASLTest(Test):
     self.c1.password = 'password'
     self.c1.hostname = 'localhost'
 
-    if not SASL.extended():
-      return
-
-    _cyrusSetup('sasl_conf')
-    self.s2.config_name('proton')
-    self.s2.config_path(os.path.abspath('sasl_conf'))
-
   def testMechANON(self):
     self.t1.bind(self.c1)
     _testSaslMech(self, 'ANONYMOUS', authUser='anonymous')
@@ -380,13 +347,6 @@ class SSLSASLTest(Test):
 
     self.c1 = Connection()
 
-    if not SASL.extended():
-      return
-
-    _cyrusSetup('sasl_conf')
-    self.s2.config_name('proton')
-    self.s2.config_path(os.path.abspath('sasl_conf'))
-
   def testSSLPlainSimple(self):
     if "java" in sys.platform:
       raise Skipped("Proton-J does not support SSL with SASL")


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