| 1 | package aws |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/DefangLabs/secret-detector/pkg/detectors/tests" |
| 7 | ) |
| 8 | |
| 9 | var clientIdTestCases = []tests.TestCase{ |
| 10 | |
| 11 | {"A3T prefix+letter", "A3TX1234567890ABCDEF", true}, |
| 12 | {"A3T prefix+digit", "A3T11234567890ABCDEF", true}, |
| 13 | {"AKIA prefix", "AKIA1234567890ABCDEF", true}, |
| 14 | {"AGPA prefix", "AGPA1234567890ABCDEF", true}, |
| 15 | {"AIDA prefix", "AIDA1234567890ABCDEF", true}, |
| 16 | {"AROA prefix", "AROA1234567890ABCDEF", true}, |
| 17 | {"AIPA prefix", "AIPA1234567890ABCDEF", true}, |
| 18 | {"ANPA prefix", "ANPA1234567890ABCDEF", true}, |
| 19 | {"ANVA prefix", "ANVA1234567890ABCDEF", true}, |
| 20 | {"ASIA prefix", "ASIA1234567890ABCDEF", true}, |
| 21 | |
| 22 | {"missing prefix", "1234567890ABCDEF", false}, |
| 23 | {"illegal prefix", "AMBA1234567890ABCDEF", false}, |
| 24 | {"lowercase prefix", "akia1234567890ABCDEF", false}, |
| 25 | |
| 26 | {"missing suffix", "AKIA", false}, |
| 27 | {"illegal characters suffix", "AKIA123456789+ABCDEF", false}, |
| 28 | {"lowercase characters suffix", "AKIA1234567890abcdef", false}, |
| 29 | {"suffix too long", "AKIA1234567890ABCDEFG", false}, |
| 30 | {"suffix too short", "AKIA1234567890ABCDE", false}, |
| 31 | {"empty input", "", false}, |
| 32 | } |
| 33 | |
| 34 | var clientIdDetector = NewClientIdDetector() |
| 35 | |
| 36 | func TestClientIdDetector_Scan(t *testing.T) { |
| 37 | tests.TestScan(t, clientIdDetector, clientIdTestCases) |
| 38 | } |
| 39 | |
| 40 | func TestClientIdDetector_ScanWithKey(t *testing.T) { |
| 41 | tests.TestScanWithKey(t, clientIdDetector, clientIdTestCases) |
| 42 | } |
| 43 | |
| 44 | func TestClientIdDetector_ScanWithMultipleMatches(t *testing.T) { |
| 45 | tests.TestScanWithMultipleMatches(t, clientIdDetector, clientIdTestCases) |
| 46 | } |
| 47 | |
| 48 | func TestClientIdDetector_ScanMap(t *testing.T) { |
| 49 | tests.TestScanMap(t, clientIdDetector, clientIdTestCases) |
| 50 | } |