3
0
corteza/sam/user.structs_test.go
Denis Arh 341c845c80 Add password encryption for User.
Took 25 minutes
2018-07-06 09:10:53 +02:00

25 lines
525 B
Go

package sam
import (
"testing"
)
func TestUser_SetPassword(t *testing.T) {
const dummyPwd = "Lorem ipsum dolor sit amet, consectetur adipiscing elit..."
dummy := &User{}
initChLen := len(dummy.changed)
dummy.SetPassword(dummyPwd)
if dummyPwd == string(dummy.Password) {
t.Error("Internal password value should be encrypted")
}
if len(dummy.changed) <= initChLen {
t.Error("Password change should be recorded")
}
if !dummy.ValidatePassword(dummyPwd) {
t.Error("Revalidating password should succeed")
}
}