web console

This commit is contained in:
TenderIronh
2022-02-03 23:43:28 +08:00
parent 7686af39e0
commit 95b46f51d0
17 changed files with 406 additions and 343 deletions
+7 -7
View File
@@ -9,24 +9,24 @@ import (
func TestTOTP(t *testing.T) {
for i := 0; i < 20; i++ {
ts := time.Now().Unix()
code := GenTOTP("testuser1", "testpassword1", ts)
code := GenTOTP(13666999958022769123, ts)
t.Log(code)
if !VerifyTOTP(code, "testuser1", "testpassword1", ts) {
if !VerifyTOTP(code, 13666999958022769123, ts) {
t.Error("TOTP error")
}
if !VerifyTOTP(code, "testuser1", "testpassword1", ts-10) {
if !VerifyTOTP(code, 13666999958022769123, ts-10) {
t.Error("TOTP error")
}
if !VerifyTOTP(code, "testuser1", "testpassword1", ts+10) {
if !VerifyTOTP(code, 13666999958022769123, ts+10) {
t.Error("TOTP error")
}
if VerifyTOTP(code, "testuser1", "testpassword1", ts+60) {
if VerifyTOTP(code, 13666999958022769123, ts+60) {
t.Error("TOTP error")
}
if VerifyTOTP(code, "testuser2", "testpassword1", ts+1) {
if VerifyTOTP(code, 13666999958022769124, ts+1) {
t.Error("TOTP error")
}
if VerifyTOTP(code, "testuser1", "testpassword2", ts+1) {
if VerifyTOTP(code, 13666999958022769125, ts+1) {
t.Error("TOTP error")
}
time.Sleep(time.Second)