first commit

This commit is contained in:
Sas Andy
2024-12-09 09:51:19 +07:00
commit ecc5dfd9c0
69 changed files with 5365 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package auth
import (
"testing"
)
func TestHashPassword(t *testing.T) {
hash, err := HashPassword("password")
if err != nil {
t.Errorf("error hashing password: %v", err)
}
if hash == "" {
t.Error("expected hash to be not empty")
}
if hash == "password" {
t.Error("expected hash to be different from password")
}
}
func TestComparePasswords(t *testing.T) {
hash, err := HashPassword("password")
if err != nil {
t.Errorf("error hashing password: %v", err)
}
if !ComparePasswords(hash, []byte("password")) {
t.Errorf("expected password to match hash")
}
if ComparePasswords(hash, []byte("notpassword")) {
t.Errorf("expected password to not match hash")
}
}