Skip to content

Commit

Permalink
parse_uri should accept and ignore optional image parameter (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline authored Jan 30, 2021
1 parent 7183690 commit 1c4f85e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pyotp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def parse_uri(uri: str) -> OTP:
otp_data['interval'] = int(value)
elif key == 'counter':
otp_data['initial_count'] = int(value)
else:
elif key != 'image':
raise ValueError('{} is not a valid parameter'.format(key))

if not secret:
Expand Down
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ def test_algorithms(self):
with self.assertRaises(ValueError):
otp.provisioning_uri(name='n', issuer_name='i', image='nourl')

otp = pyotp.parse_uri(otp.provisioning_uri(name='n', issuer_name='i', image='https://test.net/test.png'))
self.assertEqual(hashlib.sha512, otp.digest)


class Timecop(object):
"""
Half-assed clone of timecop.rb, just enough to pass our tests.
Expand Down

0 comments on commit 1c4f85e

Please sign in to comment.