mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 09:32:45 +01:00
Backend `rest-*` shards became the slowest PR checks on `Pulse` after Vitest partitioning (`#5331`), with `internal/config`, `internal/api/configapi`, and `cmd/pulse-agent` spending hundreds of seconds under `-race` on 600,000-iteration PBKDF2 calls, default-cost bcrypt hashing, and `-p=1`-serialized `go build` invocations. - Add a test-only `PULSE_TEST_EXPORT_PBKDF2_ITERATIONS` override (`1000..600000`) in `internal/config/export.go`, gated strictly on `.test`/`.test.exe` executables just like `pkg/auth/password.go` (`PULSE_TEST_BCRYPT_COST`). Production binaries always use `600000` and `100000` legacy fallback. - Add `TestMain` for `internal/config` and `internal/api/configapi` and wire `internal/api/main_test.go` to use bounded test KDF parameters while preserving explicit real `600000`/`100000` roundtrip and legacy compatibility tests (`TestExportPBKDF2ProductionDefaultsAndTestOverrideGuard`, `TestHandleImportConfigAcceptsLegacyVersion40Bundle`). - Remove hardcoded `-p=1` from `cmd/pulse-agent/release_identity_test.go` so test builds respect `GOMAXPROCS` (`2` in CI) without altering build flags or release-identity verification. Contract-Neutral: Test-only PBKDF2 override gated strictly on .test/.test.exe executables; production 600000/100000 KDF defaults, archive wire format, and API contracts are unchanged. Change-source: pulse-maintainer
20 lines
412 B
Go
20 lines
412 B
Go
package configapi
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
if _, ok := os.LookupEnv("PULSE_TEST_BCRYPT_COST"); !ok {
|
|
_ = os.Setenv("PULSE_TEST_BCRYPT_COST", strconv.Itoa(bcrypt.MinCost))
|
|
}
|
|
if _, ok := os.LookupEnv("PULSE_TEST_EXPORT_PBKDF2_ITERATIONS"); !ok {
|
|
_ = os.Setenv("PULSE_TEST_EXPORT_PBKDF2_ITERATIONS", "1000")
|
|
}
|
|
os.Exit(m.Run())
|
|
}
|