Skip to content

Commit

Permalink
[chore] - fix test (#1383)
Browse files Browse the repository at this point in the history
* fix test.

* fix import order.

* fix twilio test.
  • Loading branch information
ahrav authored Jun 7, 2023
1 parent c8b9735 commit ce4a1fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions pkg/detectors/kanbantool/kanbantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"time"

"github.com/kylelemons/godebug/pretty"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"

"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
)

Expand Down Expand Up @@ -41,7 +41,7 @@ func TestKanbantool_FromChunk(t *testing.T) {
s: Scanner{},
args: args{
ctx: context.Background(),
data: []byte(fmt.Sprintf("You can find a kanbantool secret %s within kanbantool %s", secret,domain)),
data: []byte(fmt.Sprintf("You can find a kanbantool secret %s within kanbantool %s", secret, domain)),
verify: true,
},
want: []detectors.Result{
Expand All @@ -57,7 +57,7 @@ func TestKanbantool_FromChunk(t *testing.T) {
s: Scanner{},
args: args{
ctx: context.Background(),
data: []byte(fmt.Sprintf("You can find a kanbantool secret %s within but not valid kanbantool %s", inactiveSecret,domain)), // the secret would satisfy the regex but not pass validation
data: []byte(fmt.Sprintf("You can find a kanbantool secret %s within but not valid kanbantool %s", inactiveSecret, domain)), // the secret would satisfy the regex but not pass validation
verify: true,
},
want: []detectors.Result{
Expand Down Expand Up @@ -93,10 +93,12 @@ func TestKanbantool_FromChunk(t *testing.T) {
t.Fatalf("no raw secret present: \n %+v", got[i])
}
got[i].Raw = nil

if diff := pretty.Compare(got[i], tt.want[0]); diff != "" {
t.Errorf("Kanbantool.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
}
}
if diff := pretty.Compare(got, tt.want); diff != "" {
t.Errorf("Kanbantool.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
}

})
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/detectors/twilio/twilio.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
sidMatches := sidPat.FindAllString(dataStr, -1)

for _, sid := range sidMatches {

s := detectors.Result{
DetectorType: detectorspb.DetectorType_Twilio,
Raw: []byte(sid),
Expand Down
3 changes: 2 additions & 1 deletion pkg/detectors/twilio/twilio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/kylelemons/godebug/pretty"

"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
Expand All @@ -18,7 +19,7 @@ import (
func TestTwilio_FromChunk(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors2")
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors4")
if err != nil {
t.Fatalf("could not get test secrets from GCP: %s", err)
}
Expand Down

0 comments on commit ce4a1fd

Please sign in to comment.