@@ -23,6 +23,9 @@ func TestDefaultModuleConfig(t *testing.T) {
23
23
if c .AnomalySize () != DefaultAnomalySize {
24
24
t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
25
25
}
26
+ if len (c .ExpectedContentTypes ()) != 0 {
27
+ t .Errorf ("Unexpected ExpectedContentTypes: expected length 0, got %d" , len (c .ExpectedContentTypes ()))
28
+ }
26
29
if c .Debug () != DefaultDebug {
27
30
t .Errorf ("Unexpected Debug: %v" , c .Debug ())
28
31
}
@@ -88,6 +91,8 @@ func TestConfiguredModuleConfig(t *testing.T) {
88
91
AnomalySize (8192 ),
89
92
CustomInspector (& RPCInspector {}, func (_ * http.Request ) bool { return true }, func (_ * http.Request ) {}),
90
93
CustomHeaderExtractor (func (_ * http.Request ) (http.Header , error ) { return nil , nil }),
94
+ ExpectedContentType ("application/foobar" ),
95
+ ExpectedContentType ("application/fizzbuzz" ),
91
96
Debug (true ),
92
97
MaxContentLength (500000 ),
93
98
Socket ("tcp" , "0.0.0.0:1234" ),
@@ -108,6 +113,9 @@ func TestConfiguredModuleConfig(t *testing.T) {
108
113
if c .AnomalySize () != 8192 {
109
114
t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
110
115
}
116
+ if len (c .ExpectedContentTypes ()) != 2 || c .ExpectedContentTypes ()[0 ] != "application/foobar" || c .ExpectedContentTypes ()[1 ] != "application/fizzbuzz" {
117
+ t .Errorf ("Unexpected ExpectedContentTypes: %v" , c .ExpectedContentTypes ())
118
+ }
111
119
if c .Debug () != true {
112
120
t .Errorf ("Unexpected Debug: %v" , c .Debug ())
113
121
}
@@ -171,6 +179,8 @@ func TestFromModuleConfig(t *testing.T) {
171
179
AltResponseCodes (403 ),
172
180
AnomalyDuration (10 * time .Second ),
173
181
AnomalySize (8192 ),
182
+ ExpectedContentType ("application/foobar" ),
183
+ ExpectedContentType ("application/fizzbuzz" ),
174
184
CustomInspector (& RPCInspector {}, func (_ * http.Request ) bool { return true }, func (_ * http.Request ) {}),
175
185
CustomHeaderExtractor (func (_ * http.Request ) (http.Header , error ) { return nil , nil }),
176
186
Debug (true ),
@@ -200,6 +210,9 @@ func TestFromModuleConfig(t *testing.T) {
200
210
if c .AnomalySize () != 8192 {
201
211
t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
202
212
}
213
+ if len (c .ExpectedContentTypes ()) != 2 || c .ExpectedContentTypes ()[0 ] != "application/foobar" || c .ExpectedContentTypes ()[1 ] != "application/fizzbuzz" {
214
+ t .Errorf ("Unexpected ExpectedContentTypes: %v" , c .ExpectedContentTypes ())
215
+ }
203
216
if c .Debug () != true {
204
217
t .Errorf ("Unexpected Debug: %v" , c .Debug ())
205
218
}
0 commit comments