diff --git a/pkg/detectors/budibase/budibase_test.go b/pkg/detectors/budibase/budibase_test.go index 0fa1190b6c30..ebd9ce6c8149 100644 --- a/pkg/detectors/budibase/budibase_test.go +++ b/pkg/detectors/budibase/budibase_test.go @@ -66,13 +66,14 @@ func TestBudibase_FromChunk(t *testing.T) { data: []byte(fmt.Sprintf("You can find a budibase secret %s within but not valid", inactiveSecret)), // the secret would satisfy the regex but not pass validation verify: true, }, - want: []detectors.Result{ - { - DetectorType: detectorspb.DetectorType_Budibase, - Verified: false, - VerificationError: fmt.Errorf("unexpected HTTP response status 403"), - }, - }, + want: func() []detectors.Result { + r := detectors.Result{ + DetectorType: detectorspb.DetectorType_Budibase, + Verified: true, + } + r.SetVerificationError(fmt.Errorf("unexpected HTTP response status 403")) + return []detectors.Result{r} + }(), wantErr: false, wantVerificationErr: true, }, @@ -101,7 +102,7 @@ func TestBudibase_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { - t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) + t.Fatalf("wantVerificationError = %v, verification error = %v", tt.want[i].VerificationError(), got[i].VerificationError()) } } ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError") diff --git a/pkg/detectors/eventbrite/eventbrite_test.go b/pkg/detectors/eventbrite/eventbrite_test.go index bc77b13586fa..5ac973112c7b 100644 --- a/pkg/detectors/eventbrite/eventbrite_test.go +++ b/pkg/detectors/eventbrite/eventbrite_test.go @@ -132,7 +132,7 @@ func TestEventbrite_FromChunk(t *testing.T) { for i := range got { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) - }.VerificationError() + } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } diff --git a/pkg/detectors/instamojo/instamojo_test.go b/pkg/detectors/instamojo/instamojo_test.go index d6e6fdb36a6a..81bacaaac907 100644 --- a/pkg/detectors/instamojo/instamojo_test.go +++ b/pkg/detectors/instamojo/instamojo_test.go @@ -68,7 +68,6 @@ func TestInstamojo_FromChunk(t *testing.T) { want: []detectors.Result{ { DetectorType: detectorspb.DetectorType_Instamojo, - VerificationError: fmt.Errorf("unexpected HTTP response status 401"), }, }, wantErr: false, @@ -82,7 +81,7 @@ func TestInstamojo_FromChunk(t *testing.T) { data: []byte("You cannot find the secret within"), verify: true, }, - want: nil, + want: nil, wantErr: false, wantVerificationErr: true, }, diff --git a/pkg/detectors/ip2location/ip2location_test.go b/pkg/detectors/ip2location/ip2location_test.go index ab0f9d37ea5e..2e40cdefdfcc 100644 --- a/pkg/detectors/ip2location/ip2location_test.go +++ b/pkg/detectors/ip2location/ip2location_test.go @@ -99,8 +99,8 @@ func TestIp2location_FromChunk(t *testing.T) { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) } - if (got[i].VerificationError()) != nil) != tt.wantVerificationErr { - t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) + if (got[i].VerificationError() != nil) != tt.wantVerificationErr { + t.Fatalf("wantVerificationError = %v, verification error = %v", tt.want[i].VerificationError(), got[i].VerificationError()) } } ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError") diff --git a/pkg/detectors/ldap/ldap_integration_test.go b/pkg/detectors/ldap/ldap_integration_test.go index 90c242cf8ce8..0927fcce502c 100644 --- a/pkg/detectors/ldap/ldap_integration_test.go +++ b/pkg/detectors/ldap/ldap_integration_test.go @@ -198,7 +198,7 @@ func TestLdap_Integration_FromChunk(t *testing.T) { for i := range got { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) - }.VerificationError() + } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } diff --git a/pkg/detectors/mongodb/mongodb_test.go b/pkg/detectors/mongodb/mongodb_test.go index 3f511df17fdd..530558f9bf9d 100644 --- a/pkg/detectors/mongodb/mongodb_test.go +++ b/pkg/detectors/mongodb/mongodb_test.go @@ -132,7 +132,7 @@ func TestMongoDB_FromChunk(t *testing.T) { t.Fatalf("no raw secret present: \n %+v", got[i]) } got[i].Raw = nil - if (got[i].VerificationError()) != nil) != tt.wantVerificationErr { + if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationErr = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } } diff --git a/pkg/detectors/overloop/overloop_test.go b/pkg/detectors/overloop/overloop_test.go index e6a977ae7e50..7b5d499fd675 100644 --- a/pkg/detectors/overloop/overloop_test.go +++ b/pkg/detectors/overloop/overloop_test.go @@ -132,7 +132,7 @@ func TestOverloop_FromChunk(t *testing.T) { for i := range got { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) - }.VerificationError() + } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } diff --git a/pkg/detectors/portainer/portainer_test.go b/pkg/detectors/portainer/portainer_test.go index 496c507b3e4a..49ca42d4a9d5 100644 --- a/pkg/detectors/portainer/portainer_test.go +++ b/pkg/detectors/portainer/portainer_test.go @@ -102,7 +102,7 @@ func TestPortainer_FromChunk(t *testing.T) { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) } - if (got[i].VerificationError()) != nil) != tt.wantVerificationErr { + if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } } diff --git a/pkg/detectors/privacy/privacy_test.go b/pkg/detectors/privacy/privacy_test.go index 3812757c67a8..c17317ea6b5d 100644 --- a/pkg/detectors/privacy/privacy_test.go +++ b/pkg/detectors/privacy/privacy_test.go @@ -132,7 +132,7 @@ func TestPrivacy_FromChunk(t *testing.T) { for i := range got { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) - }.VerificationError() + } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } diff --git a/pkg/detectors/uri/uri_test.go b/pkg/detectors/uri/uri_test.go index bf057083e0b6..567c97979b5d 100644 --- a/pkg/detectors/uri/uri_test.go +++ b/pkg/detectors/uri/uri_test.go @@ -88,13 +88,15 @@ func TestURI_FromChunk(t *testing.T) { data: []byte(fmt.Sprintf("You can find a uri secret %s within", "https://httpwatch:pass@www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx")), verify: true, }, - want: []detectors.Result{ - { + want: func() []detectors.Result { + r := detectors.Result{ DetectorType: detectorspb.DetectorType_URI, Verified: false, Redacted: "https://httpwatch:********@www.httpwatch.com", - }, - }, + } + r.SetVerificationError(fmt.Errorf("context deadline exceeded")) + return []detectors.Result{r} + }(), wantErr: false, wantVerificationErr: true, }, @@ -133,12 +135,11 @@ func TestURI_FromChunk(t *testing.T) { // } for i := range got { if (got[i].VerificationError() != nil) != tt.wantVerificationErr { - t.Errorf("URI.FromData() error = %v, wantVerificationErr %v", got[i].VerificationError(), tt.wantErr) + t.Errorf("URI.FromData() error = %v, wantVerificationErr %v", got[i].VerificationError(), tt.want[i]) return } got[i].Raw = nil got[i].RawV2 = nil - got[i].SetVerificationError(nil) } if diff := pretty.Compare(got, tt.want); diff != "" { t.Errorf("URI.FromData() %s diff: (-got +want)\n%s", tt.name, diff)