diff --git a/core/pkg/resultshandling/reporter/v2/mockreporter.go b/core/pkg/resultshandling/reporter/v2/mockreporter.go index 6b6a0026..d4d0b74c 100644 --- a/core/pkg/resultshandling/reporter/v2/mockreporter.go +++ b/core/pkg/resultshandling/reporter/v2/mockreporter.go @@ -32,19 +32,20 @@ func (reportMock *ReportMock) SetClusterName(clusterName string) { } func (reportMock *ReportMock) GetURL() string { - return getter.GetArmoAPIConnector().GetFrontendURL() -} - -func (reportMock *ReportMock) DisplayReportURL() { - u := fmt.Sprintf("https://%s/account/login", getter.GetArmoAPIConnector().GetFrontendURL()) + u := fmt.Sprintf("https://%s/account/sign-up", getter.GetArmoAPIConnector().GetFrontendURL()) if reportMock.query != "" { u += fmt.Sprintf("?%s", reportMock.query) } + return u +} + +func (reportMock *ReportMock) DisplayReportURL() { + sep := "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" message := sep + "\n" message += "Scan results have not been submitted: " + reportMock.message + "\n" message += "Sign up for free: " - message += u + "\n" + message += reportMock.GetURL() + "\n" message += sep + "\n" cautils.InfoTextDisplay(os.Stderr, fmt.Sprintf("\n%s\n", message)) } diff --git a/core/pkg/resultshandling/reporter/v2/reporteventreceive_test.go b/core/pkg/resultshandling/reporter/v2/reporteventreceive_test.go new file mode 100644 index 00000000..264ba14e --- /dev/null +++ b/core/pkg/resultshandling/reporter/v2/reporteventreceive_test.go @@ -0,0 +1,48 @@ +package v2 + +import ( + "testing" + + "github.com/armosec/kubescape/v2/core/cautils" + "github.com/stretchr/testify/assert" +) + +func TestGetURL(t *testing.T) { + // Test submit and registered url + { + reporter := NewReportEventReceiver( + &cautils.ConfigObj{ + AccountID: "1234", + Token: "token", + CustomerAdminEMail: "my@email", + ClusterName: "test", + }, + "", + ) + assert.Equal(t, "https://portal.armo.cloud/configuration-scanning/test?utm_campaign=Submit&utm_medium=CLI&utm_source=GitHub", reporter.GetURL()) + } + + // Test submit and NOT registered url + { + + reporter := NewReportEventReceiver( + &cautils.ConfigObj{ + AccountID: "1234", + Token: "token", + ClusterName: "test", + }, + "", + ) + assert.Equal(t, "https://portal.armo.cloud/account/sign-up?customerGUID=1234&invitationToken=token&utm_campaign=Submit&utm_medium=CLI&utm_source=GitHub", reporter.GetURL()) + } + // Test None submit url + { + reporter := NewReportMock(NO_SUBMIT_QUERY, "") + assert.Equal(t, "https://portal.armo.cloud/account/sign-up?utm_source=GitHub&utm_medium=CLI&utm_campaign=no_submit", reporter.GetURL()) + } + // Test None report url + { + reporter := NewReportMock("", "") + assert.Equal(t, "https://portal.armo.cloud/account/sign-up", reporter.GetURL()) + } +} diff --git a/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go b/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go index 40d916e5..9cc00a8a 100644 --- a/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go +++ b/core/pkg/resultshandling/reporter/v2/reporteventreceiver.go @@ -98,7 +98,6 @@ func (report *ReportEventReceiver) GetURL() string { u.Path = fmt.Sprintf("configuration-scanning/%s", report.clusterName) } else { u.Path = "account/sign-up" - q := u.Query() q.Add("invitationToken", report.token) q.Add("customerGUID", report.customerGUID) }