Back to Authelia

Testing

docs/content/contributing/guidelines/testing.md

4.39.207.2 KB
Original Source

The following outlines the specific requirements we have for testing the Authelia code contributions.

  • While we aim for 100% coverage on changes and additions, we do not enforce this where it doesn't make practical sense:
    • A test which just marks a line as tested is not necessarily an effectual test
    • Sometimes there is limited ways in which tests can be performed and the limitation makes the test ineffectual
  • Tests should be named to reflect what they testing for and which part of the code they are testing
  • It's required for bug fixes that contributors create a test that fails prior to and passes subsequent to the fix being applied, this test must be included in the contribution, excluding this test will likely result in the fix being rejected unless explicitly agreed and advised otherwise by the core team
  • It's strongly encouraged for features that contributors create have as much testing as is reasonable i.e. any line that can be tested should be tested, if the line can't be tested generally this is an indication a refactor may be required

Testing Methodology and Frequency

We run tests across multiple frameworks and platforms, and employ both SAST and DAST tooling to detect known security issues in the code. The rationale for this approach is that, while using multiple tools may increase noise, it improves confidence by providing more data on which to base our judgment.

ToolPurposeNotes
Go TestCoverage, Static and Dynamic Code AnalysisAnalysis of Go Code, Executed with go test -cover, go test -race, and go test -fuzz before and on every commit to master
React Testing LibraryCoverage, Static and Dynamic Code AnalysisAnalysis of React Code before and on every commit to master
SonarQubeStatic Code AnalysisAnalysis of All Code before and on every commit to master
CodeQLStatic Code AnalysisAnalysis of All Code before and on every commit to master, and on a schedule
CodecovCoverage StatisticsProduces Statistics for Go and TypeScript before and on every commit to master
GrypeVulnerability ManagementSBOM Scanning Only before and on every commit to master
RenovateVulnerability and Dependency ManagementOn a schedule
golangci-LintStatic Code AnalysisAnalysis of Go Code before and on every commit to master
GitGuardianSecrets ManagementAnalysis of Secrets before and on every commit to master
Code RabbitQuality and Security AssessmentAnalysis of General Pull Requests before every commit to master
OpenSSF ScorecardSecurity Practices AssessmentAutomated on every new commit to master
OpenSSF Best PracticesSecurity Practices AssessmentManual Assessment for Security Practice Posture Improvements
StepSecurity Harden-RunnerCI Agent SecurityAs Part of any Job Running in GitHub CI Job Runners
zizmorGitHub Action Static Code AnalysisPrevents Security Issues with GitHub Actions

Linting

In addition to the above SAST and DAST tools we also implement several linters which ensure code quality and consistency. These linters generally run via lefthook which is installed as a git hook.

ToolAreaPurpose
golangci-LintGoCode Quality and Consistency of Go Code
goimports-reviserGoImport Order Consistency
ESLintJavaScript and TypeScriptCode Quality and Consistency of JS/TS Code
ShellCheckShell FilesCode Quality and Consistency
yamllintYAML FilesConsistent YAML Formatting
commitlintGitEnsure Conformant Commit Messages
TruffleHogAllPreventing Secret Commit Accidents
typosAllPreventing Spelling and General Typos