24 lines
650 B
Go
24 lines
650 B
Go
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)])
|
|
}
|