feat: 0.0.1
This commit is contained in:
146 files changed
+10444
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPassword(t *testing.T) {
|
||||
password := testutil.RandomString(6)
|
||||
|
||||
hashedPassword, err := HashPassword(password)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hashedPassword)
|
||||
|
||||
err = CheckPassword(password, hashedPassword)
|
||||
require.NoError(t, err)
|
||||
|
||||
wrongPassword := testutil.RandomString(6)
|
||||
err = CheckPassword(wrongPassword, hashedPassword)
|
||||
require.Error(t, err)
|
||||
|
||||
hashedPassword2, err := HashPassword(password)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, hashedPassword2)
|
||||
|
||||
require.NotEqual(t, hashedPassword, hashedPassword2)
|
||||
}
|
||||
Reference in new issue
Block a user