| 1 | package artifactory |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/DefangLabs/secret-detector/pkg/detectors/tests" |
| 7 | ) |
| 8 | |
| 9 | var testCases = []tests.TestCase{ |
| 10 | {"token - minimal length", "AKCabcXYZ1234", true}, |
| 11 | {"token - long", "AKCabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", true}, |
| 12 | {"token - too short", "AKC123456789", false}, |
| 13 | {"token - illegal prefix", "NAKCabcXYZ1234", false}, |
| 14 | {"token - illegal lowercase prefix", "akcabcXYZ1234", false}, |
| 15 | {"token - illegal characters", "AKCabcXYZ1234=", false}, |
| 16 | |
| 17 | {"password - minimal length", "AP0abcXYZ12", true}, |
| 18 | {"password - long", "APEabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", true}, |
| 19 | {"password - too short", "AP0abcXYZ1", false}, |
| 20 | {"password - illegal AP prefix", "NAP0abcXYZ12", false}, |
| 21 | {"password - illegal lowercase AP prefix", "ap0abcXYZ12", false}, |
| 22 | {"password - illegal prefix character", "APGabcXYZ12", false}, |
| 23 | {"password - illegal lowercase prefix character", "APeabcXYZ12", false}, |
| 24 | {"password - illegal character", "AP0abcXYZ12+", false}, |
| 25 | |
| 26 | {"empty input", "", false}, |
| 27 | } |
| 28 | |
| 29 | var artifactoryDetector = NewDetector() |
| 30 | |
| 31 | func TestScan(t *testing.T) { |
| 32 | tests.TestScan(t, artifactoryDetector, testCases) |
| 33 | } |
| 34 | |
| 35 | func TestScanWithKey(t *testing.T) { |
| 36 | tests.TestScanWithKey(t, artifactoryDetector, testCases) |
| 37 | } |
| 38 | |
| 39 | func TestScanWithMultipleMatches(t *testing.T) { |
| 40 | tests.TestScanWithMultipleMatches(t, artifactoryDetector, testCases) |
| 41 | } |
| 42 | |
| 43 | func TestScanMap(t *testing.T) { |
| 44 | tests.TestScanMap(t, artifactoryDetector, testCases) |
| 45 | } |