Loading app/core/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java +1 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,7 @@ public class PgpMessageBuilder extends MessageBuilder { throw new MessagingException("Attachments are not supported in PGP/INLINE format!"); } if (shouldEncrypt && !cryptoStatus.hasRecipients()) { if (shouldEncrypt && !isDraft() && !cryptoStatus.hasRecipients()) { throw new MessagingException("Must have recipients to build message!"); } Loading app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,25 @@ class PgpMessageBuilderTest : RobolectricTest() { verifyNoMoreInteractions(mockCallback) } @Test @Throws(MessagingException::class) fun buildEncrypt__draftWithoutRecipients() { val cryptoStatus = defaultCryptoStatus.copy(cryptoMode = CryptoMode.CHOICE_ENABLED) pgpMessageBuilder.setCryptoStatus(cryptoStatus) pgpMessageBuilder.isDraft = true val returnIntent = spy(Intent()) returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS) `when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java))) .thenReturn(returnIntent) val mockCallback = mock(Callback::class.java) pgpMessageBuilder.buildAsync(mockCallback) verify(mockCallback).onMessageBuildSuccess(any<MimeMessage>(), eq(true)) verifyNoMoreInteractions(mockCallback) } @Test @Throws(MessagingException::class) fun buildEncrypt__checkGossip() { Loading app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt +1 −3 Original line number Diff line number Diff line Loading @@ -130,9 +130,7 @@ data class ComposeCryptoStatus(private val openPgpProviderState: OpenPgpProvider fun hasAutocryptPendingIntent() = recipientAutocryptStatus?.hasPendingIntent() == true override fun hasRecipients(): Boolean { return recipientAddresses.isNotEmpty() } override fun hasRecipients() = recipientAddresses.isNotEmpty() override fun getRecipientAddresses() = recipientAddresses.toTypedArray() Loading Loading
app/core/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java +1 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,7 @@ public class PgpMessageBuilder extends MessageBuilder { throw new MessagingException("Attachments are not supported in PGP/INLINE format!"); } if (shouldEncrypt && !cryptoStatus.hasRecipients()) { if (shouldEncrypt && !isDraft() && !cryptoStatus.hasRecipients()) { throw new MessagingException("Must have recipients to build message!"); } Loading
app/core/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,25 @@ class PgpMessageBuilderTest : RobolectricTest() { verifyNoMoreInteractions(mockCallback) } @Test @Throws(MessagingException::class) fun buildEncrypt__draftWithoutRecipients() { val cryptoStatus = defaultCryptoStatus.copy(cryptoMode = CryptoMode.CHOICE_ENABLED) pgpMessageBuilder.setCryptoStatus(cryptoStatus) pgpMessageBuilder.isDraft = true val returnIntent = spy(Intent()) returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS) `when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java))) .thenReturn(returnIntent) val mockCallback = mock(Callback::class.java) pgpMessageBuilder.buildAsync(mockCallback) verify(mockCallback).onMessageBuildSuccess(any<MimeMessage>(), eq(true)) verifyNoMoreInteractions(mockCallback) } @Test @Throws(MessagingException::class) fun buildEncrypt__checkGossip() { Loading
app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt +1 −3 Original line number Diff line number Diff line Loading @@ -130,9 +130,7 @@ data class ComposeCryptoStatus(private val openPgpProviderState: OpenPgpProvider fun hasAutocryptPendingIntent() = recipientAutocryptStatus?.hasPendingIntent() == true override fun hasRecipients(): Boolean { return recipientAddresses.isNotEmpty() } override fun hasRecipients() = recipientAddresses.isNotEmpty() override fun getRecipientAddresses() = recipientAddresses.toTypedArray() Loading