Fix tests

This commit is contained in:
nyuszika7h 2014-08-02 13:45:41 +02:00
parent 871607614a
commit e185416987
2 changed files with 21 additions and 18 deletions

View File

@ -931,20 +931,7 @@ class Irc(IrcCommandDispatcher):
return return
caps = ['account-notify', 'extended-join'] self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('LS',)))
if self.sasl_password:
if not self.sasl_username:
log.warning('%s: SASL username is not set, unable to '
'identify.', self.network)
else:
caps.append('sasl')
log.debug('%s: Requesting capabilities: %s',
self.network, ' '.join(caps))
for cap in caps:
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap)))
if self.password: if self.password:
log.info('%s: Queuing PASS command, not logging the password.', log.info('%s: Queuing PASS command, not logging the password.',
@ -975,16 +962,28 @@ class Irc(IrcCommandDispatcher):
self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,))) self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,)))
def doCap(self, msg): def doCap(self, msg):
caps = ['account-notify', 'extended-join']
if self.sasl_password:
if self.sasl_username:
caps.append('sasl')
else:
log.warning('%s: SASL username is not set, unable to '
'identify.', self.network)
for cap in msg.args[2].split(' '): for cap in msg.args[2].split(' '):
if msg.args[1] == 'ACK': if msg.args[1] == 'LS' and cap in caps:
log.info('%s: Server acknowledged %r capability', log.debug('%s: Requesting capability %r', cap)
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap)))
elif msg.args[1] == 'ACK':
log.info('%s: Server acknowledged capability %r',
self.network, cap) self.network, cap)
if cap == 'sasl': if cap == 'sasl':
self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE',
args=('PLAIN',))) args=('PLAIN',)))
elif msg.args[1] == 'NAK': elif msg.args[1] == 'NAK':
log.warning('%s: Server refused %r capability', log.warning('%s: Server refused capability %r',
self.network, cap) self.network, cap)
if cap == 'sasl': if cap == 'sasl':

View File

@ -382,6 +382,8 @@ class IrcTestCase(SupyTestCase):
m = self.irc.takeMsg() m = self.irc.takeMsg()
self.failUnless(m.command == 'NICK', 'Expected NICK, got %r.' % m) self.failUnless(m.command == 'NICK', 'Expected NICK, got %r.' % m)
m = self.irc.takeMsg() m = self.irc.takeMsg()
self.failUnless(m.command == 'CAP', 'Expected NICK, got %r.' % m)
m = self.irc.takeMsg()
self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m) self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m)
def testPingResponse(self): def testPingResponse(self):
@ -478,7 +480,9 @@ class IrcCallbackTestCase(SupyTestCase):
conf.supybot.nick.setValue(nick) conf.supybot.nick.setValue(nick)
user = 'user any user' user = 'user any user'
conf.supybot.user.setValue(user) conf.supybot.user.setValue(user)
expected = [ircmsgs.nick(nick), ircmsgs.user('limnoria', user)] expected = [ircmsgs.nick(nick),
ircmsgs.IrcMsg(command='CAP', args=('LS',)),
ircmsgs.user('limnoria', user)]
irc = irclib.Irc('test') irc = irclib.Irc('test')
msgs = [irc.takeMsg()] msgs = [irc.takeMsg()]
while msgs[-1] != None: while msgs[-1] != None: