Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1 committed Nov 14, 2023
1 parent 5d7c31f commit 0f4ecac
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
17 changes: 9 additions & 8 deletions pkg/detectors/budibase/budibase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/eventbrite/eventbrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/instamojo/instamojo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/detectors/ip2location/ip2location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/ldap/ldap_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/overloop/overloop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/portainer/portainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/privacy/privacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/detectors/uri/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ func TestURI_FromChunk(t *testing.T) {
data: []byte(fmt.Sprintf("You can find a uri secret %s within", "https://httpwatch:[email protected]/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,
},
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0f4ecac

Please sign in to comment.