From 350971e839fdec470c5514b655c7c4464fd748d0 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Mon, 9 Dec 2024 22:52:28 +0500 Subject: [PATCH] [Fix] detector's integration tests starting with alphabet 'A' (#3745) * fixed some tests * another detector fix * fixed integration test of apiflash as RawV2 is not being set by detector. --- pkg/detectors/agora/agora_integration_test.go | 20 ++----------------- .../amplitudeapikey_integration_test.go | 12 +++++++++++ .../apideck/apideck_integration_test.go | 4 ++++ .../appcues/appcues_integration_test.go | 12 +++++++++++ pkg/detectors/artsy/artsy_integration_test.go | 4 ++++ .../auth0oauth_integeration_test.go | 4 ++++ 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/pkg/detectors/agora/agora_integration_test.go b/pkg/detectors/agora/agora_integration_test.go index fbd70bd86..2c8b20f28 100644 --- a/pkg/detectors/agora/agora_integration_test.go +++ b/pkg/detectors/agora/agora_integration_test.go @@ -49,10 +49,6 @@ func TestAgora_FromChunk(t *testing.T) { verify: true, }, want: []detectors.Result{ - { - DetectorType: detectorspb.DetectorType_Agora, - Verified: false, - }, { DetectorType: detectorspb.DetectorType_Agora, Verified: true, @@ -61,10 +57,6 @@ func TestAgora_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_Agora, Verified: false, }, - { - DetectorType: detectorspb.DetectorType_Agora, - Verified: false, - }, }, wantErr: false, }, @@ -82,7 +74,7 @@ func TestAgora_FromChunk(t *testing.T) { Verified: false, } r.SetVerificationError(context.DeadlineExceeded) - return []detectors.Result{r, r, r, r} + return []detectors.Result{r, r} }(), wantErr: false, }, @@ -100,7 +92,7 @@ func TestAgora_FromChunk(t *testing.T) { Verified: false, } r.SetVerificationError(fmt.Errorf("unexpected HTTP response status 500")) - return []detectors.Result{r, r, r, r} + return []detectors.Result{r, r} }(), wantErr: false, }, @@ -121,14 +113,6 @@ func TestAgora_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_Agora, Verified: false, }, - { - DetectorType: detectorspb.DetectorType_Agora, - Verified: false, - }, - { - DetectorType: detectorspb.DetectorType_Agora, - Verified: false, - }, }, wantErr: false, }, diff --git a/pkg/detectors/amplitudeapikey/amplitudeapikey_integration_test.go b/pkg/detectors/amplitudeapikey/amplitudeapikey_integration_test.go index 9028ed7fb..4b04165c6 100644 --- a/pkg/detectors/amplitudeapikey/amplitudeapikey_integration_test.go +++ b/pkg/detectors/amplitudeapikey/amplitudeapikey_integration_test.go @@ -54,6 +54,10 @@ func TestAmplitudeApiKey_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_AmplitudeApiKey, Verified: true, }, + { + DetectorType: detectorspb.DetectorType_AmplitudeApiKey, + Verified: false, + }, }, wantErr: false, }, @@ -71,6 +75,10 @@ func TestAmplitudeApiKey_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_AmplitudeApiKey, Verified: false, }, + { + DetectorType: detectorspb.DetectorType_AmplitudeApiKey, + Verified: false, + }, }, wantErr: false, }, @@ -99,6 +107,10 @@ func TestAmplitudeApiKey_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("AmplitudeApiKey.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/apideck/apideck_integration_test.go b/pkg/detectors/apideck/apideck_integration_test.go index 30eb2fa7c..2a16e8a2a 100644 --- a/pkg/detectors/apideck/apideck_integration_test.go +++ b/pkg/detectors/apideck/apideck_integration_test.go @@ -96,6 +96,10 @@ func TestApiDeck_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("ApiDeck.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/appcues/appcues_integration_test.go b/pkg/detectors/appcues/appcues_integration_test.go index c46205d00..eb36ecac7 100644 --- a/pkg/detectors/appcues/appcues_integration_test.go +++ b/pkg/detectors/appcues/appcues_integration_test.go @@ -53,6 +53,10 @@ func TestAppcues_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_Appcues, Verified: true, }, + { + DetectorType: detectorspb.DetectorType_Appcues, + Verified: false, + }, }, wantErr: false, }, @@ -69,6 +73,10 @@ func TestAppcues_FromChunk(t *testing.T) { DetectorType: detectorspb.DetectorType_Appcues, Verified: false, }, + { + DetectorType: detectorspb.DetectorType_Appcues, + Verified: false, + }, }, wantErr: false, }, @@ -97,6 +105,10 @@ func TestAppcues_FromChunk(t *testing.T) { t.Fatal("no raw secret present") } 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("Appcues.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/artsy/artsy_integration_test.go b/pkg/detectors/artsy/artsy_integration_test.go index bf44ba496..82a08adf2 100644 --- a/pkg/detectors/artsy/artsy_integration_test.go +++ b/pkg/detectors/artsy/artsy_integration_test.go @@ -96,6 +96,10 @@ func TestArtsy_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("Artsy.FromData() %s diff: (-got +want)\n%s", tt.name, diff) diff --git a/pkg/detectors/auth0oauth/auth0oauth_integeration_test.go b/pkg/detectors/auth0oauth/auth0oauth_integeration_test.go index 5a343487d..2363df8aa 100644 --- a/pkg/detectors/auth0oauth/auth0oauth_integeration_test.go +++ b/pkg/detectors/auth0oauth/auth0oauth_integeration_test.go @@ -100,6 +100,10 @@ func TestAuth0oauth_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("Auth0oauth.FromData() %s diff: (-got +want)\n%s", tt.name, diff)