def testAddMsgRemovesOpsProperly(self): st = irclib.IrcState() st.channels['#foo'] = irclib.ChannelState() st.channels['#foo'].ops.add('bar') m = ircmsgs.mode('#foo', ('-o', 'bar')) st.addMsg(self.irc, m) self.failIf('bar' in st.channels['#foo'].ops)
def testCopy(self): c = irclib.ChannelState() c.addUser('jemfinch') c1 = copy.deepcopy(c) c.removeUser('jemfinch') self.assertFalse('jemfinch' in c.users) self.assertTrue('jemfinch' in c1.users)
def testCopy(self): c = irclib.ChannelState() c.addUser('jemfinch') c1 = copy.deepcopy(c) c.removeUser('jemfinch') self.failIf('jemfinch' in c.users) self.failUnless('jemfinch' in c1.users)
def testPickleCopy(self): c = irclib.ChannelState() self.assertEqual(pickle.loads(pickle.dumps(c)), c) c.addUser('jemfinch') c1 = pickle.loads(pickle.dumps(c)) self.assertEqual(c, c1) c.removeUser('jemfinch') self.failIf('jemfinch' in c.users) self.failUnless('jemfinch' in c1.users)
def testNickChangesChangeChannelUsers(self): st = irclib.IrcState() st.channels['#foo'] = irclib.ChannelState() st.channels['#foo'].addUser('@bar') self.failUnless('bar' in st.channels['#foo'].users) self.failUnless(st.channels['#foo'].isOp('bar')) st.addMsg(self.irc, ircmsgs.IrcMsg(':[email protected] NICK baz')) self.failIf('bar' in st.channels['#foo'].users) self.failIf(st.channels['#foo'].isOp('bar')) self.failUnless('baz' in st.channels['#foo'].users) self.failUnless(st.channels['#foo'].isOp('baz'))
def setUp(self): PluginTestCase.setUp(self) self.testkeyid = "21E2EF9EF2197A66" # set this to a testing key that we have pregenerated self.testkeyfingerprint = "0A969AE0B143927F9D473F3E21E2EF9EF2197A66" self.secringlocation = '/tmp/secring.gpg' #where we store our testing secring (normal location gets wiped by test env) self.cb = self.irc.getCallback('GPG') self.s = ServerProxy('http://paste.pocoo.org/xmlrpc/') shutil.copy(self.secringlocation, self.cb.gpg.gnupghome) chan = irclib.ChannelState() chan.addUser('test') chan.addUser('authedguy2') self.irc.state.channels['#test'] = chan #preseed the GPG db with a GPG registration and auth with some users gpg = self.irc.getCallback('GPG') gpg.db.register('AAAAAAAAAAAAAAA1', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA1', time.time(), 'nanotube') gpg.authed_users['nanotube!stuff@stuff/somecloak'] = { 'nick': 'nanotube', 'keyid': 'AAAAAAAAAAAAAAA1', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA1' } gpg.db.register('AAAAAAAAAAAAAAA2', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA2', time.time(), 'registeredguy') gpg.db.register('AAAAAAAAAAAAAAA3', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA3', time.time(), 'authedguy') gpg.authed_users['[email protected]'] = { 'nick': 'authedguy', 'keyid': 'AAAAAAAAAAAAAAA3', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA3' } gpg.db.register('AAAAAAAAAAAAAAA4', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4', time.time(), 'authedguy2') gpg.authed_users['[email protected]'] = { 'nick': 'authedguy2', 'keyid': 'AAAAAAAAAAAAAAA4', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4' } #set config to match test environment ocn = conf.supybot.plugins.GPG.network() conf.supybot.plugins.GPG.network.setValue('test') occ = conf.supybot.plugins.GPG.channels() conf.supybot.plugins.GPG.channels.setValue('#test')
def testAddUser(self): c = irclib.ChannelState() c.addUser('foo') self.failUnless('foo' in c.users) self.failIf('foo' in c.ops) self.failIf('foo' in c.voices) self.failIf('foo' in c.halfops) c.addUser('+bar') self.failUnless('bar' in c.users) self.failUnless('bar' in c.voices) self.failIf('bar' in c.ops) self.failIf('bar' in c.halfops) c.addUser('%baz') self.failUnless('baz' in c.users) self.failUnless('baz' in c.halfops) self.failIf('baz' in c.voices) self.failIf('baz' in c.ops) c.addUser('@quuz') self.failUnless('quuz' in c.users) self.failUnless('quuz' in c.ops) self.failIf('quuz' in c.halfops) self.failIf('quuz' in c.voices)
def testAddUser(self): c = irclib.ChannelState() c.addUser('foo') self.assertTrue('foo' in c.users) self.assertFalse('foo' in c.ops) self.assertFalse('foo' in c.voices) self.assertFalse('foo' in c.halfops) c.addUser('+bar') self.assertTrue('bar' in c.users) self.assertTrue('bar' in c.voices) self.assertFalse('bar' in c.ops) self.assertFalse('bar' in c.halfops) c.addUser('%baz') self.assertTrue('baz' in c.users) self.assertTrue('baz' in c.halfops) self.assertFalse('baz' in c.voices) self.assertFalse('baz' in c.ops) c.addUser('@quuz') self.assertTrue('quuz' in c.users) self.assertTrue('quuz' in c.ops) self.assertFalse('quuz' in c.halfops) self.assertFalse('quuz' in c.voices)
def testKickRemovesChannel(self): st = irclib.IrcState() st.channels['#foo'] = irclib.ChannelState() m = ircmsgs.kick('#foo', self.irc.nick, prefix=self.irc.prefix) st.addMsg(self.irc, m) self.failIf('#foo' in st.channels)
def testOuit(self): self.prefix = '[email protected]' self.irc.feedMsg(msg=ircmsgs.quit(prefix=self.prefix)) self.assertRegexp('gpg ident', 'not identified') chan = irclib.ChannelState()
def setUp(self): PluginTestCase.setUp(self) self.testkeyid = "21E2EF9EF2197A66" # set this to a testing key that we have pregenerated self.testkeyfingerprint = "0A969AE0B143927F9D473F3E21E2EF9EF2197A66" self.secringlocation = '/tmp/secring.gpg' #where we store our testing secring (normal location gets wiped by test env) self.cb = self.irc.getCallback('GPG') self.s = ServerProxy('http://paste.debian.net/server.pl') shutil.copy(self.secringlocation, self.cb.gpg.gnupghome) chan = irclib.ChannelState() chan.addUser('test') chan.addUser('authedguy2') self.irc.state.channels['#test'] = chan #preseed the GPG db with a GPG registration and auth with some users gpg = self.irc.getCallback('GPG') gpg.db.register('AAAAAAAAAAAAAAA1', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA1', 'someaddr', time.time(), 'nanotube') gpg.authed_users['nanotube!stuff@stuff/somecloak'] = { 'nick': 'nanotube', 'keyid': 'AAAAAAAAAAAAAAA1', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA1', 'bitcoinaddress': '1nthoeubla' } gpg.db.register('AAAAAAAAAAAAAAA2', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA2', 'someaddr', time.time(), 'registeredguy') gpg.db.register('AAAAAAAAAAAAAAA3', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA3', 'someaddr', time.time(), 'authedguy') gpg.authed_users['[email protected]'] = { 'nick': 'authedguy', 'keyid': 'AAAAAAAAAAAAAAA3', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA3', 'bitcoinaddress': '1nthoeubla' } gpg.db.register('AAAAAAAAAAAAAAA4', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4', None, time.time(), 'authedguy2') gpg.authed_users['[email protected]'] = { 'nick': 'authedguy2', 'keyid': 'AAAAAAAAAAAAAAA4', 'fingerprint': 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4', 'bitcoinaddress': None } gpg.db.register('AAAAAAAAAAAAAAA5', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA5', 'someaddr', time.time(), 'registered_guy') gpg.db.register('AAAAAAAAAAAAAAA6', 'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA6', 'someaddr', time.time(), 'registe%redguy') # create the test ecdsa keypair and resulting bitcoin address #~ self.private_key = ecdsa.SigningKey.from_string( '5JkuZ6GLsMWBKcDWa5QiD15Uj467phPR', curve = bitcoinsig.SECP256k1 ) #~ self.public_key = self.private_key.get_verifying_key() #~ self.bitcoinaddress = bitcoinsig.public_key_to_bc_address( '04'.decode('hex') + self.public_key.to_string() ) #set config to match test environment ocn = conf.supybot.plugins.GPG.network() conf.supybot.plugins.GPG.network.setValue('test') occ = conf.supybot.plugins.GPG.channels() conf.supybot.plugins.GPG.channels.setValue('#test')