|
|
@ -3,7 +3,7 @@
|
|
|
|
This module contains various tests.
|
|
|
|
This module contains various tests.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from tests.base import SherlockBaseTest
|
|
|
|
from tests.base import SherlockBaseTest
|
|
|
|
import secrets
|
|
|
|
import exrex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SherlockDetectTests(SherlockBaseTest):
|
|
|
|
class SherlockDetectTests(SherlockBaseTest):
|
|
|
@ -27,10 +27,7 @@ class SherlockDetectTests(SherlockBaseTest):
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
|
|
|
|
|
|
|
|
self.username_check([site_data["username_claimed"]],
|
|
|
|
self.username_check([site_data["username_claimed"]], [site], exist_check=True)
|
|
|
|
[site],
|
|
|
|
|
|
|
|
exist_check=True
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
@ -54,10 +51,16 @@ class SherlockDetectTests(SherlockBaseTest):
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
self.assertEqual("message", site_data["errorType"])
|
|
|
|
|
|
|
|
|
|
|
|
self.username_check([secrets.token_urlsafe(10)],
|
|
|
|
# Generate a valid username based on the regex for a username that the
|
|
|
|
[site],
|
|
|
|
# site supports that is *most likely* not taken. The regex is slighlty
|
|
|
|
exist_check=False
|
|
|
|
# modified version of site_data["regexCheck"] as we want a username
|
|
|
|
)
|
|
|
|
# that has the maximum length that is supported by the site. This way,
|
|
|
|
|
|
|
|
# we wont generate a random username that might actually exist. This
|
|
|
|
|
|
|
|
# method is very hacky, but it does the job as having hardcoded
|
|
|
|
|
|
|
|
# usernames that dont exists will lead to people with ill intent to
|
|
|
|
|
|
|
|
# create an account with that username which will break the tests
|
|
|
|
|
|
|
|
valid_username = exrex.getone(r"^[a-z0-9][a-z0-9-]{32}$")
|
|
|
|
|
|
|
|
self.username_check([valid_username], [site], exist_check=False)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
@ -75,16 +78,13 @@ class SherlockDetectTests(SherlockBaseTest):
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
site = "9GAG"
|
|
|
|
site = "BitBucket"
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
|
|
|
|
|
|
|
|
self.username_check([site_data["username_claimed"]],
|
|
|
|
self.username_check([site_data["username_claimed"]], [site], exist_check=True)
|
|
|
|
[site],
|
|
|
|
|
|
|
|
exist_check=True
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
@ -102,57 +102,27 @@ class SherlockDetectTests(SherlockBaseTest):
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
site = "9GAG"
|
|
|
|
site = "BitBucket"
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
site_data = self.site_data_all[site]
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
# Ensure that the site's detection method has not changed.
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
self.assertEqual("status_code", site_data["errorType"])
|
|
|
|
|
|
|
|
|
|
|
|
self.username_check([secrets.token_urlsafe(10)],
|
|
|
|
# Generate a valid username based on the regex for a username that the
|
|
|
|
[site],
|
|
|
|
# site supports that is *most likely* not taken. The regex is slighlty
|
|
|
|
exist_check=False
|
|
|
|
# modified version of site_data["regexCheck"] as we want a username
|
|
|
|
)
|
|
|
|
# that has the maximum length that is supported by the site. This way,
|
|
|
|
|
|
|
|
# we wont generate a random username that might actually exist. This
|
|
|
|
|
|
|
|
# method is very hacky, but it does the job as having hardcoded
|
|
|
|
|
|
|
|
# usernames that dont exists will lead to people with ill intent to
|
|
|
|
|
|
|
|
# create an account with that username which will break the tests
|
|
|
|
|
|
|
|
valid_username = exrex.getone(r"^[a-zA-Z0-9-_]{30}")
|
|
|
|
|
|
|
|
self.username_check([valid_username], [site], exist_check=False)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SherlockSiteCoverageTests(SherlockBaseTest):
|
|
|
|
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:
|
|
|
|
|
|
|
|
Nothing.
|
|
|
|
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.detect_type_check("response_url", exist_check=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Nothing.
|
|
|
|
|
|
|
|
Will trigger an assert if detection mechanism did not work as expected.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.detect_type_check("response_url", exist_check=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_coverage_false_via_status(self):
|
|
|
|
def test_coverage_false_via_status(self):
|
|
|
|
"""Test Username Does Not Exist Site Coverage (Via HTTP Status).
|
|
|
|
"""Test Username Does Not Exist Site Coverage (Via HTTP Status).
|
|
|
|
|
|
|
|
|
|
|
|