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

View File

@ -71,18 +71,18 @@ class SmokeTest {
@Order(5) @Order(5)
fun `can send and receive encrypted text messages`() = testTextMessaging(isEncrypted = true) fun `can send and receive encrypted text messages`() = testTextMessaging(isEncrypted = true)
// @Test @Test
// @Order(6) @Order(6)
// fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob -> fun `can send and receive clear image messages`() = testAfterInitialSync { alice, bob ->
// val testImage = loadResourceFile("test-image.png") val testImage = loadResourceFile("test-image.png")
// alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false) alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = false)
// bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember, isEncrypted = false) bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember)
// } }
@Test @Test
@Order(7) @Order(7)
fun `can send and receive encrypted image messages`() = testAfterInitialSync { alice, bob -> 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) alice.sendImageMessage(SharedState.sharedRoom, testImage, isEncrypted = true)
bob.expectImageMessage(SharedState.sharedRoom, testImage, SharedState.alice.roomMember) 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) this.client.syncService().room(roomId)
.map { .map {
it.events.filterIsInstance<RoomEvent.Image>().map { it.events.filterIsInstance<RoomEvent.Image>().map {
println("found: ${it}")
val output = File(image.parentFile.absolutePath, "output.png") val output = File(image.parentFile.absolutePath, "output.png")
HttpClient().request(it.imageMeta.url).bodyAsChannel().copyAndClose(output.writeChannel()) HttpClient().request(it.imageMeta.url).bodyAsChannel().copyAndClose(output.writeChannel())
val md5Hash = when (val keys = it.imageMeta.keys) { val md5Hash = when (val keys = it.imageMeta.keys) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB