Ejemplo n.º 1
0
    def test_get_geo_imgs(self):
        print("[!] Warning, this test is dependent on no server changes for example.org")
        correct_response = [None,
                            'https://www.google.com/maps/@?api=1&map_action=map&center=34.05223, -118.24368&zoom=13']
        ig = InfoGetter('example.org')
        result = ig._get_geo_imgs(ig._get_whois_data(ig._get_ip(ig.url)), ig._get_geo_location_data(ig._get_ip(ig.url)),
                                  ig.filepath)

        self.assertEqual(correct_response, result)

        # Clean
        os.remove(os.getcwd() + '/output/example - org/location.jpg')
        os.rmdir(os.getcwd() + '/output/example - org')
        os.rmdir(os.getcwd() + '/output')
Ejemplo n.º 2
0
    def test_get_ip(self):
        ig = InfoGetter('example.org')
        # Check url sanitizing
        results = []
        for url in TEST_URLS:
            results.append(ig._get_ip(url))

        r_0 = results[0]
        for elems in results:
            self.assertEqual(r_0, elems)

        # Clean
        os.rmdir(os.getcwd() + '/output/example - org')
        os.rmdir(os.getcwd() + '/output')
Ejemplo n.º 3
0
    def test_get_geo_location_data(self):
        print("[!] Warning, the first part of this test is dependent on no server changes for example.org")
        with open('example_org_geo_location.json', 'r') as f:
            example_json = json.load(f)

        ig = InfoGetter('example.org')
        self.assertEqual(example_json, ig._get_geo_location_data(ig._get_ip(ig.url)))

        ig = InfoGetter('ahdsfdg.com')
        self.assertRaises(NoGeo, ig._get_geo_location_data, 'ASFKJA')

        # Clean
        os.rmdir(os.getcwd() + '/output/example - org')
        os.rmdir(os.getcwd() + '/output/ahdsfdg - com')
        os.rmdir(os.getcwd() + '/output')