- Tests hash passwords at bcrypt.MinCost through db.PasswordCost. - Test IRC servers check the queue only on broker notification; one test keeps the 100 ms fallback poll. - The stop-timeout test shortens the timeout through a test-only setter. - service and handlers tests build config.Config directly instead of through config.New, so they run in parallel: service had run serially, and handlers started its servers one at a time. - Repeated race trials run as parallel subtests. - Fixed sleeps become waits on the broker. - A new test covers the relay's failed queue read, which only the 100 ms poll had reached. Model: opus-5-5
This commit is contained in:
1 parent
bc8aa6bb96
commit
c492e5969e
11 files changed
+356
-198
No files matched your search
+5
-1
@@ -14,6 +14,10 @@ var errNoPassword = errors.New(
|
||||
"account has no password set",
|
||||
)
|
||||
|
||||
// PasswordCost is the bcrypt cost at which SetPassword hashes a
|
||||
// password. Tests lower it to bcrypt.MinCost before they start.
|
||||
var PasswordCost = bcrypt.DefaultCost //nolint:gochecknoglobals // tests lower it
|
||||
|
||||
// SetPassword sets a bcrypt-hashed password on a session,
|
||||
// enabling multi-client login via POST /api/v1/login.
|
||||
func (database *Database) SetPassword(
|
||||
@@ -22,7 +26,7 @@ func (database *Database) SetPassword(
|
||||
password string,
|
||||
) error {
|
||||
hash, err := bcrypt.GenerateFromPassword(
|
||||
[]byte(password), bcrypt.DefaultCost,
|
||||
[]byte(password), PasswordCost,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("hash password: %w", err)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx/fxtest"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"sneak.berlin/go/neoirc/internal/config"
|
||||
"sneak.berlin/go/neoirc/internal/db"
|
||||
"sneak.berlin/go/neoirc/internal/dbtest"
|
||||
@@ -29,6 +30,13 @@ const (
|
||||
endlessQueryTimeout = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// A password hashed at full cost takes seconds under -race.
|
||||
db.PasswordCost = bcrypt.MinCost
|
||||
|
||||
m.Run()
|
||||
}
|
||||
|
||||
// TestDefaultDBURLSetsWALAndBusyTimeout opens a file database
|
||||
// with the default URL's parameters the way the server does,
|
||||
// and checks the journal mode and busy timeout it ends up with.
|
||||
|
||||
Reference in new issue
Block a user