milvus/internal/util/crypto/crypto_test.go
codeman 4e12271d79
Support login with username and password (#15656) (#16341)
Signed-off-by: kejiang <ke.jiang@zilliz.com>

Co-authored-by: kejiang <ke.jiang@zilliz.com>
2022-04-11 19:49:34 +08:00

16 lines
416 B
Go

package crypto
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPasswordVerify(t *testing.T) {
wrongPassword := "test_my_name"
correctPassword := "test_my_pass_new"
hashedPass, _ := PasswordEncrypt(correctPassword)
assert.True(t, PasswordVerify(correctPassword, "$2a$10$3H9DLiHyPxJ29bMWRNyueOrGkbzJfE3BAR159ju3UetytAoKk7Ne2"))
assert.False(t, PasswordVerify(wrongPassword, hashedPass))
}