@SneakyThrows
@Test
void readVersionedDocumentTest() {

    when(versionedDatasafeServices.latestPrivate().read(any())).thenReturn(new PasswordClearingInputStream(new ByteArrayInputStream("hello".getBytes()), null));
    RestDocumentationResultHandler document = document("versioned-read-success",
            pathParameters(
                    parameterWithName("path").description("path to the file")
            ),
            requestHeaders(
                    headerWithName("token").description(TOKEN_DESCRIPTION),
                    headerWithName("user").description(USER_DESCRIPTION),
                    headerWithName("password").description(PASSWORD_DESCRIPTION)
            )
    );
    String path = "path/to/file";
    mvc.perform(get("/versioned/{path}", path)
            .header("user", TEST_USER)
            .header("password", TEST_PASS)
            .header("token", token)
            .accept(MediaType.APPLICATION_OCTET_STREAM_VALUE))
            .andExpect(status().isOk())
            .andExpect(header().string(CONTENT_TYPE, APPLICATION_OCTET_STREAM_VALUE))
            .andDo(document);
    verify(versionedPrivateSpaceService).read(any());
}