def test_get_entropy(self):
     string = "ab"
     info("Checked string - {}".format(string))
     e = get_entropy(string)
     info("Calculated entropy: {}".format(e))
     assert_true(e > 0, "Check if calculated entropy is bigger than 0")
     assert_equal(e, 1,
                  "Check if calculated entropy is equal to predicted one")
 def test_add_ip_correct(self, mock_add_ip):
     ip = "127.0.0.1"
     mocked_id = randint(1, 10)
     # Mock Goodies response
     mock_add_ip.return_value = mocked_id
     status, cid = db_helper.add_ip(ip)
     assert_true(status, "Check if method return correct status")
     assert_type(cid, int, "Check if id is correct int")
     assert_equal(cid, mocked_id, "Check if returned id is as expected")
    def test_add_cert_correct(self, mock_add_cert):

        # Mock Cert response
        mocked_id = 1
        mock_add_cert.return_value = mocked_id
        info("Created mock Cert with id: {}".format(mocked_id))

        status, cid = db_helper.add_cert("test.com")
        assert_true(status, "Check if method return correct status")
        assert_equal(cid, mocked_id, "Check if method returned correct id")
    def test_match_keyword(self, mock_goodie):

        fake = Faker()
        mocked_keyword = fake.domain_word()
        # Mock Goodies response
        mock_goodie.return_value = [{'good_keyword': mocked_keyword}]
        info("Created mock Goodie with keyword: {}".format(mocked_keyword))

        domain = "{}x.com".format(mocked_keyword)
        info("Requested domain - {}".format(domain))
        l = match_keyword(domain)
        assert_type(l, tuple, "Check if proper tuple is returned")
        assert_true(l[0], "Check if keyword matches domain")
        assert_equal(l[1], mocked_keyword,
                     "Check if returned keyword is equal to mocked one")
示例#5
0
    def test_levenstein_check(self):

        fake = Faker()
        keywords = [fake.domain_word() for i in range(0, 2)]
        info("Generated keyword: {}".format(keywords))

        proper_keyword = keywords[0]
        domain = "{}x.{}.{}awdawdawdfawytdawdrawd.com".format(
            proper_keyword, proper_keyword, proper_keyword)
        info("Requested domain - {}".format(domain))
        l = levenstein_check(keywords, domain.split('.'))
        assert_type(l, tuple, "Check if proper tuple is returned")
        assert_true(l[0], "Check if keyword matches domain")
        assert_equal(l[1], 1, "Check if keyword matches domain only one time")
        assert_equal(l[2], proper_keyword,
                     "Check if proper keyword is returned")
        assert_equal(l[3], 1,
                     "Check if proper levenstein distance is returned")
示例#6
0
 def test_get_ip(self):
     domain = "google.com"
     info("Requested domain - {}".format(domain))
     ip = get_ip(domain)
     info("Returned ip: {}".format(ip))
     assert_true(ip.count('.') == 3, "Check if returned ip is correct ip")
    def test_add_ip_correct(self):  #, mock_get_ip_details):
        ip = "127.0.0.1"

        status, cid = db_helper.add_ip(ip)
        assert_true(status, "Check if method return correct status")
        assert_type(cid, int, "Check if id is correct int")