(t *testing.T)
| 1894 | } |
| 1895 | |
| 1896 | func TestRegisterSessionOwnerBansHimself(t *testing.T) { |
| 1897 | topicName := "grpTest" |
| 1898 | numUsers := 1 |
| 1899 | helper := TopicTestHelper{} |
| 1900 | helper.setUp(t, numUsers, types.TopicCatGrp, topicName, false) |
| 1901 | defer helper.tearDown() |
| 1902 | if len(helper.topic.sessions) != 0 { |
| 1903 | helper.finish() |
| 1904 | t.Fatalf("Initially attached sessions: expected 0 vs found %d", len(helper.topic.sessions)) |
| 1905 | } |
| 1906 | |
| 1907 | s := helper.sessions[0] |
| 1908 | uid := helper.uids[0] |
| 1909 | r := helper.results[0] |
| 1910 | |
| 1911 | // User is the topic owner. |
| 1912 | helper.topic.owner = uid |
| 1913 | pud := helper.topic.perUser[uid] |
| 1914 | pud.modeGiven |= types.ModeOwner |
| 1915 | helper.topic.perUser[uid] = pud |
| 1916 | |
| 1917 | join := &ClientComMessage{ |
| 1918 | Original: topicName, |
| 1919 | Sub: &MsgClientSub{ |
| 1920 | Id: "id456", |
| 1921 | Topic: topicName, |
| 1922 | Set: &MsgSetQuery{ |
| 1923 | Sub: &MsgSetSub{ |
| 1924 | // No O permission. |
| 1925 | Mode: "JPRW", |
| 1926 | }, |
| 1927 | }, |
| 1928 | }, |
| 1929 | AsUser: uid.UserId(), |
| 1930 | AuthLvl: int(auth.LevelAuth), |
| 1931 | sess: s, |
| 1932 | } |
| 1933 | |
| 1934 | helper.topic.registerSession(join) |
| 1935 | helper.finish() |
| 1936 | |
| 1937 | // Check for errors from testHubLoop |
| 1938 | if errorMsgs, hasError := helper.hubMessages["__ERROR__"]; hasError { |
| 1939 | t.Fatal(errorMsgs[0].Ctrl.Text) |
| 1940 | } |
| 1941 | |
| 1942 | if len(s.subs) != 0 { |
| 1943 | t.Errorf("Session subscriptions: expected 0, found %d", len(s.subs)) |
| 1944 | } |
| 1945 | online := helper.topic.perUser[uid].online |
| 1946 | if online != 0 { |
| 1947 | t.Errorf("Number of online sessions: expected 0, found %d", online) |
| 1948 | } |
| 1949 | // Session output. |
| 1950 | registerSessionVerifyOutputs(t, r, []int{http.StatusForbidden}) |
| 1951 | // Presence notifications. |
| 1952 | if len(helper.hubMessages) != 0 { |
| 1953 | t.Errorf("Hub isn't expected to receive any messages, received %d", len(helper.hubMessages)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…