fix(caldav): return 404 when trying to access a project that cannot exist with CalDAV (#2796)
This commit is contained in:
parent
50bece8cdb
commit
069685f2a7
|
|
@ -185,7 +185,8 @@ func getProjectFromParam(c *echo.Context) (project *models.ProjectWithTasksAndBu
|
|||
|
||||
intParam, err := strconv.ParseInt(param, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// The project ID given is not an integer, it cannot exist
|
||||
return nil, models.ErrProjectDoesNotExist{}
|
||||
}
|
||||
|
||||
if intParam == models.FavoritesPseudoProjectID {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ func TestCaldav(t *testing.T) {
|
|||
assert.Contains(t, rec.Body.String(), "END:VTODO")
|
||||
assert.Contains(t, rec.Body.String(), "END:VCALENDAR")
|
||||
})
|
||||
t.Run("Returns 404 for non-integer project param", func(t *testing.T) {
|
||||
e, _ := setupTestEnv()
|
||||
rec, err := newCaldavTestRequestWithUser(t, e, http.MethodGet, caldav.ProjectHandler, &testuser15, ``, nil, map[string]string{"project": "E6948AA3-86CC-40A1-874D-3B0A02FAA781"})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusNotFound, rec.Result().StatusCode)
|
||||
})
|
||||
t.Run("Import VTODO", func(t *testing.T) {
|
||||
const vtodo = `BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue