softplayer-backend/internal/helpers/hash/hash_test.go

22 lines
495 B
Go
Raw Normal View History

package hash_test
import (
"testing"
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/hash"
"github.com/alecthomas/assert/v2"
)
func TestHashValid(t *testing.T) {
2024-03-21 17:39:32 +00:00
password := "qwertyu9"
hpass, err := hash.HashPassword(password, 10)
assert.NoError(t, err)
2024-03-21 20:10:56 +00:00
assert.NoError(t, hash.CheckPasswordHash(password, hpass))
}
func TestHashInvalid(t *testing.T) {
2024-03-21 17:39:32 +00:00
password := "qwertyu9"
invhash := "qwertyu9"
2024-03-21 20:10:56 +00:00
assert.Error(t, hash.CheckPasswordHash(password, invhash))
}