@@ -18,49 +18,89 @@ func TestPhrase_Pattern(t *testing.T) {
18
18
want []string
19
19
}{
20
20
{
21
- name : "valid pattern - with keyword phrase" ,
22
- input : "phrase token = 1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" ,
23
- want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" },
21
+ name : "valid pattern - with keyword phrase" ,
22
+ input : `
23
+ [INFO] Initializing authentication
24
+ [DEBUG] phrase token = 1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890
25
+ [Info] Response received: 200 OK
26
+ ` ,
27
+ want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" },
24
28
},
25
29
{
26
- name : "valid pattern - ignore duplicate" ,
27
- input : "phrase token = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890' | '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'" ,
28
- want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" },
30
+ name : "valid pattern - ignore duplicate" ,
31
+ input : `
32
+ [INFO] Processing authentication tokens
33
+ [DEBUG] phrase token = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
34
+ [WARN] Duplicate token found: phrase token = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
35
+ [Info] Response received: 200 OK
36
+ ` ,
37
+ want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" },
29
38
},
30
39
{
31
- name : "valid pattern - key out of prefix range" ,
32
- input : "phrase keyword is not close to the real key in the data\n = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'" ,
33
- want : []string {},
40
+ name : "valid pattern - key out of prefix range" ,
41
+ input : `
42
+ [INFO] Starting system initialization
43
+ [DEBUG] phrase keyword is not close to the real key in the data
44
+ [DEBUG] Configuration loaded successfully
45
+ [DEBUG] Secret key = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
46
+ [ERROR] Response received: 400 BadRequest
47
+ ` ,
48
+ want : nil ,
34
49
},
35
50
{
36
- name : "invalid pattern" ,
37
- input : "phrase = 7cf4135a4e7f7ac228d36f210f151917a86f5dbd6" ,
38
- want : []string {},
51
+ name : "invalid pattern" ,
52
+ input : `
53
+ [INFO] Loading configuration
54
+ [DEBUG] phrase = 7cf4135a4e7f7ac228d36f210f151917a86f5dbd6
55
+ [ERROR] Response received: 400 BadRequest
56
+ ` ,
57
+ want : nil ,
39
58
},
40
59
{
41
- name : "finds all valid matches" ,
42
- input : "phrase token1 = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'\n phrase token2 = 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890'" ,
43
- want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" , "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" },
60
+ name : "finds all valid matches" ,
61
+ input : `
62
+ [INFO] Multi-token authentication
63
+ [DEBUG] phrase token1 = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
64
+ [DEBUG] phrase token2 = 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890'
65
+ [Info] Response received: 200 OK
66
+ ` ,
67
+ want : []string {"1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890" , "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" },
44
68
},
45
69
{
46
- name : "invalid pattern - too short" ,
47
- input : "phrase = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef12345678'" ,
48
- want : []string {},
70
+ name : "invalid pattern - too short" ,
71
+ input : `
72
+ [INFO] Processing short token
73
+ [DEBUG] phrase = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef12345678'
74
+ [ERROR] Response received: 400 BadRequest
75
+ ` ,
76
+ want : nil ,
49
77
},
50
78
{
51
- name : "invalid pattern - too long" ,
52
- input : "phrase = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef123456789012'" ,
53
- want : []string {},
79
+ name : "invalid pattern - too long" ,
80
+ input : `
81
+ [INFO] Processing long token
82
+ [DEBUG] phrase = '1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef123456789012'
83
+ [ERROR] Response received: 400 BadRequest
84
+ ` ,
85
+ want : nil ,
54
86
},
55
87
{
56
- name : "invalid pattern - contains uppercase" ,
57
- input : "phrase = '1A2B3C4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'" ,
58
- want : []string {},
88
+ name : "invalid pattern - contains uppercase" ,
89
+ input : `
90
+ [INFO] Processing token with uppercase
91
+ [DEBUG] phrase = '1A2B3C4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
92
+ [ERROR] Response received: 400 BadRequest
93
+ ` ,
94
+ want : nil ,
59
95
},
60
96
{
61
- name : "invalid pattern - contains special characters" ,
62
- input : "phrase = '1a2b3c4d-e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'" ,
63
- want : []string {},
97
+ name : "invalid pattern - contains special characters" ,
98
+ input : `
99
+ [INFO] Processing token with special chars
100
+ [DEBUG] phrase = '1a2b3c4d-e6f7890abcdef1234567890abcdef1234567890abcdef1234567890'
101
+ [ERROR] Response received: 400 BadRequest
102
+ ` ,
103
+ want : nil ,
64
104
},
65
105
}
66
106
0 commit comments