@@ -11,13 +11,13 @@ import (
11
11
func TestLoggingAuditor (t * testing.T ) {
12
12
tests := []struct {
13
13
name string
14
- request * Request
14
+ request Request
15
15
expectedLevel string
16
16
expectedFields []string
17
17
}{
18
18
{
19
19
name : "allow request" ,
20
- request : & Request {
20
+ request : Request {
21
21
Method : "GET" ,
22
22
URL : "https://github.com" ,
23
23
Allowed : true ,
@@ -28,7 +28,7 @@ func TestLoggingAuditor(t *testing.T) {
28
28
},
29
29
{
30
30
name : "deny request" ,
31
- request : & Request {
31
+ request : Request {
32
32
Method : "POST" ,
33
33
URL : "https://example.com" ,
34
34
Allowed : false ,
@@ -38,7 +38,7 @@ func TestLoggingAuditor(t *testing.T) {
38
38
},
39
39
{
40
40
name : "allow with empty rule" ,
41
- request : & Request {
41
+ request : Request {
42
42
Method : "PUT" ,
43
43
URL : "https://api.github.com/repos" ,
44
44
Allowed : true ,
@@ -49,7 +49,7 @@ func TestLoggingAuditor(t *testing.T) {
49
49
},
50
50
{
51
51
name : "deny HTTPS request" ,
52
- request : & Request {
52
+ request : Request {
53
53
Method : "GET" ,
54
54
URL : "https://malware.bad.com/payload" ,
55
55
Allowed : false ,
@@ -59,7 +59,7 @@ func TestLoggingAuditor(t *testing.T) {
59
59
},
60
60
{
61
61
name : "allow with wildcard rule" ,
62
- request : & Request {
62
+ request : Request {
63
63
Method : "POST" ,
64
64
URL : "https://api.github.com/graphql" ,
65
65
Allowed : true ,
@@ -70,7 +70,7 @@ func TestLoggingAuditor(t *testing.T) {
70
70
},
71
71
{
72
72
name : "deny HTTP request" ,
73
- request : & Request {
73
+ request : Request {
74
74
Method : "GET" ,
75
75
URL : "http://insecure.example.com" ,
76
76
Allowed : false ,
@@ -80,7 +80,7 @@ func TestLoggingAuditor(t *testing.T) {
80
80
},
81
81
{
82
82
name : "allow HEAD request" ,
83
- request : & Request {
83
+ request : Request {
84
84
Method : "HEAD" ,
85
85
URL : "https://cdn.jsdelivr.net/health" ,
86
86
Allowed : true ,
@@ -91,7 +91,7 @@ func TestLoggingAuditor(t *testing.T) {
91
91
},
92
92
{
93
93
name : "deny OPTIONS request" ,
94
- request : & Request {
94
+ request : Request {
95
95
Method : "OPTIONS" ,
96
96
URL : "https://restricted.api.com/cors" ,
97
97
Allowed : false ,
@@ -101,7 +101,7 @@ func TestLoggingAuditor(t *testing.T) {
101
101
},
102
102
{
103
103
name : "allow with port number" ,
104
- request : & Request {
104
+ request : Request {
105
105
Method : "GET" ,
106
106
URL : "https://localhost:3000/api/health" ,
107
107
Allowed : true ,
@@ -112,7 +112,7 @@ func TestLoggingAuditor(t *testing.T) {
112
112
},
113
113
{
114
114
name : "deny DELETE request" ,
115
- request : & Request {
115
+ request : Request {
116
116
Method : "DELETE" ,
117
117
URL : "https://api.production.com/users/admin" ,
118
118
Allowed : false ,
@@ -153,13 +153,13 @@ func TestLoggingAuditor(t *testing.T) {
153
153
func TestLoggingAuditor_EdgeCases (t * testing.T ) {
154
154
tests := []struct {
155
155
name string
156
- request * Request
156
+ request Request
157
157
expectedLevel string
158
158
expectedFields []string
159
159
}{
160
160
{
161
161
name : "empty fields" ,
162
- request : & Request {
162
+ request : Request {
163
163
Method : "" ,
164
164
URL : "" ,
165
165
Allowed : true ,
@@ -170,7 +170,7 @@ func TestLoggingAuditor_EdgeCases(t *testing.T) {
170
170
},
171
171
{
172
172
name : "special characters in URL" ,
173
- request : & Request {
173
+ request : Request {
174
174
Method : "POST" ,
175
175
URL : "https://api.example.com/users?name=John%20Doe&id=123" ,
176
176
Allowed : true ,
@@ -181,7 +181,7 @@ func TestLoggingAuditor_EdgeCases(t *testing.T) {
181
181
},
182
182
{
183
183
name : "very long URL" ,
184
- request : & Request {
184
+ request : Request {
185
185
Method : "GET" ,
186
186
URL : "https://example.com/" + strings .Repeat ("a" , 1000 ),
187
187
Allowed : false ,
@@ -191,7 +191,7 @@ func TestLoggingAuditor_EdgeCases(t *testing.T) {
191
191
},
192
192
{
193
193
name : "deny with custom URL" ,
194
- request : & Request {
194
+ request : Request {
195
195
Method : "DELETE" ,
196
196
URL : "https://malicious.com" ,
197
197
Allowed : false ,
@@ -233,13 +233,13 @@ func TestLoggingAuditor_DifferentLogLevels(t *testing.T) {
233
233
tests := []struct {
234
234
name string
235
235
logLevel slog.Level
236
- request * Request
236
+ request Request
237
237
expectOutput bool
238
238
}{
239
239
{
240
240
name : "info level allows info logs" ,
241
241
logLevel : slog .LevelInfo ,
242
- request : & Request {
242
+ request : Request {
243
243
Method : "GET" ,
244
244
URL : "https://github.com" ,
245
245
Allowed : true ,
@@ -250,7 +250,7 @@ func TestLoggingAuditor_DifferentLogLevels(t *testing.T) {
250
250
{
251
251
name : "warn level blocks info logs" ,
252
252
logLevel : slog .LevelWarn ,
253
- request : & Request {
253
+ request : Request {
254
254
Method : "GET" ,
255
255
URL : "https://github.com" ,
256
256
Allowed : true ,
@@ -261,7 +261,7 @@ func TestLoggingAuditor_DifferentLogLevels(t *testing.T) {
261
261
{
262
262
name : "warn level allows warn logs" ,
263
263
logLevel : slog .LevelWarn ,
264
- request : & Request {
264
+ request : Request {
265
265
Method : "POST" ,
266
266
URL : "https://example.com" ,
267
267
Allowed : false ,
@@ -271,7 +271,7 @@ func TestLoggingAuditor_DifferentLogLevels(t *testing.T) {
271
271
{
272
272
name : "error level blocks warn logs" ,
273
273
logLevel : slog .LevelError ,
274
- request : & Request {
274
+ request : Request {
275
275
Method : "POST" ,
276
276
URL : "https://example.com" ,
277
277
Allowed : false ,
@@ -312,7 +312,7 @@ func TestLoggingAuditor_NilLogger(t *testing.T) {
312
312
}()
313
313
314
314
auditor := & LoggingAuditor {logger : nil }
315
- req := & Request {
315
+ req := Request {
316
316
Method : "GET" ,
317
317
URL : "https://example.com" ,
318
318
Allowed : true ,
@@ -331,7 +331,7 @@ func TestLoggingAuditor_JSONHandler(t *testing.T) {
331
331
}))
332
332
333
333
auditor := NewLoggingAuditor (logger )
334
- req := & Request {
334
+ req := Request {
335
335
Method : "GET" ,
336
336
URL : "https://github.com" ,
337
337
Allowed : true ,
@@ -364,7 +364,7 @@ func TestLoggingAuditor_DiscardHandler(t *testing.T) {
364
364
logger := slog .New (slog .NewTextHandler (io .Discard , & slog.HandlerOptions {}))
365
365
366
366
auditor := NewLoggingAuditor (logger )
367
- req := & Request {
367
+ req := Request {
368
368
Method : "GET" ,
369
369
URL : "https://example.com" ,
370
370
Allowed : true ,
0 commit comments