Tres Seaver
2008-08-03 c7e12d37f696d1c9d575417ffb977cfbb0737bd4
Applied patch from Olaf Conradi which logs an error when an invalid filename
is passed to the HTPasswdPlugin.

3 files modified
25 ■■■■■ changed files
CHANGES.txt 5 ●●●●● patch | view | raw | blame | history
repoze/who/plugins/htpasswd.py 2 ●●●●● patch | view | raw | blame | history
repoze/who/tests.py 18 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -1,6 +1,11 @@
repoze.who changes
==================
After 1.0.2
 - Applied patch from Olaf Conradi which logs an error when an invalid
   filename is passed to the HTPasswdPlugin.
1.0.2 (2008/06/16)
 - Fix bug found by Chris Perkins: the auth_tkt plugin's "remember"
repoze/who/plugins/htpasswd.py
@@ -27,6 +27,8 @@
            try:
                f = open(self.filename, 'r')
            except IOError:
                environ['repoze.who.logger'].warn('could not open htpasswd '
                                                  'file %s' % self.filename)
                return None
        for line in f:
repoze/who/tests.py
@@ -902,6 +902,24 @@
        result = plugin.authenticate(environ, creds)
        self.assertEqual(result, 'chrism')
    def test_authenticate_bad_filename_logs_to_repoze_who_logger(self):
        here = os.path.abspath(os.path.dirname(__file__))
        htpasswd = os.path.join(here, 'fixtures', 'test.htpasswd.nonesuch')
        def check(password, hashed):
            return True
        plugin = self._makeOne(htpasswd, check)
        environ = self._makeEnviron()
        class DummyLogger:
            warnings = []
            def warn(self, msg):
                self.warnings.append(msg)
        logger = environ['repoze.who.logger'] = DummyLogger()
        creds = {'login':'chrism', 'password':'pass'}
        result = plugin.authenticate(environ, creds)
        self.assertEqual(result, None)
        self.assertEqual(len(logger.warnings), 1)
        self.failUnless('could not open htpasswd' in logger.warnings[0])
    def test_crypt_check(self):
        import sys
        # win32 does not have a crypt library, don't