Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Added kubescape survery link at the bottom #1491

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/core/initutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ func getReporter(ctx context.Context, tenantConfig cautils.ITenantConfig, report
// Add link only when scanning a cluster using a framework
return reporterv2.NewReportMock("", "")
}
var message string

message := "Please fill a 3 question survey to help the Kubescape project! https://kubescape.io/project/survey/"

if !fwScan && scanInfo.ScanType != cautils.ScanTypeWorkload {
message = "Kubescape does not submit scan results when scanning controls"
Expand Down
26 changes: 26 additions & 0 deletions core/core/initutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package core

import (
"context"
"io"
"os"
"reflect"
"testing"

Expand Down Expand Up @@ -229,3 +231,27 @@ func TestIsScanTypeForSubmission(t *testing.T) {
})
}
}

func TestGetReporter_MessageSurvey(t *testing.T) {
ctx := context.TODO()
tenantConfig := cautils.GetTenantConfig("Test", "Fake Access key", "Temp cluster", "", nil)
reportID := "your-report-id"
submit := false
fwScan := false
scanInfo := cautils.ScanInfo{ScanType: cautils.ScanTypeWorkload}
result := getReporter(ctx, tenantConfig, reportID, submit, fwScan, scanInfo)

// Redirect stdout to a buffer
rescueStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w

result.DisplayMessage()

w.Close()
got, _ := io.ReadAll(r)
os.Stdout = rescueStdout

want := "Please fill a 3 question survey to help the Kubescape project! https://kubescape.io/project/survey/"
assert.Equal(t, want, string(got))
}