(t *testing.T)
| 503 | } |
| 504 | |
| 505 | func TestCSRFErrorHandling(t *testing.T) { |
| 506 | cfg := CSRFConfig{ |
| 507 | ErrorHandler: func(c *echo.Context, err error) error { |
| 508 | return echo.NewHTTPError(http.StatusTeapot, "error_handler_executed") |
| 509 | }, |
| 510 | } |
| 511 | |
| 512 | e := echo.New() |
| 513 | e.POST("/", func(c *echo.Context) error { |
| 514 | return c.String(http.StatusNotImplemented, "should not end up here") |
| 515 | }) |
| 516 | |
| 517 | e.Use(CSRFWithConfig(cfg)) |
| 518 | |
| 519 | req := httptest.NewRequest(http.MethodPost, "/", nil) |
| 520 | res := httptest.NewRecorder() |
| 521 | e.ServeHTTP(res, req) |
| 522 | |
| 523 | assert.Equal(t, http.StatusTeapot, res.Code) |
| 524 | assert.Equal(t, "{\"message\":\"error_handler_executed\"}\n", res.Body.String()) |
| 525 | } |
| 526 | |
| 527 | func TestCSRFConfig_checkSecFetchSiteRequest(t *testing.T) { |
| 528 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…