Skip to content

Commit ab50cfa

Browse files
moodyjoneukreign
authored andcommitted
Add test steps to repeatedly sync_apply() using a bad password.
1 parent 5a26aea commit ab50cfa

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/integration/blockchain/test_wallet_commands.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import asyncio
22
import json
3+
import string
34
from binascii import unhexlify
5+
from random import Random
46

57
from lbry.wallet import ENCRYPT_ON_DISK
68
from lbry.error import InvalidPasswordError
@@ -385,9 +387,16 @@ async def test_sync_with_encryption_and_password_change(self):
385387
data = await daemon2.jsonrpc_sync_apply('password2')
386388
# sync_apply doesn't save password if encrypt-on-disk is False
387389
self.assertEqual(wallet2.encryption_password, None)
388-
# need to use new password2 in sync_apply
389-
with self.assertRaises(InvalidPasswordError):
390-
await daemon.jsonrpc_sync_apply('password', data=data['data'], blocking=True)
390+
391+
# Need to use new password2 in sync_apply. Attempts with other passwords
392+
# should fail consistently with InvalidPasswordError.
393+
random = Random('password')
394+
for i in range(200):
395+
bad_guess = ''.join(random.choices(string.digits + string.ascii_letters + string.punctuation, k=40))
396+
self.assertNotEqual(bad_guess, 'password2')
397+
with self.assertRaises(InvalidPasswordError):
398+
await daemon.jsonrpc_sync_apply(bad_guess, data=data['data'], blocking=True)
399+
391400
await daemon.jsonrpc_sync_apply('password2', data=data['data'], blocking=True)
392401
# sync_apply with new password2 also sets it as new local password
393402
self.assertEqual(wallet.encryption_password, 'password2')

0 commit comments

Comments
 (0)