meetandeat/runtime/hash_test.go

24 lines
650 B
Go
Raw Permalink Normal View History

2019-03-22 16:35:16 +01:00
package runtime
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestHash(t *testing.T) {
assert := assert.New(t)
password := "root"
x, err := HashValidate("pbkdf2_sha1$10000$a5viM+Paz3o=$orD4shu1Ss+1wPAhAt8hkZ/fH7Y=", password)
assert.True(x, "password is valid")
assert.True(err, "password hesh is outdated")
x, err = HashValidate("pbkdf2_sha256$10000$TnTxDT6fLiE=$v3EGDGIgmgSWXaLYvQYlSf8Lob0=", password)
assert.True(x, "password is valid")
assert.False(err, "password hash is outdated")
hashed := NewHash(password)
expectedBegin := "pbkdf2_sha256$10000$"
assert.Equal(expectedBegin, hashed[:len(expectedBegin)])
}