Skip to content

Commit

Permalink
Add tests for GroupChatChatUpdates.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Nov 5, 2024
1 parent e0088ac commit 8e12c23
Show file tree
Hide file tree
Showing 94 changed files with 10,450 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ val ALL_TEST_CASES = listOf(
ChatItemStandardMessageWithQuoteTestCase,
ChatItemStickerMessageTestCase,
ChatItemRemoteDeleteTestCase,
ChatItemViewOnceTestCase
ChatItemViewOnceTestCase,
ChatItemGroupChangeChatUpdateTestCase
)

fun main(args: Array<String>) {
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/Permutations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class PermutationScope : Iterator<List<Message<*, *>>> {

fun <T> someEnum(clazz: Class<T>, excluding: T? = null): T = excluding?.let { some(Generators.enum(clazz, excluding)) } ?: some(Generators.enum(clazz))
fun <T> someEnum(clazz: Class<T>, vararg excluding: T): T = some(Generators.enum(clazz, *excluding))
inline fun <reified T> someEnum(clazz: Class<T>, excluding: List<T>): T = some(Generators.enum(clazz, *excluding.toTypedArray()))

fun someCallLinkRootKey(): ByteArray = some(Generators.callLinkRootKey())

Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/Util.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import okio.ByteString
import okio.ByteString.Companion.toByteString
import org.thoughtcrime.securesms.backup.v2.proto.Frame
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
Expand Down Expand Up @@ -88,6 +90,12 @@ fun base64Decode(value: String): ByteArray {
return Base64.getDecoder().decode(value)
}

/** Synthetic value to make it easier to get ACI's off of frames that you know are Contacts with ACI's */
val Frame.aci: ByteString
get() = this.recipient!!.contact!!.aci!!

fun UUID.toByteString(): ByteString = this.toByteArray().toByteString()

/**
* Takes a class and converts it to a nice, multi-line string with good indentation. Optimized for readability.
*/
Expand Down
349 changes: 349 additions & 0 deletions src/main/kotlin/tests/ChatItemGroupChangeChatUpdateTestCase.kt

Large diffs are not rendered by default.

Binary file not shown.
221 changes: 221 additions & 0 deletions test-cases/chat_item_group_change_chat_update_00.txtproto
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
// This file was auto-generated! It's only meant to show you what's in the .binproto. Do not edit!

BackupInfo {
backupTimeMs = 1715636551000
mediaRootBackupKey = <8fba3ce1946b78a4ca0d9229ddb050a12702072309d6574ae12451269e5fdbb2>
version = 1
}

Frame {
account = AccountData {
accountSettings = AccountSettings {
customChatColors = [
CustomChatColor {
id = 1
solid = -16777216
},
CustomChatColor {
id = 2
solid = -65536
},
CustomChatColor {
id = 3
solid = -16711936
}
]
displayBadgesOnProfile = true
hasCompletedUsernameOnboarding = true
hasSeenGroupStoryEducationSheet = true
hasSetMyStoriesPrivacy = true
hasViewedOnboardingStory = true
keepMutedChatsArchived = true
linkPreviews = true
notDiscoverableByPhoneNumber = true
phoneNumberSharingMode = PhoneNumberSharingMode.NOBODY
preferContactAvatars = true
preferredReactionEmoji = [
"a",
"b",
"c"
]
readReceipts = true
sealedSenderIndicators = true
storiesDisabled = true
storyViewReceiptsEnabled = true
typingIndicators = true
universalExpireTimerSeconds = 3600
}
avatarUrlPath = ""
donationSubscriberData = SubscriberData {
currencyCode = "USD"
manuallyCancelled = true
subscriberId = <ecbb68c734331a2ea333cda747c98c4553652261582b4fce5ae0dea84dce6519>
}
familyName = "Fett"
givenName = "Boba"
profileKey = <610291abedc34249489da39a31c9a5cd99cdd26ff58732e268e357ee0075d9d8>
username = "boba_fett.66"
usernameLink = UsernameLink {
color = Color.OLIVE
entropy = <65675c73d00eb01005e3bb7c4a47f296cb6554f78981238815e915d824fd2e93>
serverId = <61c101a200d5421789c20518d8497af0>
}
}
}

Frame {
recipient = Recipient {
id = 1
self = Self {}
}
}

Frame {
recipient = Recipient {
id = 2
releaseNotes = ReleaseNotes {}
}
}

Frame {
recipient = Recipient {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = ""
privacyMode = PrivacyMode.ALL
}
}
id = 3
}
}

Frame {
recipient = Recipient {
contact = Contact {
aci = <000a11ce000040008000000000000001>
e164 = 16105550101
pni = <000a11ce000040008000000000000002>
profileFamilyName = "Smith"
profileGivenName = "Alice"
profileKey = <d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d>
registered = Registered {}
visibility = Visibility.VISIBLE
}
id = 4
}
}

Frame {
recipient = Recipient {
contact = Contact {
aci = <00000b0b000040008000000000000001>
e164 = 16105550102
pni = <00000b0b000040008000000000000002>
profileFamilyName = "Jones"
profileGivenName = "Bob"
profileKey = <0410410410410410410410410410410410410410410410410410410410410410>
registered = Registered {}
visibility = Visibility.VISIBLE
}
id = 5
}
}

Frame {
recipient = Recipient {
contact = Contact {
aci = <0000ca01000040008000000000000001>
e164 = 16105550103
pni = <0000ca01000040008000000000000002>
profileFamilyName = "Johnson"
profileGivenName = "Carol"
profileKey = <0820820820820820820820820820820820820820820820820820820820820820>
registered = Registered {}
visibility = Visibility.VISIBLE
}
id = 6
}
}

Frame {
recipient = Recipient {
contact = Contact {
aci = <000000da000040008000000000000001>
e164 = 16105550104
pni = <000000da000040008000000000000002>
profileFamilyName = "Brown"
profileGivenName = "Dan"
profileKey = <0c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30c30>
registered = Registered {}
visibility = Visibility.VISIBLE
}
id = 7
}
}

Frame {
recipient = Recipient {
group = Group {
masterKey = <0000000000000000000000000000000000000000000000000000000000000000>
snapshot = GroupSnapshot {
accessControl = AccessControl {
addFromInviteLink = AccessRequired.UNSATISFIABLE
attributes = AccessRequired.MEMBER
members = AccessRequired.MEMBER
}
avatarUrl = "https://example.com/avatar.jpg"
inviteLinkPassword = <>
members = [
Member {
role = Role.ADMINISTRATOR
userId = <00000000000040008000000000000001>
},
Member {
role = Role.DEFAULT
userId = <000a11ce000040008000000000000001>
},
Member {
role = Role.DEFAULT
userId = <00000b0b000040008000000000000001>
}
]
title = GroupAttributeBlob {
title = "Me, Alice, Bob"
}
version = 1
}
storySendMode = StorySendMode.DEFAULT
whitelisted = true
}
id = 10
}
}

Frame {
chat = Chat {
expireTimerVersion = 1
id = 3
recipientId = 10
}
}

Frame {
chatItem = ChatItem {
authorId = 1
chatId = 3
dateSent = 1878937499399
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
groupChange = GroupChangeChatUpdate {
updates = [
Update {
genericGroupUpdate = GenericGroupUpdate {
updaterAci = <000a11ce000040008000000000000001>
}
}
]
}
}
}
}
Binary file not shown.
Loading

0 comments on commit 8e12c23

Please sign in to comment.