#120: DataTransferPublicAccessTest.kt

plugins/org.projectforge.plugins.datatransfer/src/test/kotlin/org/projectforge/plugins/datatransfer/DataTransferPublicAccessTest.kt Path: plugins/...datatransfer/src/test/kotlin/.../DataTransferPublicAccessTest.kt · Lines: 227 · Type: Kotlin JUnit 5 integration test 227 lines · 177 code · 24 comments · 26 blank

Integration test for the public (external) DataTransfer REST layer — the most comprehensive DataTransfer test at 227 lines. Tests the anonymous access flow: external link → login → upload/download/delete → logout, using mocked HTTP requests and JCR files.

Components under test

Test scenarios (~10 test methods)

Mocked HTTP layer

Uses Mockito to mock HttpServletRequest and HttpSession — critical because DataTransferPublicSession stores data directly in HTTP session attributes. The mock session simulates getSession(false), getSession(true), getAttribute("transferAreas"), setAttribute(), and invalidate() — all exercised in the session fixation test.

Also mocks MultipartFile for upload tests and HttpServletResponse + ServletOutputStreamByteArrayOutputStream for download content capture.