def testGroupMessage(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() add = wFD(self.realm.createGroup(u"somechannel")) yield add somechannel = add.getResult() user.write("JOIN #somechannel\r\n") other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.write("JOIN #somechannel\r\n") user.transport.clear() other.transport.clear() user.write('PRIVMSG #somechannel :Hello, world.\r\n') response = self._response(user) event = self._response(other) self.failIf(response) self.assertEqual(len(event), 1) self.assertEqual(event[0][0], 'useruser!useruser@realmname') self.assertEqual(event[0][1], 'PRIVMSG', -1) self.assertEqual(event[0][2], ['#somechannel', 'Hello, world.'])
def testPrivateMessage(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() user.transport.clear() other.transport.clear() user.write('PRIVMSG otheruser :Hello, monkey.\r\n') response = self._response(user) event = self._response(other) self.failIf(response) self.assertEqual(len(event), 1) self.assertEqual(event[0][0], 'useruser!useruser@realmname') self.assertEqual(event[0][1], 'PRIVMSG') self.assertEqual(event[0][2], ['otheruser', 'Hello, monkey.']) user.write('PRIVMSG nousernamedthis :Hello, monkey.\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][0], 'realmname') self.assertEqual(response[0][1], '401') self.assertEqual(response[0][2], ['useruser', 'nousernamedthis', 'No such nick/channel.'])
def testWhois(self): user = wFD(self._loggedInUser(u'someguy')) yield user user = user.getResult() otherguy = service.User("otherguy") otherguy.itergroups = lambda: iter([ service.Group('groupA'), service.Group('groupB')]) otherguy.signOn = 10 otherguy.lastMessage = time.time() - 15 add = wFD(self.realm.addUser(otherguy)) yield add add.getResult() user.transport.clear() user.write('WHOIS otherguy\r\n') r = self._response(user) self.assertEqual(len(r), 5) wuser, wserver, idle, channels, end = r self.assertEqual(wuser[0], 'realmname') self.assertEqual(wuser[1], '311') self.assertEqual(wuser[2][0], 'someguy') self.assertEqual(wuser[2][1], 'otherguy') self.assertEqual(wuser[2][2], 'otherguy') self.assertEqual(wuser[2][3], 'realmname') self.assertEqual(wuser[2][4], '*') self.assertEqual(wuser[2][5], 'otherguy') self.assertEqual(wserver[0], 'realmname') self.assertEqual(wserver[1], '312') self.assertEqual(wserver[2][0], 'someguy') self.assertEqual(wserver[2][1], 'otherguy') self.assertEqual(wserver[2][2], 'realmname') self.assertEqual(wserver[2][3], 'Hi mom!') self.assertEqual(idle[0], 'realmname') self.assertEqual(idle[1], '317') self.assertEqual(idle[2][0], 'someguy') self.assertEqual(idle[2][1], 'otherguy') self.assertEqual(idle[2][2], '15') self.assertEqual(idle[2][3], '10') self.assertEqual(idle[2][4], "seconds idle, signon time") self.assertEqual(channels[0], 'realmname') self.assertEqual(channels[1], '319') self.assertEqual(channels[2][0], 'someguy') self.assertEqual(channels[2][1], 'otherguy') self.assertEqual(channels[2][2], '#groupA #groupB') self.assertEqual(end[0], 'realmname') self.assertEqual(end[1], '318') self.assertEqual(end[2][0], 'someguy') self.assertEqual(end[2][1], 'otherguy') self.assertEqual(end[2][2], 'End of WHOIS list.')
def testJoin(self): firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() somechannel = wFD(self.realm.createGroup(u"somechannel")) yield somechannel somechannel = somechannel.getResult() somechannel.meta['topic'] = 'some random topic' # Bring in one user, make sure he gets into the channel sanely user = TestCaseUserAgg(firstuser, self.realm, self.factory) self._login(user, "firstuser") user.transport.clear() user.write('JOIN #somechannel\r\n') response = self._response(user) self.assertEqual(len(response), 5) # Join message self.assertEqual(response[0][0], 'firstuser!firstuser@realmname') self.assertEqual(response[0][1], 'JOIN') self.assertEqual(response[0][2], ['#somechannel']) # User list self.assertEqual(response[1][1], '353') self.assertEqual(response[2][1], '366') # Topic (or lack thereof, as the case may be) self.assertEqual(response[3][1], '332') self.assertEqual(response[4][1], '333') # Hook up another client! It is a CHAT SYSTEM!!!!!!! other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.transport.clear() user.transport.clear() other.write('JOIN #somechannel\r\n') # At this point, both users should be in the channel response = self._response(other) event = self._response(user) self.assertEqual(len(event), 1) self.assertEqual(event[0][0], 'otheruser!otheruser@realmname') self.assertEqual(event[0][1], 'JOIN') self.assertEqual(event[0][2], ['#somechannel']) self.assertEqual(response[1][0], 'realmname') self.assertEqual(response[1][1], '353') self.assertEqual(response[1][2], ['otheruser', '=', '#somechannel', 'firstuser otheruser'])
def testGroupAddition(self): realm = service.InMemoryWordsRealm("realmname") p = service.Group("testgroup") d = wFD(realm.addGroup(p)) yield d d.getResult() d = wFD(realm.getGroup(u"testGroup")) yield d group = d.getResult() self.assertIdentical(p, group)
def testGroupUsernameCollision(self): """ Try creating a group with the same name as an existing user and assert that it succeeds, since users and groups should not be in the same namespace and collisions should be impossible. """ realm = service.InMemoryWordsRealm("realmname") d = wFD(realm.createUser(u"test")) yield d user = d.getResult() d = wFD(realm.createGroup(u"test")) yield d group = d.getResult()
def testLeave(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() somechannel = wFD(self.realm.createGroup(u"somechannel")) yield somechannel somechannel = somechannel.getResult() user.write('JOIN #somechannel\r\n') user.transport.clear() other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.write('JOIN #somechannel\r\n') user.transport.clear() other.transport.clear() user.write('PART #somechannel\r\n') response = self._response(user) event = self._response(other) self.assertEquals(len(response), 1) self.assertEquals(response[0][0], 'useruser!useruser@realmname') self.assertEquals(response[0][1], 'PART') self.assertEquals(response[0][2], ['#somechannel', 'leaving']) self.assertEquals(response, event) # Now again, with a part message user.write('JOIN #somechannel\r\n') user.transport.clear() other.transport.clear() user.write('PART #somechannel :goodbye stupidheads\r\n') response = self._response(user) event = self._response(other) self.assertEquals(len(response), 1) self.assertEquals(response[0][0], 'useruser!useruser@realmname') self.assertEquals(response[0][1], 'PART') self.assertEquals(response[0][2], ['#somechannel', 'goodbye stupidheads']) self.assertEquals(response, event)
def testLeave(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() somechannel = wFD(self.realm.createGroup(u"somechannel")) yield somechannel somechannel = somechannel.getResult() user.write('JOIN #somechannel\r\n') user.transport.clear() other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.write('JOIN #somechannel\r\n') user.transport.clear() other.transport.clear() user.write('PART #somechannel\r\n') response = self._response(user) event = self._response(other) self.assertEqual(len(response), 1) self.assertEqual(response[0][0], 'useruser!useruser@realmname') self.assertEqual(response[0][1], 'PART') self.assertEqual(response[0][2], ['#somechannel', 'leaving']) self.assertEqual(response, event) # Now again, with a part message user.write('JOIN #somechannel\r\n') user.transport.clear() other.transport.clear() user.write('PART #somechannel :goodbye stupidheads\r\n') response = self._response(user) event = self._response(other) self.assertEqual(len(response), 1) self.assertEqual(response[0][0], 'useruser!useruser@realmname') self.assertEqual(response[0][1], 'PART') self.assertEqual(response[0][2], ['#somechannel', 'goodbye stupidheads']) self.assertEqual(response, event)
def _loggedInUser(self, name): d = wFD(self.realm.lookupUser(name)) yield d user = d.getResult() agg = TestCaseUserAgg(user, self.realm, self.factory) self._login(agg, name) yield agg
def testGroupRetrieval(self): realm = service.InMemoryWordsRealm("realmname") d = wFD(realm.createGroup(u"testgroup")) yield d group = d.getResult() d = wFD(realm.getGroup(u"testgroup")) yield d retrieved = d.getResult() self.assertIdentical(group, retrieved) d = wFD(realm.getGroup(u"nosuchgroup")) yield d self.assertRaises(ewords.NoSuchGroup, d.getResult)
def testNegative(self): for chk in self.getCheckers(): for cred in self.getBadCredentials(): r = wFD(chk.requestAvatarId(cred)) yield r self.assertRaises(error.UnauthorizedLogin, r.getResult) yield None
def testSetTopic(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() add = wFD(self.realm.createGroup(u"somechannel")) yield add somechannel = add.getResult() user.write("JOIN #somechannel\r\n") other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.write("JOIN #somechannel\r\n") user.transport.clear() other.transport.clear() other.write('TOPIC #somechannel :This is the new topic.\r\n') response = self._response(other) event = self._response(user) self.assertEquals(response, event) self.assertEquals(response[0][0], 'otheruser!otheruser@realmname') self.assertEquals(response[0][1], 'TOPIC') self.assertEquals(response[0][2], ['#somechannel', 'This is the new topic.']) other.transport.clear() somechannel.meta['topic_date'] = 12345 other.write('TOPIC #somechannel\r\n') response = self._response(other) self.assertEquals(response[0][1], '332') self.assertEquals(response[0][2], ['otheruser', '#somechannel', 'This is the new topic.']) self.assertEquals(response[1][1], '333') self.assertEquals(response[1][2], ['otheruser', '#somechannel', 'otheruser', '12345']) other.transport.clear() other.write('TOPIC #asdlkjasd\r\n') response = self._response(other) self.assertEquals(response[0][1], '403')
def testSetTopic(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() add = wFD(self.realm.createGroup(u"somechannel")) yield add somechannel = add.getResult() user.write("JOIN #somechannel\r\n") other = wFD(self._loggedInUser(u'otheruser')) yield other other = other.getResult() other.write("JOIN #somechannel\r\n") user.transport.clear() other.transport.clear() other.write('TOPIC #somechannel :This is the new topic.\r\n') response = self._response(other) event = self._response(user) self.assertEqual(response, event) self.assertEqual(response[0][0], 'otheruser!otheruser@realmname') self.assertEqual(response[0][1], 'TOPIC') self.assertEqual(response[0][2], ['#somechannel', 'This is the new topic.']) other.transport.clear() somechannel.meta['topic_date'] = 12345 other.write('TOPIC #somechannel\r\n') response = self._response(other) self.assertEqual(response[0][1], '332') self.assertEqual(response[0][2], ['otheruser', '#somechannel', 'This is the new topic.']) self.assertEqual(response[1][1], '333') self.assertEqual(response[1][2], ['otheruser', '#somechannel', 'otheruser', '12345']) other.transport.clear() other.write('TOPIC #asdlkjasd\r\n') response = self._response(other) self.assertEqual(response[0][1], '403')
def testList(self): user = wFD(self._loggedInUser(u"someuser")) yield user user = user.getResult() user.transport.clear() somegroup = wFD(self.realm.createGroup(u"somegroup")) yield somegroup somegroup = somegroup.getResult() somegroup.size = lambda: succeed(17) somegroup.meta['topic'] = 'this is the topic woo' # Test one group user.write('LIST #somegroup\r\n') r = self._response(user) self.assertEqual(len(r), 2) resp, end = r self.assertEqual(resp[0], 'realmname') self.assertEqual(resp[1], '322') self.assertEqual(resp[2][0], 'someuser') self.assertEqual(resp[2][1], 'somegroup') self.assertEqual(resp[2][2], '17') self.assertEqual(resp[2][3], 'this is the topic woo') self.assertEqual(end[0], 'realmname') self.assertEqual(end[1], '323') self.assertEqual(end[2][0], 'someuser') self.assertEqual(end[2][1], 'End of /LIST') user.transport.clear() # Test all groups user.write('LIST\r\n') r = self._response(user) self.assertEqual(len(r), 2) fg1, end = r self.assertEqual(fg1[1], '322') self.assertEqual(fg1[2][1], 'somegroup') self.assertEqual(fg1[2][2], '17') self.assertEqual(fg1[2][3], 'this is the topic woo') self.assertEqual(end[1], '323')
def testNegative(self): for chk in self.getCheckers(): for cred in self.getBadCredentials(): r = wFD(chk.requestAvatarId(cred)) yield r self.assertRaises(error.UnauthorizedLogin, r.getResult) # Work around deferredGenerator bug yield None
def testWho(self): group = service.Group('groupname') add = wFD(self.realm.addGroup(group)) yield add add.getResult() users = [] for nick in u'userone', u'usertwo', u'userthree': u = wFD(self._loggedInUser(nick)) yield u u = u.getResult() users.append(u) users[-1].write('JOIN #groupname\r\n') for user in users: user.transport.clear() users[0].write('WHO #groupname\r\n') r = self._response(users[0]) self.failIf(self._response(users[1])) self.failIf(self._response(users[2])) wantusers = ['userone', 'usertwo', 'userthree'] for (prefix, code, stuff) in r[:-1]: self.assertEqual(prefix, 'realmname') self.assertEqual(code, '352') (myname, group, theirname, theirhost, theirserver, theirnick, flag, extra) = stuff self.assertEqual(myname, 'userone') self.assertEqual(group, '#groupname') self.failUnless(theirname in wantusers) self.assertEqual(theirhost, 'realmname') self.assertEqual(theirserver, 'realmname') wantusers.remove(theirnick) self.assertEqual(flag, 'H') self.assertEqual(extra, '0 ' + theirnick) self.failIf(wantusers) prefix, code, stuff = r[-1] self.assertEqual(prefix, 'realmname') self.assertEqual(code, '315') myname, channel, extra = stuff self.assertEqual(myname, 'userone') self.assertEqual(channel, '#groupname') self.assertEqual(extra, 'End of /WHO list.')
def testEnumeration(self): realm = service.InMemoryWordsRealm("realmname") d = wFD(realm.createGroup(u"groupone")) yield d d.getResult() d = wFD(realm.createGroup(u"grouptwo")) yield d d.getResult() groups = wFD(realm.itergroups()) yield groups groups = groups.getResult() n = [g.name for g in groups] n.sort() self.assertEqual(n, ["groupone", "grouptwo"])
def testGetGroupMode(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() add = wFD(self.realm.createGroup(u"somechannel")) yield add somechannel = add.getResult() user.write('JOIN #somechannel\r\n') user.transport.clear() user.write('MODE #somechannel\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][1], '324')
def testSetGroupMode(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() group = wFD(self.realm.createGroup(u"groupname")) yield group group = group.getResult() user.write('JOIN #groupname\r\n') user.transport.clear() user.write('MODE #groupname +abcd\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][1], '472')
def testGroups(self): mindone = TestMind() one = wFD(self._loggedInAvatar(u"one", "p1", mindone)) yield one one = one.getResult() mindtwo = TestMind() two = wFD(self._loggedInAvatar(u"two", "p2", mindtwo)) yield two two = two.getResult() add = wFD(self.realm.createGroup(u"foobar")) yield add add.getResult() groupone = wFD(one.join(u"foobar")) yield groupone groupone = groupone.getResult() grouptwo = wFD(two.join(u"foobar")) yield grouptwo grouptwo = grouptwo.getResult() msg = wFD(groupone.send({"text": "hello, monkeys"})) yield msg msg = msg.getResult() leave = wFD(groupone.leave()) yield leave leave = leave.getResult()
def testGetTopic(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() group = service.Group("somechannel") group.meta["topic"] = "This is a test topic." group.meta["topic_author"] = "some_fellow" group.meta["topic_date"] = 77777777 add = wFD(self.realm.addGroup(group)) yield add add.getResult() user.transport.clear() user.write("JOIN #somechannel\r\n") response = self._response(user) self.assertEquals(response[3][0], 'realmname') self.assertEquals(response[3][1], '332') # XXX Sigh. irc.parsemsg() is not as correct as one might hope. self.assertEquals( response[3][2], ['useruser', '#somechannel', 'This is a test topic.']) self.assertEquals(response[4][1], '333') self.assertEquals( response[4][2], ['useruser', '#somechannel', 'some_fellow', '77777777']) user.transport.clear() user.write('TOPIC #somechannel\r\n') response = self._response(user) self.assertEquals(response[0][1], '332') self.assertEquals( response[0][2], ['useruser', '#somechannel', 'This is a test topic.']) self.assertEquals(response[1][1], '333') self.assertEquals( response[1][2], ['useruser', '#somechannel', 'some_fellow', '77777777'])
def testFailedLogin(self): firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() user = TestCaseUserAgg(firstuser, self.realm, self.factory) self._login(user, "firstuser", "wrongpass") response = self._response(user, "PRIVMSG") self.assertEqual(len(response), 1) self.assertEqual(response[0][2], ['firstuser', 'Login failed. Goodbye.'])
def testFailedLogin(self): firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() user = TestCaseUserAgg(firstuser, self.realm, self.factory) self._login(user, "firstuser", "wrongpass") response = self._response(user, "PRIVMSG") self.assertEquals(len(response), 1) self.assertEquals(response[0][2], ['firstuser', 'Login failed. Goodbye.'])
def testLogout(self): logout = [] firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() user = TestCaseUserAgg(firstuser, self.realm, self.factory) self._login(user, "firstuser") user.protocol.logout = lambda: logout.append(True) user.write('QUIT\r\n') self.assertEqual(logout, [True])
def testOper(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() user.transport.clear() user.write('OPER user pass\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][1], '491')
def testSetUserMode(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() user.transport.clear() user.write('MODE useruser +abcd\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][1], '472')
def testUserAddition(self): realm = service.InMemoryWordsRealm("realmname") # Create and manually add a user to the realm p = service.User("testuser") d = wFD(realm.addUser(p)) yield d user = d.getResult() self.assertIdentical(p, user) # Make sure getting that user returns the same object d = wFD(realm.getUser(u"testuser")) yield d retrieved = d.getResult() self.assertIdentical(user, retrieved) # Make sure looking up that user returns the same object d = wFD(realm.lookupUser(u"testuser")) yield d lookedUp = d.getResult() self.assertIdentical(retrieved, lookedUp)
def _entityCreationTest(self, kind): # Kind is "user" or "group" realm = service.InMemoryWordsRealm("realmname") name = u'test' + kind.lower() create = getattr(realm, 'create' + kind.title()) get = getattr(realm, 'get' + kind.title()) flag = 'create' + kind.title() + 'OnRequest' dupExc = getattr(ewords, 'Duplicate' + kind.title()) noSuchExc = getattr(ewords, 'NoSuch' + kind.title()) # Creating should succeed d = wFD(create(name)) yield d p = d.getResult() self.assertEqual(p.name, name) # Creating the same user again should not d = wFD(create(name)) yield d self.assertRaises(dupExc, d.getResult) # Getting a non-existent user should succeed if createUserOnRequest is True setattr(realm, flag, True) d = wFD(get(u"new" + kind.lower())) yield d p = d.getResult() self.assertEqual(p.name, "new" + kind.lower()) # Getting that user again should return the same object d = wFD(get(u"new" + kind.lower())) yield d newp = d.getResult() self.assertIdentical(p, newp) # Getting a non-existent user should fail if createUserOnRequest is False setattr(realm, flag, False) d = wFD(get(u"another" + kind.lower())) yield d self.assertRaises(noSuchExc, d.getResult)
def testGetUserMode(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() user.transport.clear() user.write('MODE useruser\r\n') response = self._response(user) self.assertEqual(len(response), 1) self.assertEqual(response[0][0], 'realmname') self.assertEqual(response[0][1], '221') self.assertEqual(response[0][2], ['useruser', '+'])
def test_joinTopicless(self): """ When a user joins a group without a topic, no topic information is sent to that user. """ firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() somechannel = wFD(self.realm.createGroup(u"somechannel")) yield somechannel somechannel = somechannel.getResult() # Bring in one user, make sure he gets into the channel sanely user = TestCaseUserAgg(firstuser, self.realm, self.factory) self._login(user, "firstuser") user.transport.clear() user.write('JOIN #somechannel\r\n') response = self._response(user) responseCodes = [r[1] for r in response] self.assertNotIn('332', responseCodes) self.assertNotIn('333', responseCodes)
def testGetTopic(self): user = wFD(self._loggedInUser(u'useruser')) yield user user = user.getResult() group = service.Group("somechannel") group.meta["topic"] = "This is a test topic." group.meta["topic_author"] = "some_fellow" group.meta["topic_date"] = 77777777 add = wFD(self.realm.addGroup(group)) yield add add.getResult() user.transport.clear() user.write("JOIN #somechannel\r\n") response = self._response(user) self.assertEqual(response[3][0], 'realmname') self.assertEqual(response[3][1], '332') # XXX Sigh. irc.parsemsg() is not as correct as one might hope. self.assertEqual(response[3][2], ['useruser', '#somechannel', 'This is a test topic.']) self.assertEqual(response[4][1], '333') self.assertEqual(response[4][2], ['useruser', '#somechannel', 'some_fellow', '77777777']) user.transport.clear() user.write('TOPIC #somechannel\r\n') response = self._response(user) self.assertEqual(response[0][1], '332') self.assertEqual(response[0][2], ['useruser', '#somechannel', 'This is a test topic.']) self.assertEqual(response[1][1], '333') self.assertEqual(response[1][2], ['useruser', '#somechannel', 'some_fellow', '77777777'])
def testUserRetrieval(self): realm = service.InMemoryWordsRealm("realmname") # Make a user to play around with d = wFD(realm.createUser(u"testuser")) yield d user = d.getResult() # Make sure getting the user returns the same object d = wFD(realm.getUser(u"testuser")) yield d retrieved = d.getResult() self.assertIdentical(user, retrieved) # Make sure looking up the user also returns the same object d = wFD(realm.lookupUser(u"testuser")) yield d lookedUp = d.getResult() self.assertIdentical(retrieved, lookedUp) # Make sure looking up a user who does not exist fails d = wFD(realm.lookupUser(u"nosuchuser")) yield d self.assertRaises(ewords.NoSuchUser, d.getResult)
def testNickServLogin(self): firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() user = TestCaseUserAgg(firstuser, self.realm, self.factory) user.write('NICK firstuser extrainfo\r\n') response = self._response(user) self.assertEquals(len(response), 1) self.assertEquals(response[0][0], service.NICKSERV) self.assertEquals(response[0][1], 'PRIVMSG') self.assertEquals(response[0][2], ['firstuser', 'Password?']) user.transport.clear() user.write('PRIVMSG nickserv firstuser_password\r\n') self._assertGreeting(user)
def test_nickServLogin(self): """ Sending NICK without PASS will prompt the user for their password. When the user sends their password to NickServ, it will respond with a Greeting. """ firstuser = wFD(self.realm.lookupUser(u'firstuser')) yield firstuser firstuser = firstuser.getResult() user = TestCaseUserAgg(firstuser, self.realm, self.factory) user.write('NICK firstuser extrainfo\r\n') response = self._response(user, 'PRIVMSG') self.assertEqual(len(response), 1) self.assertEqual(response[0][0], service.NICKSERV) self.assertEqual(response[0][1], 'PRIVMSG') self.assertEqual(response[0][2], ['firstuser', 'Password?']) user.transport.clear() user.write('PRIVMSG nickserv firstuser_password\r\n') self._assertGreeting(user)
def testPositive(self): for chk in self.getCheckers(): for (cred, avatarId) in self.getGoodCredentials(): r = wFD(chk.requestAvatarId(cred)) yield r self.assertEquals(r.getResult(), avatarId)
def testPositive(self): for chk in self.getCheckers(): for (cred, avatarId) in self.getGoodCredentials(): r = wFD(chk.requestAvatarId(cred)) yield r self.assertEqual(r.getResult(), avatarId)
def testPASSLogin(self): user = wFD(self._loggedInUser(u'firstuser')) yield user user = user.getResult() self._assertGreeting(user)