def test_is_whitelisted_for_domain(self) -> None: """ Test a given email passes domain whitelist check against ccla_signature """ signature = Signature() signature.get_domain_whitelist = Mock(return_value=[".gmail.com"]) self.assertTrue(utils.is_whitelisted(signature, email="*****@*****.**")) self.assertFalse(utils.is_whitelisted(signature, email="*****@*****.**"))
def test_is_whitelisted_for_github(self) -> None: """ Test given github user passes github whitelist check against ccla_signature """ signature = Signature() signature.get_github_whitelist = Mock(return_value=['foo']) self.assertTrue(utils.is_whitelisted(signature, github_username='******')) self.assertFalse(utils.is_whitelisted(signature, github_username='******'))
def test_is_whitelisted_for_email(self) -> None: """ Test a given email to check if whitelisted against ccla_signature """ signature = Signature() signature.get_email_whitelist = Mock(return_value={"*****@*****.**"}) self.assertTrue(utils.is_whitelisted(signature, email="*****@*****.**")) self.assertFalse(utils.is_whitelisted(signature, email="*****@*****.**"))
def test_is_whitelisted_for_github_org(self) -> None: """ Test given github user passes github org check against ccla_signature """ self.mock_get.return_value.ok = True github_orgs = [{ 'login': '******', }] self.mock_get.return_value = Mock() self.mock_get.return_value.json.return_value = github_orgs signature = Signature() signature.get_github_org_whitelist = Mock(return_value=['foo-org']) self.assertTrue(utils.is_whitelisted(signature, github_username='******'))