def testStsInCleartextConnectionNoDuration(self): # "Servers MAY send this key to all clients, but insecurely # connected clients MUST ignore it." self.irc.driver.anyCertValidationEnabled.return_value = False self.irc.driver.ssl = True self.irc.driver.currentServer = drivers.Server('irc.test', 6667, False) self.irc.feedMsg( ircmsgs.IrcMsg(command='CAP', args=('*', 'LS', 'sts=port=6697'))) self.assertEqual(ircdb.networks.getNetwork('test').stsPolicies, {}) self.irc.driver.reconnect.assert_called_once_with( server=drivers.Server('irc.test', 6697, True), wait=True)
def testStsInSecureConnection(self): self.irc.driver.anyCertValidationEnabled.return_value = True self.irc.driver.ssl = True self.irc.driver.currentServer = drivers.Server('irc.test', 6697, False) self.irc.feedMsg( ircmsgs.IrcMsg(command='CAP', args=('*', 'LS', 'sts=duration=42,port=6697'))) self.assertEqual( ircdb.networks.getNetwork('test').stsPolicies, {'irc.test': 'duration=42,port=6697'}) self.irc.driver.reconnect.assert_not_called()
def testValidStsPolicy(self): irc = irclib.Irc('test') net = ircdb.networks.getNetwork('test') net.addStsPolicy('example.com', 'duration=10,port=6697') net.addDisconnection('example.com') with conf.supybot.networks.test.servers.context( ['example.com:6667', 'example.org:6667']): driver = drivers.ServersMixin(irc) self.assertEqual(driver._getNextServer(), drivers.Server('example.com', 6697, None, True)) driver.die() self.assertEqual(driver._getNextServer(), drivers.Server('example.org', 6667, None, False)) driver.die() self.assertEqual(driver._getNextServer(), drivers.Server('example.com', 6697, None, True))
def testExpiredStsPolicy(self): irc = irclib.Irc('test') net = ircdb.networks.getNetwork('test') net.addStsPolicy('example.com', 'duration=10,port=6697') net.addDisconnection('example.com') timeFastForward(16) with conf.supybot.networks.test.servers.context(['example.com:6667']): driver = drivers.ServersMixin(irc) self.assertEqual(driver._getNextServer(), drivers.Server('example.com', 6667, None, False))