test: Replace hardcoded test password with a named variable in api_test.go and add api.test.

This commit is contained in:
Haitao Pan 2026-02-06 12:29:10 +08:00
parent ba85a0236b
commit 882378e328
2 changed files with 6 additions and 6 deletions

BIN
api.test Executable file

Binary file not shown.

View File

@ -1329,8 +1329,8 @@ func TestAdminUsersMetricsForbiddenForStandardUser(t *testing.T) {
RegisterRoutes(router, WithStore(st), WithEmailVerification(false), WithUserMetricsProvider(provider))
v := "s"
hashed, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
testPass := "scrubbed"
hashed, err := bcrypt.GenerateFromPassword([]byte(testPass), bcrypt.DefaultCost)
if err != nil {
t.Fatalf("failed to hash password: %v", err)
}
@ -1349,7 +1349,7 @@ func TestAdminUsersMetricsForbiddenForStandardUser(t *testing.T) {
loginPayload := map[string]string{
"identifier": user.Email,
"password": password,
"password": testPass,
}
body, err := json.Marshal(loginPayload)
if err != nil {
@ -1418,8 +1418,8 @@ func TestAdminUsersMetricsSuccess(t *testing.T) {
RegisterRoutes(router, WithStore(st), WithEmailVerification(false), WithUserMetricsProvider(provider))
v := "s"
hashed, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
testPass := "scrubbed"
hashed, err := bcrypt.GenerateFromPassword([]byte(testPass), bcrypt.DefaultCost)
if err != nil {
t.Fatalf("failed to hash password: %v", err)
}
@ -1438,7 +1438,7 @@ func TestAdminUsersMetricsSuccess(t *testing.T) {
loginPayload := map[string]string{
"identifier": admin.Email,
"password": password,
"password": testPass,
}
body, err := json.Marshal(loginPayload)
if err != nil {