From d07df7b92c1ebf464428a8fce02499c3fcb21ed4 Mon Sep 17 00:00:00 2001 From: theodosisathanasakis
From d24387e30a97ebc5ff14313dca6621bc183f2d70 Mon Sep 17 00:00:00 2001
From: HATI <37483725+HA71@users.noreply.github.com>
Date: Sat, 19 Jan 2019 14:46:39 +0100
Subject: [PATCH 13/25] Update sites.md
---
sites.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sites.md b/sites.md
index 6bcc341b..3e114b3f 100644
--- a/sites.md
+++ b/sites.md
@@ -114,7 +114,7 @@
113. [Wikipedia](https://www.wikipedia.org/)
114. [Mastodon](https://mstdn.io/)
115. [Telegram](https://t.me/)
-116. [TradingView] (https://www.tradingview.com/)
+116. [TradingView](https://www.tradingview.com/)
117. [Kaggle](https://www.kaggle.com/)
118. [Itch.io](https://itch.io/)
119. [Basecamp](https://basecamp.com/)
From 7eeaabf17ee97245827245e770f5874355301063 Mon Sep 17 00:00:00 2001
From: Jus de Patate
@@ -78,4 +78,4 @@ docker run theyahya/sherlock user123
## License
MIT License
-Copyright (c) 2018 Siddharth Dushantha
+Copyright (c) 2018 Yahya SayadArbabi
From e92225aaa23231b73236cd85a0b76b4d929a6deb Mon Sep 17 00:00:00 2001
From: Yahya SayadArbabi
@@ -77,6 +77,26 @@ Or you can simply use "Docker Hub" to run `sherlock`:
docker run theyahya/sherlock user123
```
+## Tests
+If you are contributing to Sherlock, then Thank You!
+
+Before creating a pull request with new development, please run the tests
+to ensure that all is well. It would also be a good idea to run the tests
+before starting development to distinguish problems between your
+environment and the Sherlock software.
+
+The following is an example of the command line to run all the tests for
+Sherlock. This invocation hides the progress text that Sherlock normally
+outputs, and instead shows the verbose output of the tests.
+
+```
+% python3 -m unittest tests.all --buffer --verbose
+```
+
+Note that the tests are very much a work in progress. Significant work is
+required to get full test coverage. But, the current tests are working
+properly, and will be expanded as time goes by.
+
## License
MIT © [Yahya SayadArbabi](https://theyahya.com)
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..944e27ce
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,4 @@
+"""Sherlock Tests
+
+This package contains various submodules used to run tests.
+"""
diff --git a/tests/all.py b/tests/all.py
new file mode 100644
index 00000000..87d3b9b8
--- /dev/null
+++ b/tests/all.py
@@ -0,0 +1,94 @@
+"""Sherlock Tests
+
+This module contains various tests.
+"""
+from tests.base import SherlockBaseTest
+import unittest
+
+
+class SherlockDetectTests(SherlockBaseTest):
+ def test_detect_true(self):
+ """Test Username Existence Detection.
+
+ This test ensures that the mechanism of ensuring that a Username
+ exists works properly.
+
+ Keyword Arguments:
+ self -- This object.
+
+ Return Value:
+ N/A.
+ Will trigger an assert if Usernames which are known to exist are
+ not detected.
+ """
+
+ self.username_check(['jack'], ['Twitter'], exist_check=True)
+ #self.username_check(['dfox'], ['devRant'], exist_check=True)
+ self.username_check(['blue'], ['Pinterest'], exist_check=True)
+ self.username_check(['kevin'], ['Instagram'], exist_check=True)
+ self.username_check(['zuck'], ['Facebook'], exist_check=True)
+
+ return
+
+ def test_detect_false_via_message(self):
+ """Test Username Does Not Exist (Via Message).
+
+ This test ensures that the "message" detection mechanism of
+ ensuring that a Username does *not* exist works properly.
+
+ Keyword Arguments:
+ self -- This object.
+
+ Return Value:
+ N/A.
+ Will trigger an assert if detection mechanism did not work as expected.
+ """
+
+ self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
+ ['Instagram'],
+ exist_check=False
+ )
+
+ return
+
+ def test_detect_false_via_status_code(self):
+ """Test Username Does Not Exist (Via Status Code).
+
+ This test ensures that the "status code" detection mechanism of
+ ensuring that a Username does *not* exist works properly.
+
+ Keyword Arguments:
+ self -- This object.
+
+ Return Value:
+ N/A.
+ Will trigger an assert if detection mechanism did not work as expected.
+ """
+
+ self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
+ ['Facebook'],
+ exist_check=False
+ )
+
+ return
+
+ def test_detect_false_via_response_url(self):
+ """Test Username Does Not Exist (Via Response URL).
+
+ This test ensures that the "response URL" detection mechanism of
+ ensuring that a Username does *not* exist works properly.
+
+ Keyword Arguments:
+ self -- This object.
+
+ Return Value:
+ N/A.
+ Will trigger an assert if detection mechanism did not work as expected.
+ """
+
+ self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
+ ['Pinterest'],
+ exist_check=False
+ )
+
+ return
diff --git a/tests/base.py b/tests/base.py
new file mode 100644
index 00000000..0f992ba8
--- /dev/null
+++ b/tests/base.py
@@ -0,0 +1,107 @@
+"""Sherlock Base Tests
+
+This module contains various utilities for running tests.
+"""
+import json
+import os
+import os.path
+import unittest
+import sherlock
+import warnings
+
+
+class SherlockBaseTest(unittest.TestCase):
+ def setUp(self):
+ """Sherlock Base Test Setup.
+
+ Does common setup tasks for base Sherlock tests.
+
+ Keyword Arguments:
+ self -- This object.
+
+ Return Value:
+ N/A.
+ """
+
+ #This ignores the ResourceWarning from an unclosed SSLSocket.
+ #TODO: Figure out how to fix the code so this is not needed.
+ warnings.simplefilter("ignore", ResourceWarning)
+
+ # Load the data file with all site information.
+ data_file_path = os.path.join(os.path.dirname(os.path.realpath(sherlock.__file__)), "data.json")
+ with open(data_file_path, "r", encoding="utf-8") as raw:
+ self.site_data_all = json.load(raw)
+
+ self.verbose=False
+ self.tor=False
+ self.unique_tor=False
+
+ return
+
+ def site_data_filter(self, site_list):
+ """Filter Site Data.
+
+ Keyword Arguments:
+ self -- This object.
+ site_list -- List of strings corresponding to sites which
+ should be filtered.
+
+ Return Value:
+ Dictionary containing sub-set of site data specified by 'site_list'.
+ """
+
+ # Create new dictionary that has filtered site data based on input.
+ # Note that any site specified which is not understood will generate
+ # an error.
+ site_data = {}
+ for site in site_list:
+ with self.subTest(f"Checking test vector Site '{site}' "
+ f"exists in total site data."
+ ):
+ site_data[site] = self.site_data_all[site]
+
+ return site_data
+
+ def username_check(self, username_list, site_list, exist_check=True):
+ """Username Exist Check.
+
+ Keyword Arguments:
+ self -- This object.
+ username_list -- List of strings corresponding to usernames
+ which should exist on *all* of the sites.
+ site_list -- List of strings corresponding to sites which
+ should be filtered.
+ exist_check -- Boolean which indicates if this should be
+ a check for Username existence,
+ or non-existence.
+
+ Return Value:
+ N/A.
+ Will trigger an assert if Username does not have the expected
+ existence state.
+ """
+
+ #Filter all site data down to just what is needed for this test.
+ site_data = self.site_data_filter(site_list)
+
+ if exist_check:
+ check_type_text = "exists"
+ exist_result_desired = "yes"
+ else:
+ check_type_text = "does not exist"
+ exist_result_desired = "no"
+
+ for username in username_list:
+ results = sherlock.sherlock(username,
+ site_data,
+ verbose=self.verbose,
+ tor=self.tor,
+ unique_tor=self.unique_tor
+ )
+ for site, result in results.items():
+ with self.subTest(f"Checking Username '{username}' "
+ f"{check_type_text} on Site '{site}'"
+ ):
+ self.assertEqual(result['exists'], exist_result_desired)
+
+ return
From 4c6bb61483ccbe4ccd924cbe9a5a6f1a638f404a Mon Sep 17 00:00:00 2001
From: "Christopher K. Hoadley"