Verify Audita shared inputs and diagnostics
This commit is contained in:
@@ -149,6 +149,24 @@ func TestSubprocessRunnerPreservesFailureAndAvailableReports(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubprocessRunnerFindsFailureReportsInRequestedDirectory(t *testing.T) {
|
||||
runner := auditaTestRunner(t, SubprocessRunnerConfig{})
|
||||
req := auditaTestRequest(t)
|
||||
req.ReportDir = filepath.Join(t.TempDir(), "logs")
|
||||
if err := os.MkdirAll(req.ReportDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
failure := errors.New("synthetic audita failure")
|
||||
runner.run = func(context.Context, subprocess.RunRequest) (subprocess.RunResult, error) {
|
||||
writeAuditaTestFile(t, filepath.Join(req.ReportDir, "errors.yml"), "status: failed\n")
|
||||
return subprocess.RunResult{ExitCode: 1}, failure
|
||||
}
|
||||
result, err := runner.Run(context.Background(), req)
|
||||
if !errors.Is(err, failure) || result.Reports.ErrorsPath != filepath.Join(req.ReportDir, "errors.yml") {
|
||||
t.Fatalf("result = %#v, error = %v", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubprocessRunnerDoesNotMaskProcessFailureWithReportError(t *testing.T) {
|
||||
runner := auditaTestRunner(t, SubprocessRunnerConfig{})
|
||||
req := auditaTestRequest(t)
|
||||
|
||||
Reference in New Issue
Block a user