(t *testing.T)
| 1623 | } |
| 1624 | |
| 1625 | func TestRegisterSessionMaxSubscriberCountExceeded(t *testing.T) { |
| 1626 | topicName := "grpTest" |
| 1627 | // Pretend we already exceeded the maximum user count. This should produce an error. |
| 1628 | numUsers := 10 |
| 1629 | oldMaxSubscribers := globals.maxSubscriberCount |
| 1630 | globals.maxSubscriberCount = 10 |
| 1631 | helper := TopicTestHelper{} |
| 1632 | helper.setUp(t, numUsers, types.TopicCatGrp, topicName, false) |
| 1633 | defer func() { |
| 1634 | helper.tearDown() |
| 1635 | globals.maxSubscriberCount = oldMaxSubscribers |
| 1636 | }() |
| 1637 | if len(helper.topic.sessions) != 0 { |
| 1638 | helper.finish() |
| 1639 | t.Fatalf("Initially attached sessions: expected 0 vs found %d", len(helper.topic.sessions)) |
| 1640 | } |
| 1641 | |
| 1642 | // New uid. This should attempt to add a new subscription. |
| 1643 | uid := types.Uid(10001) |
| 1644 | s, r := helper.newSession("test-sid", uid) |
| 1645 | helper.sessions = append(helper.sessions, s) |
| 1646 | helper.results = append(helper.results, r) |
| 1647 | |
| 1648 | join := &ClientComMessage{ |
| 1649 | Original: topicName, |
| 1650 | Sub: &MsgClientSub{ |
| 1651 | Id: "id456", |
| 1652 | Topic: topicName, |
| 1653 | }, |
| 1654 | AsUser: uid.UserId(), |
| 1655 | sess: s, |
| 1656 | } |
| 1657 | |
| 1658 | helper.topic.registerSession(join) |
| 1659 | helper.finish() |
| 1660 | |
| 1661 | // Check for errors from testHubLoop |
| 1662 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 1663 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 1664 | } |
| 1665 | |
| 1666 | if len(s.subs) != 0 { |
| 1667 | t.Errorf("Session subscriptions: expected 0, found %d", len(s.subs)) |
| 1668 | } |
| 1669 | online := helper.topic.perUser[uid].online |
| 1670 | if online != 0 { |
| 1671 | t.Errorf("Number of online sessions: expected 0, found %d", online) |
| 1672 | } |
| 1673 | // Session output. |
| 1674 | registerSessionVerifyOutputs(t, r, []int{http.StatusUnprocessableEntity}) |
| 1675 | // Presence notifications. |
| 1676 | if len(helper.hubMessages) != 0 { |
| 1677 | t.Errorf("Hub isn't expected to receive any messages, received %d", len(helper.hubMessages)) |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | func TestRegisterSessionLowAuthLevelWithSysTopic(t *testing.T) { |
| 1682 | topicName := "sys" |
nothing calls this directly
no test coverage detected
searching dependent graphs…