From 71a781776ab6014ca31344d17fa4e7189d305252 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 6 Dec 2018 08:07:27 -0800 Subject: [PATCH] Support clock mocking. This addresses #15. --- Gopkg.lock | 8 +++++++- Gopkg.toml | 4 ++++ totp.go | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index d8c94aa..108681f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,6 +1,12 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. +[[projects]] + branch = "master" + name = "github.com/benbjohnson/clock" + packages = ["."] + revision = "7dc76406b6d3c05b5f71a86293cbcf3c4ea03b19" + [[projects]] branch = "master" name = "rsc.io/qr" @@ -14,6 +20,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b705d306da5a78e76b7ff289744770eef56328a4f0d1c615c1a233d056283651" + inputs-digest = "6f47334a8fcf2bb48e739e6181089e02bce6cc4d68888be311df3827db96f8ae" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index e2fd13b..a57d8a0 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -32,3 +32,7 @@ [prune] go-tests = true unused-packages = true + +[[constraint]] + branch = "master" + name = "github.com/benbjohnson/clock" diff --git a/totp.go b/totp.go index 789de4a..f8e41b1 100644 --- a/totp.go +++ b/totp.go @@ -11,9 +11,12 @@ import ( "net/url" "strconv" "strings" - "time" + + "github.com/benbjohnson/clock" ) +var time clock.Clock + // TOTP represents an RFC 6238 Time-based One-Time Password instance. type TOTP struct { *OATH