Add additional group terminate checks.

This commit is contained in:
Cody Henthorne
2026-03-24 16:12:45 -04:00
parent d97bde3959
commit c81f40eb74
20 changed files with 201 additions and 47 deletions

View File

@@ -129,7 +129,8 @@ class GroupManagerV2Test_edit {
every { groupTable.getGroup(groupId) } returns data.groupRecord
every { groupTable.requireGroup(groupId) } returns data.groupRecord.get()
every { groupTable.update(any<GroupId.V2>(), any(), any()) } returns Unit
every { groupTable.update(any<GroupId.V2>(), any(), any(), anyNullable()) } returns Unit
every { Recipient.self() } returns RecipientDatabaseTestUtils.createRecipient(isSelf = true, recipientId = RecipientId.from(1L))
every { sendGroupUpdateHelper.sendGroupUpdate(masterKey, any(), any(), any()) } returns GroupManagerV2.RecipientAndThread(Recipient.UNKNOWN, 1)
every { groupsV2API.patchGroup(any(), any(), any()) } returns GroupChangeResponse(group_change = data.groupChange!!)
every { Recipient.externalGroupExact(groupId) } returns RecipientDatabaseTestUtils.createRecipient(resolved = true)
@@ -141,7 +142,7 @@ class GroupManagerV2Test_edit {
private fun then(then: (DecryptedGroup) -> Unit) {
val decryptedGroupArg = slot<DecryptedGroup>()
verify { groupTable.update(groupId, capture(decryptedGroupArg), any()) }
verify { groupTable.update(groupId, capture(decryptedGroupArg), any(), anyNullable()) }
then(decryptedGroupArg.captured)
}

View File

@@ -161,7 +161,7 @@ class GroupsV2StateProcessorTest {
every { groupsV2Authorization.getAuthorizationForToday(serviceIds, secretParams) } returns null
if (data.expectTableUpdate) {
justRun { groupTable.update(any<GroupMasterKey>(), any<DecryptedGroup>(), any<ReceivedGroupSendEndorsements>()) }
justRun { groupTable.update(any<GroupMasterKey>(), any<DecryptedGroup>(), anyNullable<ReceivedGroupSendEndorsements>(), anyNullable<RecipientId>()) }
}
if (data.expectTableCreate) {
@@ -171,6 +171,7 @@ class GroupsV2StateProcessorTest {
if (data.expectTableUpdate || data.expectTableCreate) {
justRun { profileAndMessageHelper.storeMessage(any(), any(), any()) }
justRun { profileAndMessageHelper.persistLearnedProfileKeys(any<ProfileKeySet>()) }
justRun { profileAndMessageHelper.stopAllTypingForGroup() }
}
data.serverState?.let { serverState ->
@@ -1052,7 +1053,7 @@ class GroupsV2StateProcessorTest {
}
@Test
fun `when P2P change terminates group with known editor, then setTerminatedBy is called`() {
fun `when P2P change terminates group with known editor, then update is called with terminator recipient id`() {
val adminAci: ACI = ACI.from(UUID.randomUUID())
val adminRecipientId = RecipientId.from(200)
@@ -1065,7 +1066,6 @@ class GroupsV2StateProcessorTest {
}
every { recipientTable.getAndPossiblyMerge(adminAci, null) } returns adminRecipientId
justRun { groupTable.setTerminatedBy(groupId, adminRecipientId) }
val signedChange = DecryptedGroupChange(
revision = 6,
@@ -1087,7 +1087,7 @@ class GroupsV2StateProcessorTest {
assertThat(it.terminated, "group should be terminated").isEqualTo(true)
}
verify { groupTable.setTerminatedBy(groupId, adminRecipientId) }
verify { groupTable.update(masterKey, match { it.terminated }, null, adminRecipientId) }
}
@Test