Skip to content

Commit

Permalink
hide other areas that we have the variables visible
Browse files Browse the repository at this point in the history
Signed-off-by: Fokion Sotiropoulos <[email protected]>
  • Loading branch information
fokion committed May 17, 2023
1 parent 1294c0c commit 17b42e1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions venom_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ func init() {
}
}

func (v *Venom) CleanUpSecrets(testSuite *TestSuite) *TestSuite {
func (v *Venom) CleanUpSecrets(testSuite TestSuite) TestSuite {
for _, testCase := range testSuite.TestCases {
ctx := v.processSecrets(context.Background(), testSuite, &testCase)
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.InputVars[i] = HideSensitive(ctx, v)
}
for i, v := range testCase.TestCaseInput.Vars {
testCase.TestCaseInput.Vars[i] = HideSensitive(ctx, v)
}
result.Raw = HideSensitive(ctx, fmt.Sprint(result.Raw))
result.Interpolated = HideSensitive(ctx, fmt.Sprint(result.Interpolated))
result.Systemout = HideSensitive(ctx, result.Systemout)
result.Systemerr = HideSensitive(ctx, result.Systemerr)
}
Expand All @@ -46,7 +51,7 @@ func (v *Venom) OutputResult() error {
if v.OutputDir == "" {
return nil
}

cleanedTs := []TestSuite{}
for i := range v.Tests.TestSuites {
tcFiltered := []TestCase{}
for _, tc := range v.Tests.TestSuites[i].TestCases {
Expand All @@ -55,9 +60,11 @@ func (v *Venom) OutputResult() error {
}
}
v.Tests.TestSuites[i].TestCases = tcFiltered
ts := v.CleanUpSecrets(v.Tests.TestSuites[i])
cleanedTs = append(cleanedTs, ts)

testsResult := &Tests{
TestSuites: []TestSuite{v.Tests.TestSuites[i]},
TestSuites: []TestSuite{ts},
Status: v.Tests.Status,
NbTestsuitesFail: v.Tests.NbTestsuitesFail,
NbTestsuitesPass: v.Tests.NbTestsuitesPass,
Expand Down Expand Up @@ -95,7 +102,7 @@ func (v *Venom) OutputResult() error {
log.Fatalf("Error: you have to use the --html-report flag")
}

fname := strings.TrimSuffix(v.Tests.TestSuites[i].Filepath, filepath.Ext(v.Tests.TestSuites[i].Filepath))
fname := strings.TrimSuffix(ts.Filepath, filepath.Ext(ts.Filepath))
fname = strings.ReplaceAll(fname, "/", "_")
filename := path.Join(v.OutputDir, "test_results_"+fname+"."+v.OutputFormat)
if err := os.WriteFile(filename, data, 0600); err != nil {
Expand All @@ -106,7 +113,7 @@ func (v *Venom) OutputResult() error {

if v.HtmlReport {
testsResult := &Tests{
TestSuites: v.Tests.TestSuites,
TestSuites: cleanedTs,
Status: v.Tests.Status,
NbTestsuitesFail: v.Tests.NbTestsuitesFail,
NbTestsuitesPass: v.Tests.NbTestsuitesPass,
Expand Down

0 comments on commit 17b42e1

Please sign in to comment.