Skip to content

Commit

Permalink
Update deprecation version again
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Mar 5, 2017
1 parent 1a27eaa commit d53f651
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/twisted/cred/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def checkPassword(self, password):
class UsernameHashedPassword:

deprecatedModuleAttribute(
Version("Twisted", 16, 3, 0),
Version("Twisted", 17, 1, 0),
"Use twisted.cred.credentials.UsernamePassword instead.",
"twisted.cred.credentials", "UsernameHashedPassword")

Expand Down
12 changes: 8 additions & 4 deletions src/twisted/cred/test/test_cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@



# The Twisted version in which UsernameHashedPassword is first deprecated.
_uhpVersion = Version('Twisted', 17, 1, 0)



class ITestable(Interface):
"""
An interface for a theoretical protocol.
Expand Down Expand Up @@ -242,15 +247,14 @@ def testRequestAvatarId(self):
def testRequestAvatarId_hashed(self):
self.db = checkers.FilePasswordDB(self.dbfile)
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
creds = [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):
users = [
(b'user1', b'pass1'),
Expand Down Expand Up @@ -302,7 +306,7 @@ def testBadCredentials(self):

def testHashedCredentials(self):
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
hashedCreds = [UsernameHashedPassword(
u, self.hash(None, p, u[:2])) for u, p in self.users]
d = defer.DeferredList([self.port.login(c, None, ITestable)
Expand Down Expand Up @@ -459,5 +463,5 @@ def test_deprecation(self):
self.getDeprecatedModuleAttribute(
'twisted.cred.credentials',
'UsernameHashedPassword',
Version('Twisted', 16, 3, 0),
_uhpVersion,
'Use twisted.cred.credentials.UsernamePassword instead.')
12 changes: 8 additions & 4 deletions src/twisted/cred/test/test_simpleauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def test_interface(self):



_uhpVersion = Version('Twisted', 16, 3, 0)



class UsernameHashedPasswordTests(TestCase):
"""
Tests for L{UsernameHashedPassword}.
Expand All @@ -63,7 +67,7 @@ def test_initialisation(self):
and C{hashed} on it.
"""
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
creds = UsernameHashedPassword(b"foo", b"bar")
self.assertEqual(creds.username, b"foo")
self.assertEqual(creds.hashed, b"bar")
Expand All @@ -75,7 +79,7 @@ def test_correctPassword(self):
L{True} when the password given is the password on the object.
"""
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
creds = UsernameHashedPassword(b"user", b"pass")
self.assertTrue(creds.checkPassword(b"pass"))

Expand All @@ -86,7 +90,7 @@ def test_wrongPassword(self):
L{False} when the password given is NOT the password on the object.
"""
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
creds = UsernameHashedPassword(b"user", b"pass")
self.assertFalse(creds.checkPassword(b"someotherpass"))

Expand All @@ -96,6 +100,6 @@ def test_interface(self):
L{UsernameHashedPassword} implements L{IUsernameHashedPassword}.
"""
UsernameHashedPassword = self.getDeprecatedModuleAttribute(
'twisted.cred.credentials', 'UsernameHashedPassword', Version('Twisted', 16, 3, 0))
'twisted.cred.credentials', 'UsernameHashedPassword', _uhpVersion)
self.assertTrue(
IUsernameHashedPassword.implementedBy(UsernameHashedPassword))

0 comments on commit d53f651

Please sign in to comment.