Exported symbols are documented inconsistently and nothing enforces it.
`revive` ships an `exported` rule which would cover part of this,
however the `revive` settings only specify `confidence` and declare no
rules, and golangci-lint v2 runs no `revive` rules at all unless they
are listed, so the gap went unnoticed. `godoclint` is enabled in
preference to configuring `revive` because its rules are individually
selectable, which allows requiring documentation without also adopting
the naming and stuttering checks.
The `require-doc`, `require-pkg-doc` and `require-stdlib-doclink` rules
are enabled alongside the default set and `no-unused-link`. `max-len`
remains disabled as its 77 character default conflicts with the
documentation already in the tree. Test files are excluded because
golangci-lint forces `require-doc` to include them regardless of the
linter configuration, which would otherwise require documentation for
every exported test helper.
This documents 681 exported symbols, adds a package comment to the 34
packages which lack one, and converts 131 plain text references to
standard library identifiers into doc links. Packages of more than one
file carry their comment in `doc.go` following the existing
`experimental/embed/doc.go`, and the single file command packages carry
it above `package main`.
`mockgen` is invoked with `-write_package_comment=false` as the package
comment it writes into the generated mocks is a second package comment
for `internal/authentication` and `internal/notification`. golangci-lint
applies `single-pkg-doc` to test files even though `require-doc` skips
them, so the generated comment cannot satisfy the requirement but does
conflict with the comment which does.
The JSON schemas are regenerated as `authelia-gen` sources the
descriptions of the `internal/configuration/schema` types from their
comments.
Additionally `issues.exclude-dirs` is replaced with
`linters.exclusions.paths` as the former is not part of the version 2
configuration schema. It was silently ignored, so `internal/mocks` was
never excluded and `golangci-lint config verify` failed.
Documenting `ValidateExtra` exposed an inconsistency in it. A single
valued extra attribute whose value has a known type that isn't the
configured type is rejected, however the equivalent multi valued case
fell through the type switch and returned no error, so an `integer`
attribute holding strings validated successfully. The multi valued
branch now returns an error in the same way the single valued branch
does. A regression test covers a multi valued attribute holding strings
against an `integer` `value_type` alongside the existing compatible
cases.
Signed-off-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
This adds a lot of tests to Authelia's backend, with the intention of
bringing us above 80% coverage and attaining the OpenSSF Silver rating.
Closes#6744
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Duo MFA responses now include expiration, transaction ID and
verification code.
* TOTP export can produce per-user PNG images.
* New certificate-pool factory support for customizable system cert
loading.
* **Bug Fixes**
* Unified clock usage across auth, consent, OAuth2/OIDC, sessions and
2FA for consistent timestamps and expiries.
* **Refactor**
* Centralized provider initialization and standardized random/clock
construction; improved Duo error handling and logging; CLI I/O
decoupled.
* **Chores**
* CLI exit codes adjusted to treat config-creation as successful.
* **Tests**
* Added/updated tests for crypto, debug, Duo, TOTP, OAuth2/OIDC and many
CLI flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Co-authored-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>