Skip to content

Commit c0c6b14

Browse files
Add test cases for Group.blocked
1 parent 8282d78 commit c0c6b14

10 files changed

+56
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ application {
1919
}
2020

2121
dependencies {
22-
implementation("org.signal:libsignal-client:0.65.2")
22+
implementation("org.signal:libsignal-client:0.65.4")
2323
implementation("com.thedeanda:lorem:2.2")
2424
implementation(kotlin("reflect"))
2525
}

src/main/kotlin/tests/RecipientGroupsTestCase.kt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,23 @@ object RecipientGroupsTestCase : TestCase("recipient_groups") {
8686
)
8787
}
8888

89+
// If blocked, can't be whitelisted.
90+
val (isBlocked, isWhitelisted) = some(Generators.list<Pair<Boolean, Boolean>>(
91+
Pair(true, false),
92+
Pair(false, true),
93+
Pair(false, false)
94+
))
95+
8996
frames += Frame(
9097
recipient = Recipient(
9198
id = groupRecipientId,
9299
group = Group(
93100
masterKey = someBytes(32).toByteString(),
94-
whitelisted = someBoolean(),
101+
whitelisted = if (isBlocked) false else isWhitelisted,
95102
hideStory = someBoolean(),
96103
storySendMode = someEnum(Group.StorySendMode::class.java),
97-
snapshot = snapshot
104+
snapshot = snapshot,
105+
blocked = isBlocked
98106
)
99107
)
100108
)
@@ -109,5 +117,19 @@ object RecipientGroupsTestCase : TestCase("recipient_groups") {
109117
expireTimerVersion = 1
110118
)
111119
)
120+
121+
if (isBlocked) {
122+
frames += Frame(
123+
chatItem = ChatItem(
124+
chatId = 1,
125+
authorId = StandardFrames.recipientSelf.recipient!!.id,
126+
dateSent = someNonZeroTimestamp(),
127+
directionless = ChatItem.DirectionlessMessageDetails(),
128+
updateMessage = ChatUpdateMessage(
129+
simpleUpdate = SimpleChatUpdate(type = SimpleChatUpdate.Type.BLOCKED)
130+
)
131+
)
132+
)
133+
}
112134
}
113135
}
22 Bytes
Binary file not shown.

test-cases/recipient_groups_00.txtproto

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Frame {
208208
Frame {
209209
recipient = Recipient {
210210
group = Group {
211+
blocked = true
211212
hideStory = true
212213
masterKey = <228e188ff7647a4b753e5d1b1bcfadd2b72893989279e8c805d886b98779cc84>
213214
snapshot = GroupSnapshot {
@@ -235,7 +236,6 @@ Frame {
235236
version = 957662124
236237
}
237238
storySendMode = StorySendMode.DEFAULT
238-
whitelisted = true
239239
}
240240
id = 10
241241
}
@@ -247,4 +247,18 @@ Frame {
247247
id = 1
248248
recipientId = 10
249249
}
250+
}
251+
252+
Frame {
253+
chatItem = ChatItem {
254+
authorId = 1
255+
chatId = 1
256+
dateSent = 1675251188008
257+
directionless = DirectionlessMessageDetails {}
258+
updateMessage = ChatUpdateMessage {
259+
simpleUpdate = SimpleChatUpdate {
260+
type = Type.BLOCKED
261+
}
262+
}
263+
}
250264
}
2 Bytes
Binary file not shown.

test-cases/recipient_groups_01.txtproto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Frame {
263263
version = 1394492158
264264
}
265265
storySendMode = StorySendMode.DISABLED
266+
whitelisted = true
266267
}
267268
id = 10
268269
}
-2 Bytes
Binary file not shown.

test-cases/recipient_groups_02.txtproto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ Frame {
249249
version = 328224940
250250
}
251251
storySendMode = StorySendMode.ENABLED
252-
whitelisted = true
253252
}
254253
id = 10
255254
}
24 Bytes
Binary file not shown.

test-cases/recipient_groups_03.txtproto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Frame {
208208
Frame {
209209
recipient = Recipient {
210210
group = Group {
211+
blocked = true
211212
masterKey = <228e188ff7647a4b753e5d1b1bcfadd2b72893989279e8c805d886b98779cc84>
212213
snapshot = GroupSnapshot {
213214
accessControl = AccessControl {
@@ -271,4 +272,18 @@ Frame {
271272
id = 1
272273
recipientId = 10
273274
}
275+
}
276+
277+
Frame {
278+
chatItem = ChatItem {
279+
authorId = 1
280+
chatId = 1
281+
dateSent = 1722382677508
282+
directionless = DirectionlessMessageDetails {}
283+
updateMessage = ChatUpdateMessage {
284+
simpleUpdate = SimpleChatUpdate {
285+
type = Type.BLOCKED
286+
}
287+
}
288+
}
274289
}

0 commit comments

Comments
 (0)