-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from jsza/36-hashed-passwords
Implement password hashing
- Loading branch information
Showing
8 changed files
with
230 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
branch = True | ||
source = | ||
axiom | ||
omit = | ||
*/axiom/test/historic/stub_*.py | ||
|
||
[report] | ||
exclude_lines = | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from axiom.userbase import LoginSystem | ||
from axiom.dependency import installOn | ||
from axiom.test.historic.stubloader import saveStub | ||
from axiom.test.test_userbase import GarbageProtocolHandler | ||
|
||
|
||
def createDatabase(s): | ||
ls = LoginSystem(store=s) | ||
installOn(ls, s) | ||
acc = ls.addAccount(u'test', u'example.com', u'asdf') | ||
ss = acc.avatars.open() | ||
gph = GarbageProtocolHandler(store=ss, garbage=7) | ||
installOn(gph, ss) | ||
|
||
|
||
if __name__ == '__main__': | ||
saveStub(createDatabase, 0x1240846306fcda3289550cdf9515b2c7111d2bac) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ def testUpgrade(self): | |
|
||
def loggedIn((ifc, av, lgo)): | ||
assert av.garbage == 7 | ||
# Bug in cooperator? this triggers an exception. | ||
# return svc.stopService() | ||
return av.store.whenFullyUpgraded() | ||
d = p.login( | ||
UsernamePassword('[email protected]', SECRET), None, IGarbage) | ||
return d.addCallback(loggedIn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from twisted.cred.portal import Portal, IRealm | ||
|
||
from twisted.cred.checkers import ICredentialsChecker | ||
from twisted.cred.credentials import UsernamePassword | ||
|
||
from axiom.test.test_userbase import IGarbage | ||
from axiom.test.historic import stubloader | ||
from axiom.errors import BadCredentials | ||
from axiom.userbase import getTestContext, LoginAccount | ||
|
||
SECRET = 'asdf' | ||
SECRET2 = 'ghjk' | ||
|
||
|
||
class AccountUpgradeTest(stubloader.StubbedTest): | ||
def test_upgrade(self): | ||
""" | ||
After the upgrade, logging in with the correct password succeeds, while | ||
logging in with an incorrect password fails. | ||
""" | ||
ls = IRealm(self.store) | ||
ls._txCryptContext, perform = getTestContext() | ||
p = Portal(ls, [ICredentialsChecker(self.store)]) | ||
d = p.login( | ||
UsernamePassword('[email protected]', SECRET), None, IGarbage) | ||
perform() | ||
(ifc, av, lgo) = self.successResultOf(d) | ||
self.assertEqual(av.garbage, 7) | ||
|
||
d = p.login( | ||
UsernamePassword('[email protected]', SECRET2), None, IGarbage) | ||
perform() | ||
self.failureResultOf(d, BadCredentials) | ||
|
||
# Have to let the substore upgrade complete | ||
return av.store.whenFullyUpgraded() | ||
|
||
|
||
def test_password(self): | ||
""" | ||
After the upgrade, the password attribute is cleared. | ||
""" | ||
acct = self.store.findUnique(LoginAccount) | ||
self.assertIdentical(acct.password, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.