From c8505e458db838a73b96fa9194c63618323119af Mon Sep 17 00:00:00 2001 From: Frederic Peters Date: Mon, 22 Nov 2004 12:00:00 +0000 Subject: sync python tests with lasso 0.5 --- python/tests/errorchecking_tests.py | 2 +- python/tests/profiles_tests.py | 42 +++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'python') diff --git a/python/tests/errorchecking_tests.py b/python/tests/errorchecking_tests.py index 01a35b71..1ea9e1e7 100644 --- a/python/tests/errorchecking_tests.py +++ b/python/tests/errorchecking_tests.py @@ -66,7 +66,7 @@ class ErrorCheckingTestCase(unittest.TestCase): os.path.join(dataDir, 'idp1-la/certificate.pem')) login = lasso.Login(server) try: - login.processAuthnRequestMsg("", lasso.httpMethodRedirect) + login.processAuthnRequestMsg("") except lasso.Error: pass diff --git a/python/tests/profiles_tests.py b/python/tests/profiles_tests.py index 060e94cb..d1b1344e 100755 --- a/python/tests/profiles_tests.py +++ b/python/tests/profiles_tests.py @@ -52,6 +52,7 @@ class ServerTestCase(unittest.TestCase): None, os.path.join(dataDir, 'sp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleIdp, 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')) @@ -64,7 +65,8 @@ class ServerTestCase(unittest.TestCase): """Server construction without argument, dump & newFromDump.""" lassoServer = lasso.Server() - lassoServer.addProvider(os.path.join(dataDir, 'idp1-la/metadata.xml')) + lassoServer.addProvider( + lasso.providerRoleIdp, os.path.join(dataDir, 'idp1-la/metadata.xml')) dump = lassoServer.dump() lassoServer2 = lassoServer.newFromDump(dump) dump2 = lassoServer2.dump() @@ -81,6 +83,7 @@ class LoginTestCase(unittest.TestCase): None, os.path.join(dataDir, 'sp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleIdp, 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')) @@ -100,10 +103,11 @@ class LogoutTestCase(unittest.TestCase): None, os.path.join(dataDir, 'sp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleIdp, 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) + logout = lasso.Logout(lassoServer) try: logout.initRequest() except lasso.Error, error: @@ -121,10 +125,11 @@ class LogoutTestCase(unittest.TestCase): None, os.path.join(dataDir, 'idp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleSp, 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) + logout = lasso.Logout(lassoServer) self.failIf(logout.getNextProviderId()) def test03(self): @@ -136,13 +141,14 @@ class LogoutTestCase(unittest.TestCase): None, os.path.join(dataDir, 'idp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleSp, 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) + logout = lasso.Logout(lassoServer) # The processRequestMsg should fail but not abort. try: - logout.processRequestMsg('passport=0&lasso=1', lasso.httpMethodRedirect) + logout.processRequestMsg('passport=0&lasso=1') except lasso.Error, error: if error[0] != lasso.PROFILE_ERROR_INVALID_QUERY: raise @@ -158,13 +164,14 @@ class LogoutTestCase(unittest.TestCase): None, os.path.join(dataDir, 'idp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleSp, 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) + logout = lasso.Logout(lassoServer) # The processResponseMsg should fail but not abort. try: - logout.processResponseMsg('liberty=&alliance', lasso.httpMethodRedirect) + logout.processResponseMsg('liberty=&alliance') except lasso.Error, error: if error[0] != lasso.PROFILE_ERROR_INVALID_QUERY: raise @@ -180,6 +187,7 @@ class LogoutTestCase(unittest.TestCase): None, os.path.join(dataDir, 'idp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleSp, 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')) @@ -195,26 +203,38 @@ class DefederationTestCase(unittest.TestCase): None, os.path.join(dataDir, 'idp1-la/certificate.pem')) lassoServer.addProvider( + lasso.providerRoleSp, 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')) - defederation = lasso.Defederation(lassoServer, lasso.providerTypeIdp) + defederation = lasso.Defederation(lassoServer) # The processNotificationMsg should fail but not abort. try: - defederation.processNotificationMsg('nonLibertyQuery=1', lasso.httpMethodRedirect) + defederation.processNotificationMsg('nonLibertyQuery=1') except lasso.Error, error: - if error[0] != lasso.PROFILE_ERROR_INVALID_QUERY: + if error[0] != lasso.PROFILE_ERROR_INVALID_MSG: raise else: self.fail('Defederation processNotificationMsg should have failed.') +class IdentityTestCase(unittest.TestCase): + def test01(self): + """Identity newFromDump & dump.""" + + identityDump = """_CD739B41C602EAEA93626EBD1751CB46_11EA77A4FED32C41824AC5DE87298E65""" + identity = lasso.Identity.newFromDump(identityDump) + newIdentityDump = identity.dump() + self.failUnlessEqual(identityDump, newIdentityDump) + + suite1 = unittest.makeSuite(ServerTestCase, 'test') suite2 = unittest.makeSuite(LoginTestCase, 'test') suite3 = unittest.makeSuite(LogoutTestCase, 'test') suite4 = unittest.makeSuite(DefederationTestCase, 'test') +suite5 = unittest.makeSuite(IdentityTestCase, 'test') -allTests = unittest.TestSuite((suite1, suite2, suite3, suite4)) +allTests = unittest.TestSuite((suite1, suite2, suite3, suite4, suite5)) if __name__ == '__main__': sys.exit(not unittest.TextTestRunner(verbosity = 2).run(allTests).wasSuccessful()) -- cgit