feat: complete IM P0 and P1 reliability work
This commit is contained in:
+35
-1
@@ -334,6 +334,40 @@ func TestHandleBroadcastDataP2PRequiresRelationship(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleBroadcastDataGroupRejectsMutedMember(t *testing.T) {
|
||||
helper := TopicTestHelper{}
|
||||
helper.setUp(t, 2, types.TopicCatGrp, "grp-test", true)
|
||||
defer helper.tearDown()
|
||||
|
||||
oldStore := store.Store
|
||||
oldGroupBusiness := store.GroupBusiness
|
||||
mockStore := mock_store.NewMockPersistentStorageInterface(helper.ctrl)
|
||||
mockStore.EXPECT().IsOpen().Return(true)
|
||||
store.Store = mockStore
|
||||
store.GroupBusiness = &testGroupBusinessStore{settings: &types.GroupSettings{Topic: "grp-test", MuteAll: true}}
|
||||
memberState := helper.topic.perUser[helper.uids[1]]
|
||||
memberState.modeWant = types.ModeCPublic
|
||||
memberState.modeGiven = types.ModeCPublic
|
||||
helper.topic.perUser[helper.uids[1]] = memberState
|
||||
defer func() {
|
||||
store.Store = oldStore
|
||||
store.GroupBusiness = oldGroupBusiness
|
||||
}()
|
||||
|
||||
msg := &ClientComMessage{
|
||||
Id: "muted-1", AsUser: helper.uids[1].UserId(), Original: "grp-test",
|
||||
Pub: &MsgClientPub{Topic: "grp-test", Content: "blocked"},
|
||||
sess: helper.sessions[1],
|
||||
}
|
||||
helper.topic.handleClientMsg(msg)
|
||||
helper.finish()
|
||||
|
||||
verifyResponseCodes(helper.results[1], []int{http.StatusForbidden}, t)
|
||||
if helper.topic.lastID != 0 {
|
||||
t.Fatalf("muted publish changed topic sequence: %d", helper.topic.lastID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleBroadcastCall(t *testing.T) {
|
||||
numUsers := 2
|
||||
helper := TopicTestHelper{}
|
||||
@@ -766,7 +800,7 @@ func TestHandleBroadcastDataRejectsUserSystemType(t *testing.T) {
|
||||
AsUser: from,
|
||||
Pub: &MsgClientPub{
|
||||
Topic: "p2p",
|
||||
Head: map[string]any{"type": "system"},
|
||||
Head: map[string]any{"x-im-schema": float64(1), "x-im-type": "system_event"},
|
||||
Content: "test",
|
||||
},
|
||||
sess: helper.sessions[0],
|
||||
|
||||
Reference in New Issue
Block a user