Merge pull request #39 from NotoriousRebel/dev

removed unncessary tests.
This commit is contained in:
Matt 2020-02-13 17:55:53 -05:00 committed by GitHub
commit 5cb32bbd7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 22 deletions

View file

@ -1,5 +1,4 @@
from theHarvester.discovery import githubcode
from theHarvester.discovery.githubcode import RetryResult, ErrorResult, SuccessResult
from theHarvester.discovery.constants import MissingKey
from theHarvester.lib.core import Core
from unittest.mock import MagicMock
@ -84,24 +83,6 @@ async def test_invalid_fragments_from_response(self):
test_result = await test_class_instance.fragments_from_response(self.MalformedResponse.response.json())
assert test_result == []
async def test_handle_response_ok(self):
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = await test_class_instance.handle_response()
assert isinstance(test_result, SuccessResult)
async def test_handle_response_retry(self):
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = await test_class_instance.handle_response(self.RetryResponse.response.json())
assert isinstance(test_result, RetryResult)
async def test_handle_response_fail(self):
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = await test_class_instance.handle_response(self.FailureResponse.response.json())
assert isinstance(test_result, ErrorResult)
async def test_next_page(self):
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)

View file

@ -16,11 +16,13 @@ async def do_search(self):
dct = responses
self.totalhosts: set = {
host.split(',')[0].replace('www','') if ',' in host and self.word.replace('www.', '') in host.split(',')[0] in host else
host.split(',')[0].replace('www.', '') if ',' in host and self.word.replace('www.', '') in host.split(',')[
0] in host else
host.split(',')[1] for host in dct['FDNS_A']}
self.totalips: set = {ip.split(',')[0]for ip in dct['FDNS_A'] if
self.totalips: set = {ip.split(',')[0] for ip in dct['FDNS_A'] if
re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", ip.split(',')[0])}
async def get_hostnames(self) -> set:
return self.totalhosts

View file

@ -1,5 +1,6 @@
from theHarvester.lib.core import *
import aiohttp
from typing import Set
class SearchCrtsh:
@ -18,7 +19,8 @@ async def do_search(self) -> Set:
response = await AsyncFetcher.fetch(client, url, json=True, proxy=self.proxy)
await client.close()
data = set(
[dct['name_value'][2:] if '*.' == dct['name_value'][:2] else dct['name_value'] for dct in response])
[dict(dct)['name_value'][2:] if '*.' == dict(dct)['name_value'][:2] else dict(dct)['name_value']
for dct in response])
except Exception as e:
print(e)
return data