2024-03-19 16:20:32 +00:00
|
|
|
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))
|
2024-03-19 16:20:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
2024-03-19 16:20:32 +00:00
|
|
|
}
|