mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Add method to delete all private messages to REST API
Needed for https://code.briarproject.org/briar/briar-gtk/-/issues/11. Fixes #1782
This commit is contained in:
@@ -17,6 +17,7 @@ import org.briarproject.bramble.test.ImmediateExecutor
|
||||
import org.briarproject.bramble.test.TestUtils.getRandomId
|
||||
import org.briarproject.bramble.util.StringUtils.getRandomString
|
||||
import org.briarproject.briar.api.client.SessionId
|
||||
import org.briarproject.briar.api.conversation.DeletionResult
|
||||
import org.briarproject.briar.api.introduction.IntroductionRequest
|
||||
import org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_TEXT_LENGTH
|
||||
import org.briarproject.briar.api.messaging.MessagingManager
|
||||
@@ -343,6 +344,30 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
assertJsonEquals(json, request.output(contact.id))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteAllMessages() {
|
||||
every { ctx.pathParam("contactId") } returns "1"
|
||||
every { conversationManager.deleteAllMessages(ContactId(1)) } returns DeletionResult()
|
||||
controller.deleteAllMessages(ctx)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteAllMessagesInvalidContactId() {
|
||||
every { ctx.pathParam("contactId") } returns "foo"
|
||||
assertThrows(NotFoundResponse::class.java) {
|
||||
controller.deleteAllMessages(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteAllMessagesNonexistentContactId() {
|
||||
every { ctx.pathParam("contactId") } returns "1"
|
||||
every { conversationManager.deleteAllMessages(ContactId(1)) } throws NoSuchContactException()
|
||||
assertThrows(NotFoundResponse::class.java) {
|
||||
controller.deleteAllMessages(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
private fun expectGetContact() {
|
||||
every { ctx.pathParam("contactId") } returns contact.id.int.toString()
|
||||
every { contactManager.getContact(contact.id) } returns contact
|
||||
|
||||
Reference in New Issue
Block a user