2019-04-25 04:52:08 +07:00
|
|
|
package authentication
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestShouldHashPassword(t *testing.T) {
|
2019-11-02 01:31:51 +07:00
|
|
|
hash := HashPassword("password", "$6$rounds=50000$aFr56HjK3DrB8t3S")
|
|
|
|
assert.Equal(t, "$6$rounds=50000$aFr56HjK3DrB8t3S$zhPQiS85cgBlNhUKKE6n/AHMlpqrvYSnSL3fEVkK0yHFQ.oFFAd8D4OhPAy18K5U61Z2eBhxQXExGU/eknXlY1", hash)
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestShouldCheckPassword(t *testing.T) {
|
2019-11-02 01:31:51 +07:00
|
|
|
ok, err := CheckPassword("password", "$6$rounds=50000$aFr56HjK3DrB8t3S$zhPQiS85cgBlNhUKKE6n/AHMlpqrvYSnSL3fEVkK0yHFQ.oFFAd8D4OhPAy18K5U61Z2eBhxQXExGU/eknXlY1")
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.True(t, ok)
|
|
|
|
}
|