CardDavFilterTest.ktCardDavFilter.handledByCardDavFilter() static method correctly routes HTTP requests to the CardDAV servlet based on HTTP method and request URI patterns. Ensures only CardDAV-relevant requests (OPTIONS, PROPFIND, REPORT, GET on known paths) are intercepted by the filter while unrelated requests pass through.This test validates the CardDAV request routing logic in CardDavFilter. The system uses a Servlet Filter pattern — HTTP requests arrive at the application server and the filter decides whether to forward them to the CardDAV handler or let them continue through the normal request pipeline.
The test employs a parameterized helper method pattern: checkRequest(method, requestUri, expected, msg?) creates a mocked HttpServletRequest via Mockito, stubs requestURI and method, then asserts the return value of CardDavFilter.handledByCardDavFilter(request) matches expected.
| HTTP Method | URI Pattern | Expected | Rationale |
|---|---|---|---|
| OPTIONS | /carddav, /carddav/users/kai, /users/kai, /users, /principals | true | OPTIONS is a CORS preflight / DAV capability check — all known CardDAV paths respond |
| PROPFIND | /carddav, /carddav/users/kai, /users/kai, /carddav/users/, /users, /carddav/principals/, /principals | true | PROPFIND is the WebDAV property-fetch method; intercepted on all user and principal URLs |
| OPTIONS | /.well-known/carddav | true | Well-known URI discovery per RFC 6764 for CardDAV service location |
| GET | /.well-known/carddav | true | GET on well-known URI returns service discovery info |
| GET | /principals | false | GET principal listing without DAV headers is not CardDAV |
| GET | /carddav | true | GET on base carddav path |
| GET | /carddav/users/joe/addressbooks/ProjectForge-123.vcf | true | VCF download with dash-separated ID pattern "ProjectForge-123" |
| GET | /users/joe/addressbooks/ProjectForge-123.vcf | true | Same without /carddav prefix |
| GET | /users/joe/addressbooks/ProjectForge123.vcf | false | Missing dash separator — not recognized as ProjectForge identifier |
| GET | /users/joe/address/ProjectForge-123.vcf | false | Wrong path segment "address" instead of "addressbooks" |
Uses Mockito.mock(HttpServletRequest::class.java) to create mock servlet requests. Then Mockito.when(request.method).thenReturn(method) and Mockito.when(request.requestURI).thenReturn(requestUri) set up the test fixture. No real HTTP server is involved — pure unit testing of the routing function.
868d6abb7 2025 -> 2026 63081666f Source file headers: 2024-> 2025. fc6301b43 WIP: CardDavServer. 6c1daac93 WIP: Carddav 78a5132bf WIP: Carddav c4062ed97 WIP: Carddav 40e554cbe WIP: Carddav ad8b47d1f WIP: CardDavWIP: CardDav