MCPcopy Create free account
hub / github.com/cloudflare/cfssl / TestHTTP

Function TestHTTP

errors/error_test.go:288–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

286}
287
288func TestHTTP(t *testing.T) {
289 err := NewMethodNotAllowed("GET")
290 if err == nil {
291 t.Fatal("New Mathod Check failed")
292 }
293
294 err = NewBadRequest(errors.New("Bad Request"))
295 if err == nil {
296 t.Fatal("New Bad Request Check failed")
297 }
298
299 if err.StatusCode != 400 {
300 t.Fatal("New Bad Request error code construction failed")
301 }
302
303 err = NewBadRequestString("Bad Request String")
304 if err == nil {
305 t.Fatal("New Bad Request String Check failed")
306 }
307
308 if err.StatusCode != 400 {
309 t.Fatal("New Bad Request String error code construction failed")
310 }
311
312 err = NewBadRequestMissingParameter("Request Missing Parameter")
313 if err == nil {
314 t.Fatal("New Bad Request Missing Parameter Check failed")
315 }
316
317 if err.StatusCode != 400 {
318 t.Fatal("New Bad Request Missing Parameter error code construction failed")
319 }
320
321 err = NewBadRequestUnwantedParameter("Unwanted Parameter Present In Request")
322 if err == nil {
323 t.Fatal("New Bad Request Unwanted Parameter Check failed")
324 }
325
326 if err.StatusCode != 400 {
327 t.Fatal("New Bad Request Unwanted Parameter error code construction failed")
328 }
329
330}
331
332func TestHTTPErrorString(t *testing.T) {
333 method := "GET"

Callers

nothing calls this directly

Calls 6

NewMethodNotAllowedFunction · 0.85
NewBadRequestFunction · 0.85
NewBadRequestStringFunction · 0.85
NewMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…