gokyle / twofactor

Two-factor authentication.
MIT License
18 stars 10 forks source link

Allow mocking `time` #15

Open colemickens opened 5 years ago

colemickens commented 5 years ago

When I looked, it didn't seem like it was possible to mock the various usages of time.Now making it hard to do nice testing around this library.

Thanks!

kisom commented 5 years ago

Thanks, @colemickens. I've got a PR open to support mocking the clock.

colemickens commented 5 years ago

Thank you, especially for the very fast turnaround. Cheers!

colemickens commented 5 years ago

Actually, I don't really understand how this is usable. It's not exported and there's no setter functionality. I think this should be reopened.

kisom commented 5 years ago

I misunderstood - you want to be able to test this from an external package. I've included support for that now in #17.

dominikschulz commented 5 years ago

Also this change seems to break TOTP. AFAIK the clock needs to be initialised.