From e2af279c3dece486e5b1ece729e8c60c083899ac Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Fri, 20 Dec 2024 21:37:32 +0500 Subject: [PATCH] [Fix] detector's integration tests starting with alphabet 'm' (#3807) * ignore extraData and analysisInfo in mailchimp integration test. * Ignore ExtraData in Mailchimp and Mailgun integration test. * Exclude RawV2 values from integration test of mux detector. * Exclude RawV2 values from integration test of mux detector. --- pkg/detectors/mailchimp/mailchimp_integration_test.go | 1 + pkg/detectors/mailgun/mailgun_integration_test.go | 1 + .../mattermostpersonaltoken_integration_test.go | 7 ++++++- pkg/detectors/mux/mux_integration_test.go | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/detectors/mailchimp/mailchimp_integration_test.go b/pkg/detectors/mailchimp/mailchimp_integration_test.go index c181fd5674da..d524439ef7f9 100644 --- a/pkg/detectors/mailchimp/mailchimp_integration_test.go +++ b/pkg/detectors/mailchimp/mailchimp_integration_test.go @@ -94,6 +94,7 @@ func TestMailchimp_FromChunk(t *testing.T) { } got[i].Raw = nil got[i].AnalysisInfo = nil + got[i].ExtraData = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("Mailchimp.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/mailgun/mailgun_integration_test.go b/pkg/detectors/mailgun/mailgun_integration_test.go index 0b887ce2c37e..65f7934ec377 100644 --- a/pkg/detectors/mailgun/mailgun_integration_test.go +++ b/pkg/detectors/mailgun/mailgun_integration_test.go @@ -130,6 +130,7 @@ func TestMailgun_FromChunk(t *testing.T) { } got[i].Raw = nil got[i].AnalysisInfo = nil + got[i].ExtraData = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("Mailgun.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_integration_test.go b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_integration_test.go index b1db37b782a1..26b9605619d0 100644 --- a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_integration_test.go +++ b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_integration_test.go @@ -60,7 +60,7 @@ func TestMattermostPersonalToken_FromChunk(t *testing.T) { s: Scanner{}, args: args{ ctx: context.Background(), - data: []byte(fmt.Sprintf("You can find a mattermost secret %s within mattermost server %s but not valid", inactiveSecret, "test323561.cloud.mattermost.com")), // the secret would satisfy the regex but not pass validation + data: []byte(fmt.Sprintf("You can find a mattermost secret %s within mattermost server %s but not valid", inactiveSecret, server)), // the secret would satisfy the regex but not pass validation verify: true, }, want: []detectors.Result{ @@ -96,6 +96,11 @@ func TestMattermostPersonalToken_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } got[i].Raw = nil + + if len(got[i].RawV2) == 0 { + t.Fatalf("no RawV2 secret present: \n %+v", got[i]) + } + got[i].RawV2 = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("MattermostPersonalToken.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/mux/mux_integration_test.go b/pkg/detectors/mux/mux_integration_test.go index 871b44a7a35d..ec8427b86542 100644 --- a/pkg/detectors/mux/mux_integration_test.go +++ b/pkg/detectors/mux/mux_integration_test.go @@ -97,6 +97,11 @@ func TestMux_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } got[i].Raw = nil + + if len(got[i].RawV2) == 0 { + t.Fatalf("no rawv2 secret present: \n %+v", got[i]) + } + got[i].RawV2 = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("Mux.FromData() %s diff: (-got +want)\n%s", tt.name, diff)