2019-09-07 10:58:57 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
from theHarvester.discovery import linkedinsearch
|
2019-09-07 11:00:22 +08:00
|
|
|
import pytest
|
2019-09-08 08:59:58 +08:00
|
|
|
import os
|
2019-09-08 08:34:11 +08:00
|
|
|
import re
|
2019-09-07 10:58:57 +08:00
|
|
|
|
|
|
|
|
2019-09-08 08:59:58 +08:00
|
|
|
|
2019-09-07 10:58:57 +08:00
|
|
|
class TestGetLinks(object):
|
|
|
|
|
|
|
|
def test_get_links(self):
|
|
|
|
search = linkedinsearch.SearchLinkedin("facebook.com", '100')
|
|
|
|
search.process()
|
|
|
|
links = search.get_links()
|
2019-09-08 07:50:53 +08:00
|
|
|
assert list(links)
|
2019-09-07 11:35:59 +08:00
|
|
|
|
2019-09-08 08:34:11 +08:00
|
|
|
def test_links_linkedin(self):
|
2019-09-08 08:59:58 +08:00
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
2019-09-08 09:04:05 +08:00
|
|
|
mock_response = open(dir_path + "/test_linkedin_links.txt").read()
|
2019-09-08 08:34:11 +08:00
|
|
|
reg_links = re.compile(r"url=https:\/\/www\.linkedin.com(.*?)&")
|
2019-09-08 09:04:05 +08:00
|
|
|
temp = reg_links.findall(mock_response)
|
2019-09-08 08:34:11 +08:00
|
|
|
resul = []
|
2019-09-08 09:04:05 +08:00
|
|
|
for regex_item in temp:
|
|
|
|
stripped_url = regex_item.replace("url=", "")
|
2019-09-08 08:34:11 +08:00
|
|
|
resul.append("https://www.linkedin.com" + y)
|
|
|
|
assert set(resul)
|
|
|
|
|
|
|
|
|
2019-09-07 10:58:57 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
pytest.main()
|