diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2016-11-10 20:15:11 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2016-11-10 20:15:11 -0500 |
commit | 47b1d1524dbde0e2ff004f6b2c76f9038cf5958f (patch) | |
tree | da9d24e05720e7f1b72fc76ffd1d46438b389150 | |
parent | 1a982b8bba3a2a850d5f64ca725590cbd3521d6c (diff) | |
download | passlib-47b1d1524dbde0e2ff004f6b2c76f9038cf5958f.tar.gz |
totp: added cache_seconds to TotpMatch repr, fixed py3 bug in UTs
-rw-r--r-- | docs/lib/passlib.totp-tutorial.rst | 2 | ||||
-rw-r--r-- | passlib/tests/test_totp.py | 2 | ||||
-rw-r--r-- | passlib/totp.py | 5 |
3 files changed, 5 insertions, 4 deletions
diff --git a/docs/lib/passlib.totp-tutorial.rst b/docs/lib/passlib.totp-tutorial.rst index 7a35c11..bfb595d 100644 --- a/docs/lib/passlib.totp-tutorial.rst +++ b/docs/lib/passlib.totp-tutorial.rst @@ -546,7 +546,7 @@ informational attributes. >>> # user provides correct token >>> otp.match('359275', time=1475338840) - <TotpMatch counter=49177961 time=1475338840> + <TotpMatch counter=49177961 time=1475338840 cache_seconds=60> As a further optimization, the :meth:`TOTP.verify` method allows deserializing and matching a token in a single step. Not only does this save a little code, diff --git a/passlib/tests/test_totp.py b/passlib/tests/test_totp.py index 4ee4800..1c7c27e 100644 --- a/passlib/tests/test_totp.py +++ b/passlib/tests/test_totp.py @@ -1146,7 +1146,7 @@ class TotpTest(TestCase): # uri (bytes) otp = from_source(b"otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&" - "issuer=Example") + b"issuer=Example") self.assertEqual(otp.key, KEY4_RAW) # dict diff --git a/passlib/totp.py b/passlib/totp.py index 9282070..f097e7c 100644 --- a/passlib/totp.py +++ b/passlib/totp.py @@ -1242,7 +1242,7 @@ class TOTP(object): >>> # token from counter step 30 sec ago (within allowed window) >>> totp.match('000492', 1419622729) - <TotpMatch counter=47320756 time=1419622729> + <TotpMatch counter=47320756 time=1419622729 cache_seconds=60> >>> # invalid token -- token from 60 sec ago (outside of window) >>> totp.match('760389', 1419622729) @@ -1889,7 +1889,8 @@ class TotpMatch(SequenceMixin): return self.counter, self.time def __repr__(self): - return "<TotpMatch counter=%d time=%d>" % self._as_tuple() + args = (self.counter, self.time, self.cache_seconds) + return "<TotpMatch counter=%d time=%d cache_seconds=%d>" % args #============================================================================= # convenience helpers |