From c24b4d5b30f6348ebb7c30dc4373a5f1ac7319d9 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 11 Dec 2024 22:23:02 +0500 Subject: [PATCH] [Fix] detector's integration tests starting with alphabet 'g' (#3765) * fix geocodio detector test * fix github detector test * fix githubapp detector test * fix gitlab v2 detector * fix godaddy v1 detector test --- pkg/detectors/geocodio/geocodio_integration_test.go | 4 ++++ pkg/detectors/github/v2/github_integration_test.go | 3 +++ pkg/detectors/githubapp/githubapp_integration_test.go | 1 + pkg/detectors/gitlab/v2/gitlab_integration_test.go | 2 ++ pkg/detectors/godaddy/v1/godaddy_integration_test.go | 1 + 5 files changed, 11 insertions(+) diff --git a/pkg/detectors/geocodio/geocodio_integration_test.go b/pkg/detectors/geocodio/geocodio_integration_test.go index bdf085620357..79feb334d42e 100644 --- a/pkg/detectors/geocodio/geocodio_integration_test.go +++ b/pkg/detectors/geocodio/geocodio_integration_test.go @@ -96,6 +96,10 @@ func TestGeocodio_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 raw v2 secret present: \n %+v", got[i]) + } + got[i].RawV2 = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("Geocodio.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/github/v2/github_integration_test.go b/pkg/detectors/github/v2/github_integration_test.go index a6db2700ec91..8cccb1105e6b 100644 --- a/pkg/detectors/github/v2/github_integration_test.go +++ b/pkg/detectors/github/v2/github_integration_test.go @@ -205,6 +205,8 @@ func TestGitHub_FromChunk(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := Scanner{} + s.UseCloudEndpoint(true) + s.SetCloudEndpoint(s.CloudEndpoint()) got, err := s.FromData(tt.args.ctx, tt.args.verify, tt.args.data) if (err != nil) != tt.wantErr { t.Errorf("GitHub.FromData() error = %v, wantErr %v", err, tt.wantErr) @@ -215,6 +217,7 @@ func TestGitHub_FromChunk(t *testing.T) { t.Fatal("no raw secret present") } got[i].Raw = nil + got[i].AnalysisInfo = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("GitHub.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/githubapp/githubapp_integration_test.go b/pkg/detectors/githubapp/githubapp_integration_test.go index b23269fd3169..4424405a98cd 100644 --- a/pkg/detectors/githubapp/githubapp_integration_test.go +++ b/pkg/detectors/githubapp/githubapp_integration_test.go @@ -101,6 +101,7 @@ func TestGitHubApp_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } got[i].Raw = nil + got[i].ExtraData = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("GitHubApp.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/gitlab/v2/gitlab_integration_test.go b/pkg/detectors/gitlab/v2/gitlab_integration_test.go index 69fc6693e518..f10683d84cab 100644 --- a/pkg/detectors/gitlab/v2/gitlab_integration_test.go +++ b/pkg/detectors/gitlab/v2/gitlab_integration_test.go @@ -264,6 +264,8 @@ func TestGitlabV2_FromChunk(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + tt.s.UseCloudEndpoint(true) + tt.s.SetCloudEndpoint(tt.s.CloudEndpoint()) got, err := tt.s.FromData(tt.args.ctx, tt.args.verify, tt.args.data) if (err != nil) != tt.wantErr { t.Errorf("Gitlab.FromData() error = %v, wantErr %v", err, tt.wantErr) diff --git a/pkg/detectors/godaddy/v1/godaddy_integration_test.go b/pkg/detectors/godaddy/v1/godaddy_integration_test.go index b72e8776f9d6..98233eb9d093 100644 --- a/pkg/detectors/godaddy/v1/godaddy_integration_test.go +++ b/pkg/detectors/godaddy/v1/godaddy_integration_test.go @@ -95,6 +95,7 @@ func TestGoDaddy_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } got[i].Raw = nil + got[i].ExtraData = nil } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("GoDaddy.FromData() %s diff: (-got +want)\n%s", tt.name, diff)