def test_pickleable_shells(self): pool = Pool(1) xurllib = ExtendedUrllib() original_shell = Shell(MockVuln(), xurllib, pool) kb.append('a', 'b', original_shell) unpickled_shell = kb.get('a', 'b')[0] self.assertEqual(original_shell, unpickled_shell) self.assertEqual(unpickled_shell.worker_pool, None) self.assertEqual(unpickled_shell._uri_opener, None) pool.terminate() pool.join() xurllib.end()
def test_pickleable_shells_get_all(self): class FakeCore(object): worker_pool = Pool(1) uri_opener = ExtendedUrllib() core = FakeCore() original_shell = Shell(MockVuln(), core.uri_opener, core.worker_pool) kb.append('a', 'b', original_shell) unpickled_shell = list(kb.get_all_shells(core))[0] self.assertEqual(original_shell, unpickled_shell) self.assertEqual(unpickled_shell.worker_pool, core.worker_pool) self.assertEqual(unpickled_shell._uri_opener, core.uri_opener) core.worker_pool.terminate() core.worker_pool.join() core.uri_opener.end()
def __init__(self, vuln, uri_opener, worker_pool): Shell.__init__(self, vuln, uri_opener, worker_pool) # For writing files to the remote server self._transfer_handler = None