Пример #1
0
 def is_webkit_trac_user(self, username, password):
     try:
         with self.open_trac_credentials_file() as f:
             htdigest = HTDigestParser(f)
     except IOError, e:
         raise Error('Error opening Trac credentials file: {0}'.format(
             e.strerror))
 def assertEntriesEqual(self, entries, additional_content=None):
     digest_file = self.fake_htdigest_file()
     if additional_content is not None:
         digest_file.seek(pos=0, mode=os.SEEK_END)
         digest_file.write(additional_content)
         digest_file.seek(pos=0, mode=os.SEEK_SET)
     self.assertEqual(entries, HTDigestParser(digest_file).entries())
Пример #3
0
    def is_webkit_trac_user(self, username, password):
        try:
            with self.open_trac_credentials_file() as f:
                htdigest = HTDigestParser(f)
        except IOError as e:
            raise Error('Error opening Trac credentials file: {0}'.format(
                e.strerror))

        if not htdigest.entries():
            raise Error('Error parsing Trac credentials file')

        if not htdigest.authenticate(username, 'Mac OS Forge', password):
            self.err = 'Invalid username/password'
            return False

        return True
    def test_authenticate(self):
        htdigest = HTDigestParser(self.fake_htdigest_file())
        self.assertTrue(htdigest.authenticate('user1', 'realm 1', 'password1'))
        self.assertTrue(htdigest.authenticate('user2', 'realm 2', 'password2'))
        self.assertTrue(htdigest.authenticate('user3', 'realm 1', 'password3'))
        self.assertTrue(htdigest.authenticate('user3', 'realm 3', 'password3'))

        self.assertFalse(htdigest.authenticate('user1', 'realm', 'password1'))
        self.assertFalse(htdigest.authenticate('user1', 'realm 2',
                                               'password1'))
        self.assertFalse(htdigest.authenticate('user2', 'realm 2',
                                               'password1'))
        self.assertFalse(htdigest.authenticate('user2', 'realm 1',
                                               'password1'))
        self.assertFalse(htdigest.authenticate('', '', ''))
    def test_authenticate(self):
        htdigest = HTDigestParser(self.fake_htdigest_file())
        self.assertTrue(htdigest.authenticate('user1', 'realm 1', 'password1'))
        self.assertTrue(htdigest.authenticate('user2', 'realm 2', 'password2'))
        self.assertTrue(htdigest.authenticate('user3', 'realm 1', 'password3'))
        self.assertTrue(htdigest.authenticate('user3', 'realm 3', 'password3'))

        self.assertFalse(htdigest.authenticate('user1', 'realm', 'password1'))
        self.assertFalse(htdigest.authenticate('user1', 'realm 2', 'password1'))
        self.assertFalse(htdigest.authenticate('user2', 'realm 2', 'password1'))
        self.assertFalse(htdigest.authenticate('user2', 'realm 1', 'password1'))
        self.assertFalse(htdigest.authenticate('', '', ''))
 def test_empty_file(self):
     self.assertEqual([], HTDigestParser(StringIO.StringIO()).entries())