(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func TestKeyAuth(t *testing.T) { |
| 33 | handlerCalled := false |
| 34 | handler := func(c *echo.Context) error { |
| 35 | handlerCalled = true |
| 36 | return c.String(http.StatusOK, "test") |
| 37 | } |
| 38 | middlewareChain := KeyAuth(testKeyValidator)(handler) |
| 39 | |
| 40 | e := echo.New() |
| 41 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 42 | req.Header.Set(echo.HeaderAuthorization, "Bearer valid-key") |
| 43 | rec := httptest.NewRecorder() |
| 44 | c := e.NewContext(req, rec) |
| 45 | |
| 46 | err := middlewareChain(c) |
| 47 | |
| 48 | assert.NoError(t, err) |
| 49 | assert.True(t, handlerCalled) |
| 50 | } |
| 51 | |
| 52 | func TestKeyAuthWithConfig(t *testing.T) { |
| 53 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…