async def test_enumerate_found_raise_if_host_is_offline(self, loop): async def fake_perform(*args, **kwargs): raise OfflineHostException() hammertime = HammerTime(loop) hammertime.request_engine = MagicMock() hammertime.request_engine.perform = fake_perform component_finder = ActiveComponentFinder(hammertime, self.target_url) component_finder.components_file_list_group = self.plugin_list with self.assertRaises(OfflineHostException): async for _ in component_finder.enumerate_found(): pass
async def test_enumerate_found_return_list_of_dict_with_component_key_and_fetched_files( self, loop): async def fake_perform(entry, *args, **kwargs): entry.result.hash = "fake-hash" return entry hammertime = HammerTime(loop) hammertime.request_engine = MagicMock() hammertime.request_engine.perform = fake_perform component_finder = ActiveComponentFinder(hammertime, self.target_url) component_finder.components_file_list_group = self.plugin_list components = await self.return_async_iterator_as_list( component_finder.enumerate_found()) for component_dict in components: self.assertTrue( component_dict['key'] == self.plugin0_file_list.key or component_dict['key'] == self.plugin1_file_list.key) self.assertIn('files', component_dict)