@@ -10,8 +10,10 @@ import eu.opencloud.android.lib.common.accounts.AccountUtils
1010import eu.opencloud.android.lib.common.authentication.OpenCloudCredentialsFactory
1111import eu.opencloud.android.lib.common.operations.RemoteOperationResult
1212import eu.opencloud.android.lib.resources.files.tus.CreateTusUploadRemoteOperation.Base64Encoder
13+ import okhttp3.mockwebserver.Dispatcher
1314import okhttp3.mockwebserver.MockResponse
1415import okhttp3.mockwebserver.MockWebServer
16+ import okhttp3.mockwebserver.RecordedRequest
1517import org.junit.After
1618import org.junit.Assert.*
1719import org.junit.Before
@@ -190,13 +192,27 @@ class TusIntegrationTest {
190192 val firstChunkSize = 50L
191193
192194 // POST Create with Upload -> 201 + Location + Upload-Offset
193- server.enqueue(
194- MockResponse ()
195- .setResponseCode(201 )
196- .addHeader(" Tus-Resumable" , " 1.0.0" )
197- .addHeader(" Location" , locationPath)
198- .addHeader(" Upload-Offset" , firstChunkSize.toString())
199- )
195+ server.dispatcher = object : Dispatcher () {
196+ override fun dispatch (request : RecordedRequest ): MockResponse {
197+ if (request.path == collectionPath) {
198+ // Verify body content
199+ val bodySize = request.bodySize
200+ assertEquals(firstChunkSize, bodySize)
201+
202+ // Verify body bytes (first 50 bytes of the file)
203+ val expectedBytes = ByteArray (firstChunkSize.toInt()) { it.toByte() }
204+ val actualBytes = request.body.readByteArray()
205+ assertArrayEquals(expectedBytes, actualBytes)
206+
207+ return MockResponse ()
208+ .setResponseCode(201 )
209+ .addHeader(" Tus-Resumable" , " 1.0.0" )
210+ .addHeader(" Location" , locationPath)
211+ .addHeader(" Upload-Offset" , bodySize.toString())
212+ }
213+ return MockResponse ().setResponseCode(404 )
214+ }
215+ }
200216
201217 val create = CreateTusUploadRemoteOperation (
202218 file = localFile,
0 commit comments