theHarvester/tests/discovery/test_linkedin_links.py

32 lines
885 B
Python
Raw Normal View History

#!/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-08 08:59:58 +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 09:20:35 +08:00
assert set(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__))
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(.*?)&")
temp = reg_links.findall(mock_response)
2019-09-08 08:34:11 +08:00
resul = []
for regex_item in temp:
stripped_url = regex_item.replace("url=", "")
2019-09-08 09:20:35 +08:00
resul.append("https://www.linkedin.com" + stripped_url)
2019-09-08 08:34:11 +08:00
assert set(resul)
if __name__ == '__main__':
pytest.main()