blob: 81621333df2755b089f14ce56f7fed0eda581cc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)
}
}
|