(t *testing.T)
| 2976 | } |
| 2977 | |
| 2978 | func TestRegisterSessionWithComplexModeString(t *testing.T) { |
| 2979 | topicName := "grpTest" |
| 2980 | numUsers := 2 |
| 2981 | helper := TopicTestHelper{} |
| 2982 | helper.setUp(t, numUsers, types.TopicCatGrp, topicName, false) |
| 2983 | defer helper.tearDown() |
| 2984 | |
| 2985 | uid := helper.uids[1] |
| 2986 | s := helper.sessions[1] |
| 2987 | r := helper.results[1] |
| 2988 | |
| 2989 | // User with existing subscription wants to change mode |
| 2990 | pud := helper.topic.perUser[uid] |
| 2991 | pud.modeWant = types.ModeCPublic |
| 2992 | pud.modeGiven = types.ModeCPublic |
| 2993 | helper.topic.perUser[uid] = pud |
| 2994 | |
| 2995 | join := &ClientComMessage{ |
| 2996 | Original: topicName, |
| 2997 | Sub: &MsgClientSub{ |
| 2998 | Id: "id456", |
| 2999 | Topic: topicName, |
| 3000 | Set: &MsgSetQuery{ |
| 3001 | Sub: &MsgSetSub{ |
| 3002 | Mode: "JRWPAS", // Complex mode string with multiple permissions |
| 3003 | }, |
| 3004 | }, |
| 3005 | }, |
| 3006 | AsUser: uid.UserId(), |
| 3007 | AuthLvl: int(auth.LevelAuth), |
| 3008 | sess: s, |
| 3009 | } |
| 3010 | |
| 3011 | helper.ss.EXPECT().Update(topicName, uid, gomock.Any()).Return(nil) |
| 3012 | |
| 3013 | helper.topic.registerSession(join) |
| 3014 | helper.finish() |
| 3015 | |
| 3016 | // Check for errors from testHubLoop |
| 3017 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 3018 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 3019 | } |
| 3020 | |
| 3021 | if len(helper.topic.sessions) != 1 { |
| 3022 | t.Fatalf("Attached sessions: expected 1, found %d", len(helper.topic.sessions)) |
| 3023 | } |
| 3024 | if len(s.subs) != 1 { |
| 3025 | t.Fatalf("Session subscriptions: expected 1, found %d", len(s.subs)) |
| 3026 | } |
| 3027 | online := helper.topic.perUser[uid].online |
| 3028 | if online != 1 { |
| 3029 | t.Fatalf("Number of online sessions: expected 1, found %d", online) |
| 3030 | } |
| 3031 | registerSessionVerifyOutputs(t, r, []int{http.StatusOK}) |
| 3032 | } |
| 3033 | |
| 3034 | func TestHandleBroadcastDataGroupWithMutedUser(t *testing.T) { |
| 3035 | topicName := "grp-test" |
nothing calls this directly
no test coverage detected
searching dependent graphs…