[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests - test_ftpauth.py:1.1
Jim Fulton
jim@zope.com
Mon, 3 Feb 2003 10:08:49 -0500
Update of /cvs-repository/Zope3/src/zope/app/security/tests
In directory cvs.zope.org:/tmp/cvs-serv15846/src/zope/app/security/tests
Added Files:
test_ftpauth.py
Log Message:
Refactored the ftp framework to make it much simpler, less general,
and easier to maintain. This included ripping out the vfs framework.
=== Added File Zope3/src/zope/app/security/tests/test_ftpauth.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: test_ftpauth.py,v 1.1 2003/02/03 15:08:46 jim Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from zope.publisher.interfaces.ftp import IFTPCredentials
from zope.app.security.ftpauth import FTPAuth
class FTPCredentials:
__doc__ = IFTPCredentials.__doc__
__implements__ = IFTPCredentials
def __init__(self, credentials):
self.credentials = credentials
def _authUserPW(self):
return self.credentials
unauth = 0
def unauthorized(self, challenge):
self.unauth += 1
class Test(TestCase):
def test(self):
request = FTPCredentials(('bob', '123'))
auth = FTPAuth(request)
self.assertEqual(auth.getLogin(), 'bob')
self.assertEqual(auth.getPassword(), '123')
unauth = request.unauth
auth.needLogin('xxx')
self.assertEqual(request.unauth, unauth+1)
def test_suite():
return TestSuite((
makeSuite(Test),
))
if __name__=='__main__':
main(defaultTest='test_suite')