From cd0dd91ab93653631904f2ea0e574ccde6d60339 Mon Sep 17 00:00:00 2001 From: Chia Date: Wed, 5 Aug 2026 14:48:00 +1200 Subject: add passkey, totp. --- internal/controlplane/passkeys_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 internal/controlplane/passkeys_test.go (limited to 'internal/controlplane/passkeys_test.go') diff --git a/internal/controlplane/passkeys_test.go b/internal/controlplane/passkeys_test.go new file mode 100644 index 0000000..8162133 --- /dev/null +++ b/internal/controlplane/passkeys_test.go @@ -0,0 +1,27 @@ +package controlplane + +import ( + "testing" + "time" + + "github.com/go-webauthn/webauthn/webauthn" +) + +func TestEnsureWebAuthnExpirySetsServerSideDeadline(t *testing.T) { + before := time.Now().UTC() + session := &webauthn.SessionData{} + ensureWebAuthnExpiry(session) + if session.Expires.Before(before.Add(webAuthnChallengeTTL-time.Second)) || + session.Expires.After(time.Now().UTC().Add(webAuthnChallengeTTL+time.Second)) { + t.Fatalf("expiry %s is not approximately %s from now", session.Expires, webAuthnChallengeTTL) + } +} + +func TestEnsureWebAuthnExpiryPreservesLibraryDeadline(t *testing.T) { + want := time.Now().UTC().Add(time.Minute) + session := &webauthn.SessionData{Expires: want} + ensureWebAuthnExpiry(session) + if !session.Expires.Equal(want) { + t.Fatalf("expiry = %s, want %s", session.Expires, want) + } +} -- cgit v1.2.3