|
@@ -7,20 +7,36 @@ import sys
|
|
|
|
|
|
class DummyCallback(Callback):
|
|
|
|
|
|
+ def getsecret(self, question):
|
|
|
+ return str(123) + str(45)
|
|
|
+
|
|
|
+ def getnewsecret(self, question):
|
|
|
+ return str(123) + str(45)
|
|
|
+
|
|
|
+
|
|
|
+class DummyCallback2(Callback):
|
|
|
+
|
|
|
def getinput(self, question):
|
|
|
- return '12345'
|
|
|
+ return 'newsecret'
|
|
|
|
|
|
def getsecret(self, question):
|
|
|
- return '12345'
|
|
|
+ return 'wrong'
|
|
|
|
|
|
+ def getnewsecret(self, question):
|
|
|
+ return 'newsecret'
|
|
|
|
|
|
-class DummyCallback2(Callback):
|
|
|
+
|
|
|
+class DummyCallback3(Callback):
|
|
|
|
|
|
def getinput(self, question):
|
|
|
return 'newsecret'
|
|
|
|
|
|
def getsecret(self, question):
|
|
|
+ return '12345'
|
|
|
+
|
|
|
+ def getnewsecret(self, question):
|
|
|
return 'newsecret'
|
|
|
+
|
|
|
if 'darwin' in sys.platform: # pragma: no cover
|
|
|
from pwman.ui.mac import PwmanCliMacNew as PwmanCliNew
|
|
|
OSX = True
|
|
@@ -124,10 +140,16 @@ class DBTests(unittest.TestCase):
|
|
|
self.assertEqual(2, len(got_tags))
|
|
|
|
|
|
def test_change_pass(self):
|
|
|
- self.tester.cli.callback = DummyCallback2
|
|
|
+ enc = CryptoEngine.get()
|
|
|
+ enc._callback = DummyCallback2()
|
|
|
self.assertRaises(CryptoBadKeyException,
|
|
|
self.tester.cli._db.changepassword)
|
|
|
|
|
|
+ def test_db_change_pass(self):
|
|
|
+ enc = CryptoEngine.get()
|
|
|
+ enc._callback = DummyCallback3()
|
|
|
+ self.tester.cli._db.changepassword()
|
|
|
+
|
|
|
|
|
|
class CLITests(unittest.TestCase):
|
|
|
"""
|