Debian Codegraph @

pkg/detectors/twilio/twilio_auth_detector_test.go

raw symbols SCIP
1 package twilio
2
3 import (
4 "testing"
5
6 "github.com/DefangLabs/secret-detector/pkg/detectors/tests"
7 )
8
9 var testCases = []tests.TestCase{
10 {"account - lowercase", "AC1234567890abcdef1234567890abcdef", true},
11 {"account - uppercase", "AC1234567890ABCDEF1234567890ABCDEF", true},
12 {"account - missing prefix", "1234567890abcdef1234567890abcdef", false},
13 {"account - illegal prefix", "MM1234567890abcdef1234567890abcdef", false},
14 {"account - lowercase prefix", "ac1234567890abcdef1234567890abcdef", false},
15 {"account - missing suffix", "AC", false},
16 {"account - illegal characters suffix", "AC1234567890ghijkl1234567890ghijkl", false},
17 {"account - suffix too long", "AC1234567890abcdef1234567890abcdefg", false},
18 {"account - suffix too short", "AC1234567890abcdef1234567890abcde", false},
19
20 {"key - lowercase", "SK1234567890abcdef1234567890abcdef", true},
21 {"key - uppercase", "SK1234567890ABCDEF1234567890ABCDEF", true},
22 {"key - lowercase prefix", "sk1234567890abcdef1234567890abcdef", false},
23 {"key - missing suffix", "SK", false},
24 {"key - illegal characters suffix", "SK1234567890ghijkl1234567890ghijkl", false},
25 {"key - suffix too long", "SK1234567890abcdef1234567890abcdefg", false},
26 {"key - suffix too short", "SK1234567890abcdef1234567890abcde", false},
27
28 {"empty input", "", false},
29 }
30
31 var twilioDetector = NewDetector()
32
33 func TestScan(t *testing.T) {
34 tests.TestScan(t, twilioDetector, testCases)
35 }
36
37 func TestScanWithKey(t *testing.T) {
38 tests.TestScanWithKey(t, twilioDetector, testCases)
39 }
40
41 func TestScanWithMultipleMatches(t *testing.T) {
42 tests.TestScanWithMultipleMatches(t, twilioDetector, testCases)
43 }
44
45 func TestScanMap(t *testing.T) {
46 tests.TestScanMap(t, twilioDetector, testCases)
47 }