adding separate image for encrypted image test and re-enabling clear image test

This commit is contained in:
Adam Brown 2022-09-21 22:51:00 +01:00 committed by Adam Brown
parent e70ed9f6e5
commit 5472b41d73
4 changed files with 9 additions and 13 deletions

View File

@ -66,7 +66,6 @@ internal class SendMessageUseCase(
true -> {
val result = mediaEncrypter.encrypt(imageContent.inputStream())
val bytes = File(result.uri).readBytes()
println("!!! ${bytes.size}")
val uri = httpClient.execute(uploadRequest(bytes, imageContent.fileName, "application/octet-stream")).contentUri
@ -114,9 +113,7 @@ internal class SendMessageUseCase(
}
false -> {
val bytes = ByteArrayOutputStream().also {
it.writeTo(imageContent.outputStream())
}.toByteArray()
val bytes = File(imageContent.uri).readBytes()
val uri = httpClient.execute(uploadRequest(bytes, imageContent.fileName, imageContent.mimeType)).contentUri
sendRequest(

View File

@ -71,18 +71,18 @@ class SmokeTest {
@Order(5)
fun `can send and receive encrypted text messages`() = testTextMessaging(isEncrypted = true)
// @Test
// @Order(6)
// fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob ->
// val testImage = loadResourceFile("test-image.png")
// alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false)
// bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember, isEncrypted = false)
// }
@Test
@Order(6)
fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob ->
val testImage = loadResourceFile("test-image.png")
alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false)
bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember)
}
@Test
@Order(7)
fun `can send and receive encrypted image messages`() = testAfterInitialSync { alice, bob ->
val testImage = loadResourceFile("test-image.png")
val testImage = loadResourceFile("test-image2.png")
alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = true)
bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember)
}

View File

@ -147,7 +147,6 @@ class MatrixTestScope(private val testScope: TestScope) {
this.client.syncService().room(roomId)
.map {
it.events.filterIsInstance<RoomEvent.Image>().map {
println("found: ${it}")
val output = File(image.parentFile.absolutePath, "output.png")
HttpClient().request(it.imageMeta.url).bodyAsChannel().copyAndClose(output.writeChannel())
val md5Hash = when (val keys = it.imageMeta.keys) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB