@@ -24,6 +24,7 @@ func init() {
24
24
}
25
25
26
26
func TestNewAuditor (t * testing.T ) {
27
+ t .Parallel ()
27
28
config := & Config {}
28
29
auditor := NewAuditor (config )
29
30
@@ -32,6 +33,7 @@ func TestNewAuditor(t *testing.T) {
32
33
}
33
34
34
35
func TestAuditorMiddlewareDisabled (t * testing.T ) {
36
+ t .Parallel ()
35
37
config := & Config {}
36
38
auditor := NewAuditor (config )
37
39
@@ -52,6 +54,7 @@ func TestAuditorMiddlewareDisabled(t *testing.T) {
52
54
}
53
55
54
56
func TestAuditorMiddlewareWithRequestData (t * testing.T ) {
57
+ t .Parallel ()
55
58
config := & Config {
56
59
IncludeRequestData : true ,
57
60
MaxDataSize : 1024 ,
@@ -80,6 +83,7 @@ func TestAuditorMiddlewareWithRequestData(t *testing.T) {
80
83
}
81
84
82
85
func TestAuditorMiddlewareWithResponseData (t * testing.T ) {
86
+ t .Parallel ()
83
87
config := & Config {
84
88
IncludeResponseData : true ,
85
89
MaxDataSize : 1024 ,
@@ -105,6 +109,7 @@ func TestAuditorMiddlewareWithResponseData(t *testing.T) {
105
109
}
106
110
107
111
func TestDetermineEventType (t * testing.T ) {
112
+ t .Parallel ()
108
113
auditor := NewAuditor (& Config {})
109
114
110
115
tests := []struct {
@@ -135,6 +140,7 @@ func TestDetermineEventType(t *testing.T) {
135
140
136
141
for _ , tt := range tests {
137
142
t .Run (tt .name , func (t * testing.T ) {
143
+ t .Parallel ()
138
144
req := httptest .NewRequest (tt .method , tt .path , nil )
139
145
result := auditor .determineEventType (req )
140
146
assert .Equal (t , tt .expected , result )
@@ -143,6 +149,7 @@ func TestDetermineEventType(t *testing.T) {
143
149
}
144
150
145
151
func TestMapMCPMethodToEventType (t * testing.T ) {
152
+ t .Parallel ()
146
153
tests := []struct {
147
154
mcpMethod string
148
155
expected string
@@ -165,13 +172,15 @@ func TestMapMCPMethodToEventType(t *testing.T) {
165
172
auditor := NewAuditor (& Config {})
166
173
for _ , tt := range tests {
167
174
t .Run (tt .mcpMethod , func (t * testing.T ) {
175
+ t .Parallel ()
168
176
result := auditor .mapMCPMethodToEventType (tt .mcpMethod )
169
177
assert .Equal (t , tt .expected , result )
170
178
})
171
179
}
172
180
}
173
181
174
182
func TestDetermineOutcome (t * testing.T ) {
183
+ t .Parallel ()
175
184
auditor := NewAuditor (& Config {})
176
185
177
186
tests := []struct {
@@ -193,13 +202,15 @@ func TestDetermineOutcome(t *testing.T) {
193
202
194
203
for _ , tt := range tests {
195
204
t .Run (string (rune (tt .statusCode )), func (t * testing.T ) {
205
+ t .Parallel ()
196
206
result := auditor .determineOutcome (tt .statusCode )
197
207
assert .Equal (t , tt .expected , result )
198
208
})
199
209
}
200
210
}
201
211
202
212
func TestGetClientIP (t * testing.T ) {
213
+ t .Parallel ()
203
214
auditor := NewAuditor (& Config {})
204
215
205
216
tests := []struct {
@@ -232,6 +243,7 @@ func TestGetClientIP(t *testing.T) {
232
243
233
244
for _ , tt := range tests {
234
245
t .Run (tt .name , func (t * testing.T ) {
246
+ t .Parallel ()
235
247
req := httptest .NewRequest ("GET" , "/test" , nil )
236
248
for key , value := range tt .headers {
237
249
req .Header .Set (key , value )
@@ -247,9 +259,11 @@ func TestGetClientIP(t *testing.T) {
247
259
}
248
260
249
261
func TestExtractSubjects (t * testing.T ) {
262
+ t .Parallel ()
250
263
auditor := NewAuditor (& Config {})
251
264
252
265
t .Run ("with JWT claims" , func (t * testing.T ) {
266
+ t .Parallel ()
253
267
claims := jwt.MapClaims {
254
268
"sub" : "user123" ,
255
269
"name" : "John Doe" ,
@@ -271,6 +285,7 @@ func TestExtractSubjects(t *testing.T) {
271
285
})
272
286
273
287
t .Run ("with preferred_username" , func (t * testing.T ) {
288
+ t .Parallel ()
274
289
claims := jwt.MapClaims {
275
290
"sub" : "user456" ,
276
291
"preferred_username" : "johndoe" ,
@@ -287,6 +302,7 @@ func TestExtractSubjects(t *testing.T) {
287
302
})
288
303
289
304
t .Run ("with email fallback" , func (t * testing.T ) {
305
+ t .Parallel ()
290
306
claims := jwt.MapClaims {
291
307
"sub" : "user789" ,
292
308
@@ -303,6 +319,7 @@ func TestExtractSubjects(t *testing.T) {
303
319
})
304
320
305
321
t .Run ("without claims" , func (t * testing.T ) {
322
+ t .Parallel ()
306
323
req := httptest .NewRequest ("GET" , "/test" , nil )
307
324
308
325
subjects := auditor .extractSubjects (req )
@@ -312,7 +329,9 @@ func TestExtractSubjects(t *testing.T) {
312
329
}
313
330
314
331
func TestDetermineComponent (t * testing.T ) {
332
+ t .Parallel ()
315
333
t .Run ("with configured component" , func (t * testing.T ) {
334
+ t .Parallel ()
316
335
config := & Config {Component : "custom-component" }
317
336
auditor := NewAuditor (config )
318
337
@@ -323,6 +342,7 @@ func TestDetermineComponent(t *testing.T) {
323
342
})
324
343
325
344
t .Run ("without configured component" , func (t * testing.T ) {
345
+ t .Parallel ()
326
346
config := & Config {}
327
347
auditor := NewAuditor (config )
328
348
@@ -334,6 +354,7 @@ func TestDetermineComponent(t *testing.T) {
334
354
}
335
355
336
356
func TestExtractTarget (t * testing.T ) {
357
+ t .Parallel ()
337
358
auditor := NewAuditor (& Config {})
338
359
339
360
tests := []struct {
@@ -380,6 +401,7 @@ func TestExtractTarget(t *testing.T) {
380
401
381
402
for _ , tt := range tests {
382
403
t .Run (tt .name , func (t * testing.T ) {
404
+ t .Parallel ()
383
405
req := httptest .NewRequest (tt .method , tt .path , nil )
384
406
result := auditor .extractTarget (req , tt .eventType )
385
407
assert .Equal (t , tt .expected , result )
@@ -388,6 +410,7 @@ func TestExtractTarget(t *testing.T) {
388
410
}
389
411
390
412
func TestAddMetadata (t * testing.T ) {
413
+ t .Parallel ()
391
414
auditor := NewAuditor (& Config {})
392
415
393
416
event := NewAuditEvent ("test" , EventSource {}, OutcomeSuccess , map [string ]string {}, "test" )
@@ -407,7 +430,9 @@ func TestAddMetadata(t *testing.T) {
407
430
}
408
431
409
432
func TestAddEventData (t * testing.T ) {
433
+ t .Parallel ()
410
434
t .Run ("with request and response data" , func (t * testing.T ) {
435
+ t .Parallel ()
411
436
config := & Config {
412
437
IncludeRequestData : true ,
413
438
IncludeResponseData : true ,
@@ -439,6 +464,7 @@ func TestAddEventData(t *testing.T) {
439
464
})
440
465
441
466
t .Run ("with non-JSON data" , func (t * testing.T ) {
467
+ t .Parallel ()
442
468
config := & Config {
443
469
IncludeRequestData : true ,
444
470
IncludeResponseData : true ,
@@ -465,6 +491,7 @@ func TestAddEventData(t *testing.T) {
465
491
})
466
492
467
493
t .Run ("disabled data inclusion" , func (t * testing.T ) {
494
+ t .Parallel ()
468
495
config := & Config {
469
496
IncludeRequestData : false ,
470
497
IncludeResponseData : false ,
@@ -483,6 +510,7 @@ func TestAddEventData(t *testing.T) {
483
510
}
484
511
485
512
func TestResponseWriterCapture (t * testing.T ) {
513
+ t .Parallel ()
486
514
config := & Config {
487
515
IncludeResponseData : true ,
488
516
MaxDataSize : 10 , // Small limit for testing
@@ -510,6 +538,7 @@ func TestResponseWriterCapture(t *testing.T) {
510
538
}
511
539
512
540
func TestResponseWriterStatusCode (t * testing.T ) {
541
+ t .Parallel ()
513
542
rw := & responseWriter {
514
543
ResponseWriter : httptest .NewRecorder (),
515
544
statusCode : http .StatusOK , // Default
@@ -521,6 +550,7 @@ func TestResponseWriterStatusCode(t *testing.T) {
521
550
}
522
551
523
552
func TestExtractSourceWithHeaders (t * testing.T ) {
553
+ t .Parallel ()
524
554
auditor := NewAuditor (& Config {})
525
555
526
556
req := httptest .NewRequest ("GET" , "/test" , nil )
0 commit comments