1
1
//go:build detectors
2
2
// +build detectors
3
3
4
- package abbysale
4
+ package abyssale
5
5
6
6
import (
7
7
"context"
8
8
"fmt"
9
+ "testing"
10
+ "time"
11
+
9
12
"github.com/google/go-cmp/cmp/cmpopts"
10
13
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
11
14
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
12
- "testing"
13
- "time"
14
15
15
16
"github.com/google/go-cmp/cmp"
16
17
17
18
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
18
19
)
19
20
20
- func TestAbbysale_FromChunk (t * testing.T ) {
21
+ func TestAbyssale_FromChunk (t * testing.T ) {
21
22
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
22
23
defer cancel ()
23
- testSecrets , err := common .GetSecret (ctx , "trufflehog-testing" , "detectors3 " )
24
+ testSecrets , err := common .GetSecret (ctx , "trufflehog-testing" , "detectors5 " )
24
25
if err != nil {
25
26
t .Fatalf ("could not get test secrets from GCP: %s" , err )
26
27
}
27
- secret := testSecrets .MustGetField ("ABBYSALE_TOKEN " )
28
- inactiveSecret := testSecrets .MustGetField ("ABBYSALE_INACTIVE " )
28
+ secret := testSecrets .MustGetField ("ABYSSALE_TOKEN " )
29
+ inactiveSecret := testSecrets .MustGetField ("ABYSSALE_INACTIVE " )
29
30
30
31
type args struct {
31
32
ctx context.Context
@@ -44,12 +45,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
44
45
s : Scanner {},
45
46
args : args {
46
47
ctx : context .Background (),
47
- data : []byte (fmt .Sprintf ("You can find a abbysale secret %s within but verified" , secret )),
48
+ data : []byte (fmt .Sprintf ("You can find a abyssale secret %s within but verified" , secret )),
48
49
verify : true ,
49
50
},
50
51
want : []detectors.Result {
51
52
{
52
- DetectorType : detectorspb .DetectorType_Abbysale ,
53
+ DetectorType : detectorspb .DetectorType_Abyssale ,
53
54
Verified : true ,
54
55
},
55
56
},
@@ -60,12 +61,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
60
61
s : Scanner {client : common .SaneHttpClientTimeOut (1 * time .Microsecond )},
61
62
args : args {
62
63
ctx : context .Background (),
63
- data : []byte (fmt .Sprintf ("You can find a abbysale secret %s within but verified" , secret )),
64
+ data : []byte (fmt .Sprintf ("You can find a abyssale secret %s within but verified" , secret )),
64
65
verify : true ,
65
66
},
66
67
want : func () []detectors.Result {
67
68
r := detectors.Result {
68
- DetectorType : detectorspb .DetectorType_Abbysale ,
69
+ DetectorType : detectorspb .DetectorType_Abyssale ,
69
70
Verified : false ,
70
71
}
71
72
r .SetVerificationError (context .DeadlineExceeded )
@@ -78,12 +79,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
78
79
s : Scanner {client : common .ConstantResponseHttpClient (500 , "{}" )},
79
80
args : args {
80
81
ctx : context .Background (),
81
- data : []byte (fmt .Sprintf ("You can find a abbysale secret %s within but verified" , secret )),
82
+ data : []byte (fmt .Sprintf ("You can find a abyssale secret %s within but verified" , secret )),
82
83
verify : true ,
83
84
},
84
85
want : func () []detectors.Result {
85
86
r := detectors.Result {
86
- DetectorType : detectorspb .DetectorType_Abbysale ,
87
+ DetectorType : detectorspb .DetectorType_Abyssale ,
87
88
Verified : false ,
88
89
}
89
90
r .SetVerificationError (fmt .Errorf ("unexpected HTTP response status 500" ))
@@ -96,12 +97,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
96
97
s : Scanner {},
97
98
args : args {
98
99
ctx : context .Background (),
99
- data : []byte (fmt .Sprintf ("You can find a abbysale secret %s within but verified" , inactiveSecret )), // the secret would satisfy the regex but not pass validation
100
+ data : []byte (fmt .Sprintf ("You can find a abyssale secret %s within but verified" , inactiveSecret )), // the secret would satisfy the regex but not pass validation
100
101
verify : true ,
101
102
},
102
103
want : []detectors.Result {
103
104
{
104
- DetectorType : detectorspb .DetectorType_Abbysale ,
105
+ DetectorType : detectorspb .DetectorType_Abyssale ,
105
106
Verified : false ,
106
107
},
107
108
},
@@ -123,7 +124,7 @@ func TestAbbysale_FromChunk(t *testing.T) {
123
124
t .Run (tt .name , func (t * testing.T ) {
124
125
got , err := tt .s .FromData (tt .args .ctx , tt .args .verify , tt .args .data )
125
126
if (err != nil ) != tt .wantErr {
126
- t .Errorf ("Abbysale .FromData() error = %v, wantErr %v" , err , tt .wantErr )
127
+ t .Errorf ("Abyssale .FromData() error = %v, wantErr %v" , err , tt .wantErr )
127
128
return
128
129
}
129
130
for i := range got {
@@ -145,7 +146,7 @@ func TestAbbysale_FromChunk(t *testing.T) {
145
146
}
146
147
ignoreOpts := cmpopts .IgnoreFields (detectors.Result {}, "Raw" , "RawV2" , "verificationError" )
147
148
if diff := cmp .Diff (got , tt .want , ignoreOpts ); diff != "" {
148
- t .Errorf ("Abbysale .FromData() %s diff: (-got +want)\n %s" , tt .name , diff )
149
+ t .Errorf ("Abyssale .FromData() %s diff: (-got +want)\n %s" , tt .name , diff )
149
150
}
150
151
})
151
152
}
0 commit comments