@@ -244,7 +244,7 @@ func SetupAndRunHTTPSource(t *testing.T, h *HTTPSource, config []byte, metricLev
244
244
return out , testRegistry , & tomb
245
245
}
246
246
247
- func TestStreamingAcquisitionWrongHTTPMethod (t * testing.T ) {
247
+ func TestStreamingAcquisitionHTTPMethod (t * testing.T ) {
248
248
h := & HTTPSource {}
249
249
_ , _ , tomb := SetupAndRunHTTPSource (t , h , []byte (`
250
250
source: http
@@ -259,13 +259,32 @@ basic_auth:
259
259
260
260
ctx := t .Context ()
261
261
262
- req , err := http .NewRequestWithContext (ctx , http .MethodGet , testHTTPServerAddr + "/test" , http .NoBody )
262
+ req , err := http .NewRequestWithContext (ctx , http .MethodPut , testHTTPServerAddr + "/test" , http .NoBody )
263
263
require .NoError (t , err )
264
264
265
+ // Method validity is checked after auth
266
+ req .SetBasicAuth ("test" , "test" )
267
+
265
268
res , err := http .DefaultClient .Do (req )
266
269
require .NoError (t , err )
267
270
assert .Equal (t , http .StatusMethodNotAllowed , res .StatusCode )
268
271
272
+ // Check that GET/HEAD requests return a 200
273
+
274
+ req , err = http .NewRequestWithContext (ctx , http .MethodGet , testHTTPServerAddr + "/test" , http .NoBody )
275
+ require .NoError (t , err )
276
+ req .SetBasicAuth ("test" , "test" )
277
+ res , err = http .DefaultClient .Do (req )
278
+ require .NoError (t , err )
279
+ assert .Equal (t , http .StatusOK , res .StatusCode )
280
+
281
+ req , err = http .NewRequestWithContext (ctx , http .MethodHead , testHTTPServerAddr + "/test" , http .NoBody )
282
+ require .NoError (t , err )
283
+ req .SetBasicAuth ("test" , "test" )
284
+ res , err = http .DefaultClient .Do (req )
285
+ require .NoError (t , err )
286
+ assert .Equal (t , http .StatusOK , res .StatusCode )
287
+
269
288
h .Server .Close ()
270
289
tomb .Kill (nil )
271
290
err = tomb .Wait ()
0 commit comments