@@ -23,6 +23,9 @@ func TestDefaultModuleConfig(t *testing.T) {
2323 if c .AnomalySize () != DefaultAnomalySize {
2424 t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
2525 }
26+ if len (c .ExpectedContentTypes ()) != 0 {
27+ t .Errorf ("Unexpected ExpectedContentTypes: expected length 0, got %d" , len (c .ExpectedContentTypes ()))
28+ }
2629 if c .Debug () != DefaultDebug {
2730 t .Errorf ("Unexpected Debug: %v" , c .Debug ())
2831 }
@@ -88,6 +91,8 @@ func TestConfiguredModuleConfig(t *testing.T) {
8891 AnomalySize (8192 ),
8992 CustomInspector (& RPCInspector {}, func (_ * http.Request ) bool { return true }, func (_ * http.Request ) {}),
9093 CustomHeaderExtractor (func (_ * http.Request ) (http.Header , error ) { return nil , nil }),
94+ ExpectedContentType ("application/foobar" ),
95+ ExpectedContentType ("application/fizzbuzz" ),
9196 Debug (true ),
9297 MaxContentLength (500000 ),
9398 Socket ("tcp" , "0.0.0.0:1234" ),
@@ -108,6 +113,9 @@ func TestConfiguredModuleConfig(t *testing.T) {
108113 if c .AnomalySize () != 8192 {
109114 t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
110115 }
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+ }
111119 if c .Debug () != true {
112120 t .Errorf ("Unexpected Debug: %v" , c .Debug ())
113121 }
@@ -171,6 +179,8 @@ func TestFromModuleConfig(t *testing.T) {
171179 AltResponseCodes (403 ),
172180 AnomalyDuration (10 * time .Second ),
173181 AnomalySize (8192 ),
182+ ExpectedContentType ("application/foobar" ),
183+ ExpectedContentType ("application/fizzbuzz" ),
174184 CustomInspector (& RPCInspector {}, func (_ * http.Request ) bool { return true }, func (_ * http.Request ) {}),
175185 CustomHeaderExtractor (func (_ * http.Request ) (http.Header , error ) { return nil , nil }),
176186 Debug (true ),
@@ -200,6 +210,9 @@ func TestFromModuleConfig(t *testing.T) {
200210 if c .AnomalySize () != 8192 {
201211 t .Errorf ("Unexpected AnomalySize: %v" , c .AnomalySize ())
202212 }
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+ }
203216 if c .Debug () != true {
204217 t .Errorf ("Unexpected Debug: %v" , c .Debug ())
205218 }
0 commit comments