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