diff --git a/process_testcase.go b/process_testcase.go index 2ad74e14..37070ae0 100644 --- a/process_testcase.go +++ b/process_testcase.go @@ -141,8 +141,17 @@ func (v *Venom) runTestCase(ctx context.Context, ts *TestSuite, tc *TestCase) { tc.Vars.AddAll(ts.ComputedVars) tc.computedVars = H{} - computedSecrets := []string{} + ctx = v.processSecrets(ctx, ts, tc) + + Info(ctx, "Starting testcase") + + defer Info(ctx, "Ending testcase") + // ##### RUN Test Steps Here + v.runTestSteps(ctx, tc, nil) +} +func (v *Venom) processSecrets(ctx context.Context, ts *TestSuite, tc *TestCase) context.Context { + computedSecrets := []string{} for k, v := range tc.Vars { for _, s := range ts.Secrets { if strings.Compare(k, s) == 0 { @@ -150,13 +159,7 @@ func (v *Venom) runTestCase(ctx context.Context, ts *TestSuite, tc *TestCase) { } } } - ctx = context.WithValue(ctx, ContextKey("secrets"), computedSecrets) - - Info(ctx, "Starting testcase") - - defer Info(ctx, "Ending testcase") - // ##### RUN Test Steps Here - v.runTestSteps(ctx, tc, nil) + return context.WithValue(ctx, ContextKey("secrets"), computedSecrets) } func (v *Venom) runTestSteps(ctx context.Context, tc *TestCase, tsIn *TestStepResult) { diff --git a/venom_output.go b/venom_output.go index a10e9eb7..aa669dca 100644 --- a/venom_output.go +++ b/venom_output.go @@ -2,6 +2,7 @@ package venom import ( "bytes" + "context" "encoding/json" "encoding/xml" "fmt" @@ -23,6 +24,23 @@ func init() { } } +func (v *Venom) CleanUpSecrets(testSuite *TestSuite) *TestSuite { + for _, testCase := range testSuite.TestCases { + ctx := v.processSecrets(context.Background(), testSuite, &testCase) + for _, result := range testCase.TestStepResults { + for i, v := range result.ComputedVars { + result.ComputedVars[i] = HideSensitive(ctx, v) + } + for i, v := range result.InputVars { + result.ComputedVars[i] = HideSensitive(ctx, v) + } + result.Systemout = HideSensitive(ctx, result.Systemout) + result.Systemerr = HideSensitive(ctx, result.Systemerr) + } + } + return testSuite +} + // OutputResult output result to sdtout, files... func (v *Venom) OutputResult() error { if v.OutputDir == "" {