PropFindRequestHandlerTest.ktPropFindRequestHandler.generatePropFindResponse() — the core WebDAV PROPFIND response generator. Verifies correct XML multistatus responses for two scenarios: resource type/displayname queries and principal/privilege queries. Uses Mockito mocks for HTTP servlet objects and a real PFUserDO entity.PropFindRequestHandler is the server-side handler that responds to CardDAV PROPFIND requests per RFC 4918 (WebDAV). PROPFIND is the primary mechanism by which CardDAV clients discover server capabilities, resource types, and user principal information.
When a client PROPFINDs for resourcetype and displayname properties on /carddav/users/kai/, the handler must respond with:
<d:collection /> (indicating this is a collection/container resource)kai (the username)The response is a full XML multistatus document with DAV, CardDAV, CalDAV, and custom namespace declarations.
When a client queries user identity properties:
<d:href>/carddav/principals/users/kai/</d:href>read, write, write-properties, write-content<d:href>/carddav/principals/users/kai/</d:href>| Class | Role |
|---|---|
Prop | Represents a single requested DAV property with a PropType enum value |
PropType | Enum of known DAV properties: RESOURCETYPE, DISPLAYNAME, CURRENT_USER_PRINCIPAL, CURRENT_USER_PRIVILEGE_SET, PRINCIPAL_URL, GETETAG, GETCTAG, SYNCTOKEN |
RequestWrapper | Wraps HttpServletRequest, extracts the request URI for response href generation |
WriterContext | Bundles request wrapper, response, user, and requested props — the complete context needed by the handler |
PropFindRequestHandler | Static method generatePropFindResponse(WriterContext): String — pure function generating XML string |
/carddav/users/kai/ as requestURIusername = "kai" — no mocking neededAll responses include these XML namespace declarations:
xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:cs="http://calendarserver.org/ns/" xmlns:me="http://me.com/_namespace/"
These correspond to: DAV core, CardDAV, Apple CalendarServer extensions, and a custom namespace.
| Commit | What changed in this file |
|---|---|
868d6abb7 | Copyright year 2025→2026. No logic change. |
63081666f | Copyright year 2024→2025. No logic change. |
f86cfa20a | Removed <card:addressbook/> from expected XML. Resource type reports only <d:collection/> — no longer claims CardDAV address book capability. Final cleanup after the addressbook element went through multiple add/remove cycles. |
139f9f316 | Added <card:addressbook/> to resource type. Part of photo/avatar support — the element was briefly added to advertise CardDAV capability, then removed again in f86cfa20a. |
5167dab99 | Major API change. (1) Prop.RESOURCETYPE→Prop(PropType.RESOURCETYPE): Prop became constructor-based. (2) Display name changed from i18n key "address.cardDAV..." to actual username "kai". (3) <card:addressbook/> temporarily removed. |
6c1daac93 | Introduced WriterContext. generatePropFindResponse() signature changed from (request, user, props) to a single context object. Added HttpServletResponse mock. Cleaner extensibility. |
0d7a81f91 | Added xmlns:me namespace. Swapped element order: <collection/> before <addressbook/>. DAV-required element now comes first. |
b14376470 | cr:addressbook→card:addressbook. Namespace prefix standardized from obscure cr to conventional card. |
744d238de | Namespace URI fix. xmlns prefix cr→card, corrected the CardDAV namespace URI string. |
c4062ed97 | Added XML namespace prefixes. Bare elements (<multistatus>) → namespace-qualified (<d:multistatus>). Matched handler output after it started emitting qualified XML. |
40e554cbe | Changed test URI from generic /carddav to user-specific /carddav/users/kai/. Matched actual per-user URL structure. |
2ad0cfe66 | Initial creation. Basic PROPFIND test with inline XML literals, Mockito HTTP mocks. Verified RESOURCETYPE + DISPLAYNAME properties. |