(t *testing.T)
| 1679 | } |
| 1680 | |
| 1681 | func TestRegisterSessionLowAuthLevelWithSysTopic(t *testing.T) { |
| 1682 | topicName := "sys" |
| 1683 | // No one is subscribed to sys. |
| 1684 | numUsers := 0 |
| 1685 | helper := TopicTestHelper{} |
| 1686 | helper.setUp(t, numUsers, types.TopicCatSys, topicName, false) |
| 1687 | defer helper.tearDown() |
| 1688 | if len(helper.topic.sessions) != 0 { |
| 1689 | helper.finish() |
| 1690 | t.Fatalf("Initially attached sessions: expected 0 vs found %d", len(helper.topic.sessions)) |
| 1691 | } |
| 1692 | |
| 1693 | // New uid. This should attempt to add a new subscription |
| 1694 | // which produces an error b/c authLevel isn't root. |
| 1695 | uid := types.Uid(10001) |
| 1696 | s, r := helper.newSession("test-sid", uid) |
| 1697 | helper.sessions = append(helper.sessions, s) |
| 1698 | helper.results = append(helper.results, r) |
| 1699 | |
| 1700 | join := &ClientComMessage{ |
| 1701 | Original: topicName, |
| 1702 | Sub: &MsgClientSub{ |
| 1703 | Id: "id456", |
| 1704 | Topic: topicName, |
| 1705 | }, |
| 1706 | AsUser: uid.UserId(), |
| 1707 | sess: s, |
| 1708 | } |
| 1709 | |
| 1710 | helper.topic.registerSession(join) |
| 1711 | helper.finish() |
| 1712 | |
| 1713 | // Check for errors from testHubLoop |
| 1714 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 1715 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 1716 | } |
| 1717 | |
| 1718 | if len(s.subs) != 0 { |
| 1719 | t.Errorf("Session subscriptions: expected 0, found %d", len(s.subs)) |
| 1720 | } |
| 1721 | online := helper.topic.perUser[uid].online |
| 1722 | if online != 0 { |
| 1723 | t.Errorf("Number of online sessions: expected 0, found %d", online) |
| 1724 | } |
| 1725 | // Session output. |
| 1726 | registerSessionVerifyOutputs(t, r, []int{http.StatusForbidden}) |
| 1727 | // Presence notifications. |
| 1728 | if len(helper.hubMessages) != 0 { |
| 1729 | t.Errorf("Hub isn't expected to receive any messages, received %d", len(helper.hubMessages)) |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | func TestRegisterSessionNewChannelGetSubDbError(t *testing.T) { |
| 1734 | topicName := "grpTest" |
nothing calls this directly
no test coverage detected
searching dependent graphs…