All checks were successful
check / check (push) Successful in 3s
Bumps golangci-lint from v2.11.3 to v2.12.2 and adopts the canonical lint config. ## Version pins - `Dockerfile`: `golangci/golangci-lint:v2.12.2` Debian image, pinned by digest, dated `2026-08-07` - `script/bootstrap`: `GOLANGCI_LINT_VERSION=2.12.2` with updated sha256 pins for the `linux-amd64` and `linux-arm64` release archives ## Config `.golangci.yml` replaced with the canonical config. The previous file kept `lll`/`funlen`/`cyclop`/`dupl` settings under the top-level `linters-settings` key, which the v2 schema ignores; the canonical config nests them under `linters.settings`, so those thresholds now actually apply. The unsupported `issues.exclude-use-default` key was dropped. ## Lint fixes (32 findings) - `lll` (7): wrapped or shortened over-length lines (struct tag comments moved above fields, test logger construction split, `session.NewForTest` signature wrapped, shortened a `#nosec` comment) - `goconst` (17): replaced repeated `"POST"`/`"PUT"` literals with `http.MethodPost`/`http.MethodPut`, added shared test constants for `webhooker-test`/`test`/`application/json`, and added `tmplKeyError`/`tmplKeyWebhook` constants for template data keys in `internal/handlers` - `dupl` (8): merged `buildHTTPTargetConfig` and `buildSlackTargetConfig` into a parameterized `buildURLTargetConfig`; removed the duplicate `iWebhookDB` test helper in favor of `testWebhookDB`; extracted shared helpers in middleware and session tests No `//nolint` directives were added and behavior is unchanged. `make check` (fmt-check, tests, lint) passes. Note: golangci-lint v2.12 deprecates the `gomodguard` linter in favor of `gomodguard_v2`; the canonical config change for that is left for a future coordinated update. Co-authored-by: sneak <sneak@sneak.berlin> Reviewed-on: #86 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
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,
|
|
}
|
|
}
|