Tugas tabel

This commit is contained in:
farrel
2026-09-28 18:27:16 +07:00
parent c7e17bf89e
commit f40a0ab1fd
17 changed files with 862 additions and 35 deletions
+25
View File
@@ -0,0 +1,25 @@
package auth
import "testing"
func TestPasswordAndToken(t *testing.T) {
pass := "secret123"
hash, err := HashPassword(pass)
if err != nil {
t.Fatalf("unexpected error hashing: %v", err)
}
if !CheckPassword(pass, hash) {
t.Fatal("expected password check to succeed")
}
if CheckPassword("wrongpass", hash) {
t.Fatal("expected wrong password to fail")
}
tok, err := GenerateToken()
if err != nil {
t.Fatalf("unexpected error generating token: %v", err)
}
if len(tok) != 64 {
t.Fatalf("expected 64 hex chars, got %d", len(tok))
}
}