Inicial
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package auth_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/techxcar/backend/internal/auth"
|
||||
)
|
||||
|
||||
func TestHashPassword_isNotPlaintext(t *testing.T) {
|
||||
hash, err := auth.HashPassword("mysecret")
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "mysecret", hash)
|
||||
assert.NotEmpty(t, hash)
|
||||
}
|
||||
|
||||
func TestVerifyPassword_correct(t *testing.T) {
|
||||
hash, err := auth.HashPassword("correctpassword")
|
||||
require.NoError(t, err)
|
||||
assert.True(t, auth.VerifyPassword("correctpassword", hash))
|
||||
}
|
||||
|
||||
func TestVerifyPassword_wrong(t *testing.T) {
|
||||
hash, err := auth.HashPassword("correctpassword")
|
||||
require.NoError(t, err)
|
||||
assert.False(t, auth.VerifyPassword("wrongpassword", hash))
|
||||
}
|
||||
Reference in New Issue
Block a user