mirror of
https://github.com/volatiletech/authboss.git
synced 2025-07-07 00:55:37 +02:00
30 lines
475 B
Go
30 lines
475 B
Go
package defaults
|
|
|
|
import (
|
|
"golang.org/x/crypto/bcrypt"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestHasher(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
hasher := NewBCryptHasher(bcrypt.DefaultCost)
|
|
|
|
hash, err := hasher.GenerateHash("qwerty")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if hash == "" {
|
|
t.Error("Result Hash must be not empty")
|
|
|
|
}
|
|
if len(hash) != 60 {
|
|
t.Error("hash was invalid length", len(hash))
|
|
}
|
|
if !strings.HasPrefix(hash, "$2a$10$") {
|
|
t.Error("hash was wrong", hash)
|
|
}
|
|
}
|