Rename the module, proto service, and all identifiers from simple_bank/ SimpleBank to api_tmpl/ApiTmpl, and regenerate the gRPC/gateway/swagger/ mock code accordingly. - Scrub real secrets (SMTP password, auth token secret) from api.env/ api_test.env, untrack them, and add api.env.example/api_test.env.example - Remove committed build artifacts (tmp/main, tmp/build-errors.log, dbml-error.log) and gitignore them going forward - Fix Dockerfile paths (build target, migrations copy) that referenced a stale project layout - Rewrite README to match the actual cmd/ + internal/ structure and add a "using this as a template" section
30 lines
677 B
Go
30 lines
677 B
Go
package security
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/FernandoJVideira/api_tmpl/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)
|
|
}
|