diff options
| author | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-08-25 10:57:45 +0000 |
|---|---|---|
| committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-08-25 10:57:45 +0000 |
| commit | 09f7afd9909d9a6e5b6c0d148e2e8ba62648dc78 (patch) | |
| tree | 77ba45693d6575698efeb2bd36d59daafefed0a6 /python/tests | |
| parent | 9d460cf67c3999a0ec7723c377a60df07268b5c8 (diff) | |
| download | lasso-09f7afd9909d9a6e5b6c0d148e2e8ba62648dc78.tar.gz lasso-09f7afd9909d9a6e5b6c0d148e2e8ba62648dc78.tar.xz lasso-09f7afd9909d9a6e5b6c0d148e2e8ba62648dc78.zip | |
Added a --source-dir option to tests.
Diffstat (limited to 'python/tests')
| -rw-r--r-- | python/tests/errorchecking_tests.py | 15 | ||||
| -rw-r--r-- | python/tests/login_tests.py | 35 | ||||
| -rwxr-xr-x | python/tests/tests.py | 21 |
3 files changed, 50 insertions, 21 deletions
diff --git a/python/tests/errorchecking_tests.py b/python/tests/errorchecking_tests.py index 3e4614df..65cdbbe8 100644 --- a/python/tests/errorchecking_tests.py +++ b/python/tests/errorchecking_tests.py @@ -24,6 +24,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import os import unittest import sys @@ -35,6 +36,12 @@ if not '../.libs' in sys.path: import lasso +try: + dataDir +except NameError: + dataDir = '../../tests/data' + + class ErrorCheckingTestCase(unittest.TestCase): def test01(self): try: @@ -53,10 +60,10 @@ class ErrorCheckingTestCase(unittest.TestCase): # This time; we got something wrong as query string; we pass it to # init_from_authn_request_msg; surely it shouldn't segfault server = lasso.Server( - '../../tests/data/idp1-la/metadata.xml', - None, # '../../tests/data/idp1-la/public-key.pem' is no more used - '../../tests/data/idp1-la/private-key-raw.pem', - '../../tests/data/idp1-la/certificate.pem', + os.path.join(dataDir, 'idp1-la/metadata.xml'), + None, # os.path.join(dataDir, 'idp1-la/public-key.pem') is no more used + os.path.join(dataDir, 'idp1-la/private-key-raw.pem'), + os.path.join(dataDir, 'idp1-la/certificate.pem'), lasso.signatureMethodRsaSha1) login = lasso.Login(server) try: diff --git a/python/tests/login_tests.py b/python/tests/login_tests.py index 6c93fb99..e43db5a6 100644 --- a/python/tests/login_tests.py +++ b/python/tests/login_tests.py @@ -24,6 +24,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import os import unittest import sys @@ -35,6 +36,12 @@ if not '../.libs' in sys.path: import lasso +try: + dataDir +except NameError: + dataDir = '../../tests/data' + + class LoginTestCase(unittest.TestCase): pass @@ -44,15 +51,15 @@ class LogoutTestCase(unittest.TestCase): """SP logout without session and indentity; testing init_request.""" lassoServer = lasso.Server( - '../../tests/data/sp1-la/metadata.xml', - None, # '../../tests/data/sp1-la/public-key.pem' is no more used - '../../tests/data/sp1-la/private-key-raw.pem', - '../../tests/data/sp1-la/certificate.pem', + os.path.join(dataDir, 'sp1-la/metadata.xml'), + None, # os.path.join(dataDir, 'sp1-la/public-key.pem') is no more used + os.path.join(dataDir, 'sp1-la/private-key-raw.pem'), + os.path.join(dataDir, 'sp1-la/certificate.pem'), lasso.signatureMethodRsaSha1) lassoServer.add_provider( - '../../tests/data/idp1-la/metadata.xml', - '../../tests/data/idp1-la/public-key.pem', - '../../tests/data/ca1-la/certificate.pem') + os.path.join(dataDir, 'idp1-la/metadata.xml'), + os.path.join(dataDir, 'idp1-la/public-key.pem'), + os.path.join(dataDir, 'idp1-la/certificate.pem')) logout = lasso.Logout(lassoServer, lasso.providerTypeSp) try: logout.init_request() @@ -66,15 +73,15 @@ class LogoutTestCase(unittest.TestCase): """IDP logout without session and identity; testing logout.get_next_providerID.""" lassoServer = lasso.Server( - '../../tests/data/idp1-la/metadata.xml', - None, # '../../tests/data/idp1-la/public-key.pem' is no more used - '../../tests/data/idp1-la/private-key-raw.pem', - '../../tests/data/idp1-la/certificate.pem', + os.path.join(dataDir, 'idp1-la/metadata.xml'), + None, # os.path.join(dataDir, 'idp1-la/public-key.pem') is no more used + os.path.join(dataDir, 'idp1-la/private-key-raw.pem'), + os.path.join(dataDir, 'idp1-la/certificate.pem'), lasso.signatureMethodRsaSha1) lassoServer.add_provider( - '../../tests/data/sp1-la/metadata.xml', - '../../tests/data/sp1-la/public-key.pem', - '../../tests/data/ca1-la/certificate.pem') + os.path.join(dataDir, 'sp1-la/metadata.xml'), + os.path.join(dataDir, 'sp1-la/public-key.pem'), + os.path.join(dataDir, 'sp1-la/certificate.pem')) logout = lasso.Logout(lassoServer, lasso.providerTypeIdp) self.failIf(logout.get_next_providerID()) diff --git a/python/tests/tests.py b/python/tests/tests.py index a8e902b4..a1913e01 100755 --- a/python/tests/tests.py +++ b/python/tests/tests.py @@ -24,7 +24,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import __builtin__ import imp +from optparse import OptionParser +import os import sys import time import unittest @@ -42,7 +45,19 @@ testSuites = ( 'errorchecking_tests', ) -if "--xml" in sys.argv: + +# Parse command line options. +parser = OptionParser() +parser.add_option( + '-x', '--xml', dest = 'xmlMode', help = 'enable XML output', + action = 'store_true', default = False) +parser.add_option( + '-s', '--source-dir', dest = 'srcDir', help = 'path of source directory', + metavar = 'DIR', default = os.getcwd()) +(options, args) = parser.parse_args() +__builtin__.__dict__['dataDir'] = os.path.join(options.srcDir, '../../tests/data') + +if options.xmlMode: print """<?xml version="1.0"?>""" print """<testsuites xmlns="http://check.sourceforge.net/ns">""" print """ <title>Python Bindings</title>""" @@ -65,7 +80,7 @@ for testSuite in testSuites: else: doc = testSuite - if "--xml" in sys.argv: + if options.xmlMode: runner = XmlTestRunner() else: runner = unittest.TextTestRunner(verbosity=2) @@ -76,7 +91,7 @@ for testSuite in testSuites: result = runner.run(module.allTests) success = success and result.wasSuccessful() -if "--xml" in sys.argv: +if options.xmlMode: print """</testsuites>""" sys.exit(not success) |
