Debian Codegraph @

pkg/detectors/stripe/stripe_detector_test.go

raw symbols SCIP
1 package stripe
2
3 import (
4 "testing"
5
6 "github.com/DefangLabs/secret-detector/pkg/detectors/tests"
7 )
8
9 var testCases = []tests.TestCase{
10 {"standard - valid live", `sk_live_1234567890abcdefgHIJKLMN`, true},
11 {"standard - valid test", `sk_test_1234567890abcdefgHIJKLMN`, true},
12 {"standard - missing prefix", `1234567890abcdefgHIJKLMN`, false},
13 {"standard - partial prefix", `live_1234567890abcdefgHIJKLMN`, false},
14 {"standard - illegal prefix", `sk_xxxx_1234567890abcdefgHIJKLMN`, false},
15 {"standard - uppercase prefix", `SK_LIVE_1234567890abcdefgHIJKLMN`, false},
16 {"standard - missing separator", `sk_live1234567890abcdefgHIJKLMN`, false},
17 {"standard - wrong separator", `sk_live-1234567890abcdefgHIJKLMN`, false},
18 {"standard - missing suffix", `sk_live`, false},
19 {"standard - illegal character suffix", `sk_live_123456789-abcdefgHIJKLMN`, false},
20 {"standard - suffix too long", `sk_live_1234567890abcdefgHIJKLMNO`, false},
21 {"standard - suffix too short", `sk_live_1234567890abcdefgHIJKLM`, false},
22
23 {"restricted - valid live", `rk_live_1234567890abcdefgHIJKLMN`, true},
24 {"restricted - valid test", `rk_test_1234567890abcdefgHIJKLMN`, true},
25 {"restricted - partial prefix", `rk_1234567890abcdefgHIJKLMN`, false},
26 {"restricted - illegal prefix", `rk_xxxx_1234567890abcdefgHIJKLMN`, false},
27 {"restricted - uppercase prefix", `RK_LIVE_1234567890abcdefgHIJKLMN`, false},
28 {"restricted - missing separator", `rk_live1234567890abcdefgHIJKLMN`, false},
29 {"restricted - wrong separator", `rk_live-1234567890abcdefgHIJKLMN`, false},
30 {"restricted - missing suffix", `rk_live`, false},
31 {"restricted - illegal character suffix", `rk_live_123456789-abcdefgHIJKLMN`, false},
32 {"restricted - suffix too long", `rk_live_1234567890abcdefgHIJKLMNO`, false},
33 {"restricted - suffix too short", `rk_live_1234567890abcdefgHIJKLM`, false},
34
35 {"empty input", "", false},
36 }
37
38 var stripeDetector = NewDetector()
39
40 func TestScan(t *testing.T) {
41 tests.TestScan(t, stripeDetector, testCases)
42 }
43
44 func TestScanWithKey(t *testing.T) {
45 tests.TestScanWithKey(t, stripeDetector, testCases)
46 }
47
48 func TestScanWithMultipleMatches(t *testing.T) {
49 tests.TestScanWithMultipleMatches(t, stripeDetector, testCases)
50 }
51
52 func TestScanMap(t *testing.T) {
53 tests.TestScanMap(t, stripeDetector, testCases)
54 }