[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testBasicAuthAdapter.py:1.1.2.1
Guido van Rossum
guido@python.org
Thu, 13 Dec 2001 12:21:39 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv30934/tests
Added Files:
Tag: Zope-3x-branch
testBasicAuthAdapter.py
Log Message:
Add HTTP Basic Authentication Adapter implementation.
=== Added File Zope3/lib/python/Zope/App/Security/tests/testBasicAuthAdapter.py ===
##############################################################################
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
##############################################################################
import unittest, sys
from Zope.App.Security.BasicAuthAdapter import BasicAuthAdapter
class Test(unittest.TestCase):
def testBasicAuthAdapter(self):
class Request:
def __init__(self, lpw):
self.lpw = lpw
def _authUserPW(self):
return self.lpw
r = Request(None)
a = BasicAuthAdapter(r)
self.assertEqual(a.getLogin(), None)
self.assertEqual(a.getPassword(), None)
r = Request(("tim", "123"))
a = BasicAuthAdapter(r)
self.assertEqual(a.getLogin(), "tim")
self.assertEqual(a.getPassword(), "123")
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())