All checks were successful
check / check (push) Successful in 2m51s
Bump the golangci-lint Docker image pin in Dockerfile and the release-archive sha256 pins in script/bootstrap from 2.11.3 to 2.12.2, and replace .golangci.yml with the canonical config. The canonical config moves lll/funlen/cyclop/dupl settings from the top-level linters-settings key (ignored by the v2 schema) to linters.settings, so those thresholds now actually apply. Fix all findings the newly applied thresholds surfaced: - lll: wrap or shorten seven over-length lines (struct tag comments, test logger construction, a func signature, and a nosec comment) - goconst: use http.MethodPost/http.MethodPut and new shared constants for repeated test strings; add tmplKeyError and tmplKeyWebhook constants for template data keys in handlers - dupl: merge buildHTTPTargetConfig and buildSlackTargetConfig into a parameterized buildURLTargetConfig; drop the duplicate iWebhookDB test helper in favor of testWebhookDB; extract shared helpers in middleware and session tests
28 lines
651 B
Go
28 lines
651 B
Go
package session
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/gorilla/sessions"
|
|
"sneak.berlin/go/webhooker/internal/config"
|
|
)
|
|
|
|
// NewForTest creates a Session with a pre-configured cookie store for use
|
|
// in tests. This bypasses the fx lifecycle and database dependency, allowing
|
|
// middleware and handler tests to use real session functionality. The key
|
|
// parameter is the raw 32-byte authentication key used for session encryption
|
|
// and CSRF cookie signing.
|
|
func NewForTest(
|
|
store *sessions.CookieStore,
|
|
cfg *config.Config,
|
|
log *slog.Logger,
|
|
key []byte,
|
|
) *Session {
|
|
return &Session{
|
|
store: store,
|
|
key: key,
|
|
config: cfg,
|
|
log: log,
|
|
}
|
|
}
|