2019-01-22 01:26:07 +00:00
|
|
|
"""Sherlock Tests
|
|
|
|
|
|
|
|
This module contains various tests.
|
|
|
|
"""
|
|
|
|
from tests.base import SherlockBaseTest
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class SherlockDetectTests(SherlockBaseTest):
|
2019-07-14 23:31:55 +00:00
|
|
|
def test_detect_true_via_message(self):
|
|
|
|
"""Test Username Does Exist (Via Message).
|
2019-01-22 01:26:07 +00:00
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
This test ensures that the "message" detection mechanism of
|
|
|
|
ensuring that a Username does exist works properly.
|
2019-01-22 01:26:07 +00:00
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
2019-07-14 23:31:55 +00:00
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
2019-01-22 01:26:07 +00:00
|
|
|
"""
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
site = 'Instagram'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_claimed"]],
|
|
|
|
[site],
|
|
|
|
exist_check=True
|
|
|
|
)
|
2019-01-22 01:26:07 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
site = 'Instagram'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_unclaimed"]],
|
|
|
|
[site],
|
2019-01-22 01:26:07 +00:00
|
|
|
exist_check=False
|
|
|
|
)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
def test_detect_true_via_status_code(self):
|
|
|
|
"""Test Username Does Exist (Via Status Code).
|
|
|
|
|
|
|
|
This test ensures that the "status code" detection mechanism of
|
|
|
|
ensuring that a Username does exist works properly.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
|
|
|
site = 'Facebook'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_claimed"]],
|
|
|
|
[site],
|
|
|
|
exist_check=True
|
|
|
|
)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2019-01-22 01:26:07 +00:00
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
site = 'Facebook'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_unclaimed"]],
|
|
|
|
[site],
|
2019-01-22 01:26:07 +00:00
|
|
|
exist_check=False
|
|
|
|
)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
def test_detect_true_via_response_url(self):
|
|
|
|
"""Test Username Does Exist (Via Response URL).
|
|
|
|
|
|
|
|
This test ensures that the "response URL" detection mechanism of
|
|
|
|
ensuring that a Username does exist works properly.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
|
|
|
site = 'Quora'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("response_url", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_claimed"]],
|
|
|
|
[site],
|
|
|
|
exist_check=True
|
|
|
|
)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2019-01-22 01:26:07 +00:00
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2019-07-14 23:31:55 +00:00
|
|
|
site = 'Quora'
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
#Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("response_url", site_data["errorType"])
|
|
|
|
|
|
|
|
self.username_check([site_data["username_unclaimed"]],
|
|
|
|
[site],
|
2019-01-22 01:26:07 +00:00
|
|
|
exist_check=False
|
|
|
|
)
|
|
|
|
|
|
|
|
return
|
2019-01-23 02:16:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SherlockSiteCoverageTests(SherlockBaseTest):
|
|
|
|
def test_coverage_false_via_response_url(self):
|
|
|
|
"""Test Username Does Not Exist Site Coverage (Via Response URL).
|
|
|
|
|
|
|
|
This test checks all sites with the "response URL" detection mechanism
|
|
|
|
to ensure that a Username that does not exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:46:53 +00:00
|
|
|
self.detect_type_check("response_url", exist_check=False)
|
2019-01-23 02:16:19 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def test_coverage_true_via_response_url(self):
|
|
|
|
"""Test Username Does Exist Site Coverage (Via Response URL).
|
|
|
|
|
|
|
|
This test checks all sites with the "response URL" detection mechanism
|
|
|
|
to ensure that a Username that does exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:46:53 +00:00
|
|
|
self.detect_type_check("response_url", exist_check=True)
|
2019-01-23 02:16:19 +00:00
|
|
|
|
|
|
|
return
|
2019-01-30 23:45:36 +00:00
|
|
|
|
|
|
|
def test_coverage_false_via_status(self):
|
|
|
|
"""Test Username Does Not Exist Site Coverage (Via HTTP Status).
|
|
|
|
|
|
|
|
This test checks all sites with the "HTTP Status" detection mechanism
|
|
|
|
to ensure that a Username that does not exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:40:16 +00:00
|
|
|
self.detect_type_check("status_code", exist_check=False)
|
2019-01-30 23:45:36 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def test_coverage_true_via_status(self):
|
|
|
|
"""Test Username Does Exist Site Coverage (Via HTTP Status).
|
|
|
|
|
|
|
|
This test checks all sites with the "HTTP Status" detection mechanism
|
|
|
|
to ensure that a Username that does exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:40:16 +00:00
|
|
|
self.detect_type_check("status_code", exist_check=True)
|
2019-01-30 23:45:36 +00:00
|
|
|
|
|
|
|
return
|
2019-01-31 00:24:28 +00:00
|
|
|
|
|
|
|
def test_coverage_false_via_message(self):
|
|
|
|
"""Test Username Does Not Exist Site Coverage (Via Error Message).
|
|
|
|
|
|
|
|
This test checks all sites with the "Error Message" detection mechanism
|
|
|
|
to ensure that a Username that does not exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:32:06 +00:00
|
|
|
self.detect_type_check("message", exist_check=False)
|
2019-01-31 00:24:28 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def test_coverage_true_via_message(self):
|
|
|
|
"""Test Username Does Exist Site Coverage (Via Error Message).
|
|
|
|
|
|
|
|
This test checks all sites with the "Error Message" detection mechanism
|
|
|
|
to ensure that a Username that does exist is reported that way.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
|
2019-02-03 02:32:06 +00:00
|
|
|
self.detect_type_check("message", exist_check=True)
|
2019-01-31 00:24:28 +00:00
|
|
|
|
|
|
|
return
|
2019-02-10 05:34:09 +00:00
|
|
|
|
|
|
|
def test_coverage_total(self):
|
|
|
|
"""Test Site Coverage Is Total.
|
|
|
|
|
|
|
|
This test checks that all sites have test data available.
|
|
|
|
|
|
|
|
Keyword Arguments:
|
|
|
|
self -- This object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
N/A.
|
|
|
|
Will trigger an assert if we do not have total coverage.
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.coverage_total_check()
|
|
|
|
|
|
|
|
return
|