Sync shared snapshot from df68167

This commit is contained in:
Gabriel20xx committed 2026-08-06 16:53:48 +02:00
1 parent 588ef139a6
commit 06efc832ca
79 files changed
+10035 -3

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package auth
import (
"testing"
"time"
)
func TestVerifyTOTPRFC6238SHA1Vectors(t *testing.T) {
secret := "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
cases := []struct {
unix int64
code string
}{
{unix: 59, code: "287082"},
{unix: 1111111109, code: "081804"},
{unix: 1111111111, code: "050471"},
{unix: 1234567890, code: "005924"},
{unix: 2000000000, code: "279037"},
}
for _, testCase := range cases {
if !VerifyTOTP(secret, testCase.code, time.Unix(testCase.unix, 0)) {
t.Errorf("VerifyTOTP(%d, %q) = false", testCase.unix, testCase.code)
}
}
}
func TestTOTPProvisioningURI(t *testing.T) {
uri := TOTPProvisioningURI("Example App", "admin@example.com", "abc123")
if uri == "" || len(uri) < len("otpauth://totp/") || uri[:15] != "otpauth://totp/" {
t.Fatalf("unexpected provisioning URI: %q", uri)
}
}