[Zodb-checkins] CVS: ZODB3/ZEO/tests - testAuth.py:1.1.2.2
Jeremy Hylton
jeremy at zope.com
Tue May 13 17:43:18 EDT 2003
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv10344/ZEO/tests
Modified Files:
Tag: ZODB3-auth-branch
testAuth.py
Log Message:
Add tests for auth_digest.
=== ZODB3/ZEO/tests/testAuth.py 1.1.2.1 => 1.1.2.2 ===
--- ZODB3/ZEO/tests/testAuth.py:1.1.2.1 Tue Apr 29 16:02:53 2003
+++ ZODB3/ZEO/tests/testAuth.py Tue May 13 16:43:17 2003
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -21,6 +21,7 @@
from ThreadedAsync import LoopCallback
from ZEO.auth.database import Database
#from ZEO.auth.auth_srp import SRPDatabase
+from ZEO.auth.auth_digest import DigestDatabase
from ZEO.ClientStorage import ClientStorage
from ZEO.StorageServer import StorageServer
from ZODB.FileStorage import FileStorage
@@ -33,12 +34,8 @@
class BaseTest(unittest.TestCase):
def createDB(self, name):
if os.path.exists(name):
- os.remove(self.database)
- if name.endswith('srp'):
- db = SRPDatabase(name)
- else:
- db = Database(name)
-
+ os.remove(self.database)
+ db = self.dbclass(name)
db.add_user('foo', 'bar')
db.save()
@@ -59,12 +56,16 @@
for file in glob.glob('auth-test.fs*'):
os.remove(file)
- def check(self):
+ def checkOK(self):
# Sleep for 0.2 seconds to give the server some time to start up
# seems to be needed before and after creating the storage
- time.sleep(0.2)
+ time.sleep(self.wait)
cs = ClientStorage(SOCKET, wait=0, username='foo', password='bar')
- time.sleep(0.2)
+ time.sleep(self.wait)
+
+ if cs is None:
+ raise AssertionError, \
+ "authentication for %s failed" % self.protocol
if cs._connection == None:
raise AssertionError, \
@@ -74,20 +75,49 @@
if not cs.is_connected():
raise AssertionError, \
"authentication for %s failed" % self.protocol
+
+ def checkNOK(self):
+ time.sleep(self.wait)
+ cs = ClientStorage(SOCKET, wait=0, username='foo', password='noogie')
+ time.sleep(self.wait)
+
+ # Normally a wrong password will return None immediately.
+ if cs is None:
+ return
+
+ if cs._connection is None:
+ return
+
+ cs._connection.poll()
+
+ if cs.is_connected():
+ raise AssertionError, "authenticated with incorrect password"
class PlainTextAuth(BaseTest):
protocol = 'plaintext'
database = 'authdb.sha'
+ dbclass = Database
+ wait = 0.2
class SHAAuth(BaseTest):
protocol = 'sha'
database = 'authdb.sha'
+ dbclass = Database
+ wait = 0.5
-#class SRPAuth(BaseTest):
-# protocol = 'srp'
-# database = 'authdb.srp'
+##class SRPAuth(BaseTest):
+## protocol = 'srp'
+## database = 'authdb.srp'
+## dbclass = SRPDatabase
+## wait = 1.0
+
+class DigestAuth(BaseTest):
+ protocol = "digest"
+ database = "authdb.digest"
+ dbclass = DigestDatabase
+ wait = 0.5
-test_classes = [PlainTextAuth, SHAAuth] # SRPAuth
+test_classes = [PlainTextAuth, SHAAuth, DigestAuth]
def test_suite():
suite = unittest.TestSuite()
More information about the Zodb-checkins
mailing list