Commit 8f8696c1 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 556ece20
......@@ -21,6 +21,7 @@ import unittest
import zLOG
from ThreadedAsync import LoopCallback
from ZEO import zeopasswd
from ZEO.ClientStorage import ClientStorage
from ZEO.Exceptions import ClientDisconnected
from ZEO.StorageServer import StorageServer
......@@ -44,8 +45,19 @@ class AuthTest(CommonSetupTearDown):
self.pwdb = self.dbclass(self.pwfile)
self.pwdb.add_user("foo", "bar")
self.pwdb.save()
self._checkZEOpasswd()
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):
self.__super_tearDown()
os.remove(self.pwfile)
......@@ -102,6 +114,7 @@ class AuthTest(CommonSetupTearDown):
# Once the client stops using the hmac, it should be disconnected.
self.assertRaises(ClientDisconnected, self._storage.versions)
class PlainTextAuth(AuthTest):
import ZEO.tests.auth_plaintext
protocol = "plaintext"
......
......@@ -101,7 +101,7 @@ def options(args):
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)
if p is None:
usage("Error: configuration does not specify auth protocol")
......@@ -109,6 +109,9 @@ def main(args=None):
from ZEO.auth.auth_digest import DigestDatabase as Database
elif p == "srp":
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:
raise ValueError, "Unknown database type %r" % p
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