Here are the examples of the python api twisted.cred.credentials.UsernameHashedPassword taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Source : test_cred.py
with MIT License
from autofelix
with MIT License
from autofelix
def testRequestAvatarId_hashed(self):
self.db = checkers.FilePasswordDB(self.dbfile)
creds = [credentials.UsernameHashedPassword(u, p)
for u, p in self.users]
d = defer.gatherResults(
[defer.maybeDeferred(self.db.requestAvatarId, c) for c in creds])
d.addCallback(self.assertEqual, [u for u, p in self.users])
return d
class HashedPasswordOnDiskDatabaseTests(unittest.TestCase):
3
Source : test_cred.py
with MIT License
from autofelix
with MIT License
from autofelix
def testHashedCredentials(self):
hashedCreds = [credentials.UsernameHashedPassword(
u, self.hash(None, p, u[:2])) for u, p in self.users]
d = defer.DeferredList([self.port.login(c, None, ITestable)
for c in hashedCreds], consumeErrors=True)
d.addCallback(self._assertFailures, error.UnhandledCredentials)
return d
def _assertFailures(self, failures, *expectedFailures):
3
Source : test_simpleauth.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_initialisation(self):
"""
The initialisation of L{UsernameHashedPassword} will set C{username}
and C{hashed} on it.
"""
creds = UsernameHashedPassword(b"foo", b"bar")
self.assertEqual(creds.username, b"foo")
self.assertEqual(creds.hashed, b"bar")
def test_correctPassword(self):
3
Source : test_simpleauth.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_correctPassword(self):
"""
Calling C{checkPassword} on a L{UsernameHashedPassword} will return
L{True} when the password given is the password on the object.
"""
creds = UsernameHashedPassword(b"user", b"pass")
self.assertTrue(creds.checkPassword(b"pass"))
def test_wrongPassword(self):
3
Source : test_simpleauth.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_wrongPassword(self):
"""
Calling C{checkPassword} on a L{UsernameHashedPassword} will return
L{False} when the password given is NOT the password on the object.
"""
creds = UsernameHashedPassword(b"user", b"pass")
self.assertFalse(creds.checkPassword(b"someotherpass"))
def test_interface(self):