Commit 6ca0a809 authored by Christian Robottom's avatar Christian Robottom

Adding a simple test for the zeopasswd script. Modifies zeopasswd.main() ...

Adding a simple test for the zeopasswd script. Modifies zeopasswd.main()                    slightly to accept a Database class; this is used only because                              auth_plaintext isn't an "officially supported" authentication protocol.
parent 5134ece8
...@@ -21,6 +21,7 @@ import unittest ...@@ -21,6 +21,7 @@ import unittest
import zLOG import zLOG
from ThreadedAsync import LoopCallback from ThreadedAsync import LoopCallback
from ZEO import zeopasswd
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
from ZEO.Exceptions import ClientDisconnected from ZEO.Exceptions import ClientDisconnected
from ZEO.StorageServer import StorageServer from ZEO.StorageServer import StorageServer
...@@ -44,8 +45,19 @@ class AuthTest(CommonSetupTearDown): ...@@ -44,8 +45,19 @@ class AuthTest(CommonSetupTearDown):
self.pwdb = self.dbclass(self.pwfile) self.pwdb = self.dbclass(self.pwfile)
self.pwdb.add_user("foo", "bar") self.pwdb.add_user("foo", "bar")
self.pwdb.save() self.pwdb.save()
self._checkZEOpasswd()
self.__super_setUp() self.__super_setUp()
def _checkZEOpasswd(self):
args = ["-f", self.pwfile, "-p", self.protocol]
if self.protocol == "plaintext":
from ZEO.auth.base import Database
zeopasswd.main(args + ["-d", "foo"], Database)
zeopasswd.main(args + ["foo", "bar"], Database)
else:
zeopasswd.main(args + ["-d", "foo"])
zeopasswd.main(args + ["foo", "bar"])
def tearDown(self): def tearDown(self):
self.__super_tearDown() self.__super_tearDown()
os.remove(self.pwfile) os.remove(self.pwfile)
...@@ -102,6 +114,7 @@ class AuthTest(CommonSetupTearDown): ...@@ -102,6 +114,7 @@ class AuthTest(CommonSetupTearDown):
# Once the client stops using the hmac, it should be disconnected. # Once the client stops using the hmac, it should be disconnected.
self.assertRaises(ClientDisconnected, self._storage.versions) self.assertRaises(ClientDisconnected, self._storage.versions)
class PlainTextAuth(AuthTest): class PlainTextAuth(AuthTest):
import ZEO.tests.auth_plaintext import ZEO.tests.auth_plaintext
protocol = "plaintext" protocol = "plaintext"
......
...@@ -101,7 +101,7 @@ def options(args): ...@@ -101,7 +101,7 @@ def options(args):
return auth_protocol, auth_db, auth_realm, delete, username, password return auth_protocol, auth_db, auth_realm, delete, username, password
def main(args=None): def main(args=None, dbclass=None):
p, auth_db, auth_realm, delete, username, password = options(args) p, auth_db, auth_realm, delete, username, password = options(args)
if p is None: if p is None:
usage("Error: configuration does not specify auth protocol") usage("Error: configuration does not specify auth protocol")
...@@ -109,6 +109,9 @@ def main(args=None): ...@@ -109,6 +109,9 @@ def main(args=None):
from ZEO.auth.auth_digest import DigestDatabase as Database from ZEO.auth.auth_digest import DigestDatabase as Database
elif p == "srp": elif p == "srp":
from ZEO.auth.auth_srp import SRPDatabase as Database from ZEO.auth.auth_srp import SRPDatabase as Database
elif dbclass:
# dbclass is used for testing tests.auth_plaintext, see testAuth.py
Database = dbclass
else: else:
raise ValueError, "Unknown database type %r" % p raise ValueError, "Unknown database type %r" % p
if auth_db is None: if auth_db is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment