Example #1
0
    def test__RDAPLookup(self):

        data_dir = path.dirname(__file__)

        with io.open(str(data_dir) + '/rdap.json', 'r') as data_file:
            data = json.load(data_file)

        for key, val in data.items():

            log.debug('Testing: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(obj.lookup(response=val['response'],
                                                 asn_data=val['asn_data'],
                                                 depth=0), dict)

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: %r' % e)
Example #2
0
    def test_lookup(self):

        data_dir = path.abspath(path.join(path.dirname(__file__), '..'))

        with io.open(str(data_dir) + '/rdap.json', 'r') as data_file:
            data = json.load(data_file)

        for key, val in data.items():

            log.debug('Testing: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(obj.lookup(asn_data=val['asn_data'],
                                                 depth=1), dict)

            except (HTTPLookupError, HTTPRateLimitError):

                pass

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))

        for key, val in data.items():

            log.debug('Testing bootstrap and raw: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(obj.lookup(asn_data=val['asn_data'],
                                                 depth=3,
                                                 bootstrap=True,
                                                 inc_raw=True), dict)

            except (HTTPLookupError, HTTPRateLimitError):

                pass

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))
Example #3
0
    def test_lookup(self):

        data_dir = path.dirname(__file__)

        with io.open(str(data_dir) + '/rdap.json', 'r') as data_file:
            data = json.load(data_file)

        for key, val in data.items():

            log.debug('Testing: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(
                    obj.lookup(response=val['response'],
                               asn_data=val['asn_data'],
                               depth=0), dict)

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))

            self.assertRaises(NetError, RDAP, 'a')

        for key, val in data.items():

            log.debug('Testing bootstrap and raw: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(
                    obj.lookup(response=val['response'],
                               asn_data=val['asn_data'],
                               depth=0,
                               bootstrap=True,
                               inc_raw=True), dict)

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))

            break

        log.debug('Testing rdap.lookup response checks')
        net = Net('74.125.225.229')
        obj = RDAP(net)
        self.assertIsInstance(
            obj.lookup(response={
                'handle': 'test',
                'ipVersion': 'v4',
                'startAddress': '74.125.225.229',
                'endAddress': '74.125.225.229'
            },
                       asn_data=val['asn_data'],
                       depth=0), dict)

        log.debug('Testing rdap.lookup entitiy checks')
        net = Net('74.125.225.229')
        obj = RDAP(net)
        entity = [{
            'handle':
            'test',
            'roles': ['administrative', 'technical'],
            'entities': [{
                'handle': 'GOGL',
                'roles': ['administrative', 'technical']
            }]
        }]

        self.assertIsInstance(
            obj.lookup(response={
                'handle': 'test',
                'ipVersion': 'v4',
                'startAddress': '74.125.225.229',
                'endAddress': '74.125.225.229',
                'entities': entity
            },
                       asn_data=val['asn_data'],
                       depth=1), dict)

        self.assertIsInstance(
            obj.lookup(response={
                'handle': 'test',
                'ipVersion': 'v4',
                'startAddress': '74.125.225.229',
                'endAddress': '74.125.225.229',
                'entities': entity
            },
                       asn_data=val['asn_data'],
                       depth=1,
                       bootstrap=True,
                       inc_raw=True), dict)

        # No sub entities. This is for coverage, but won't error out.
        entity = [{'handle': 'test', 'roles': ['administrative', 'technical']}]

        self.assertIsInstance(
            obj.lookup(response={
                'handle': 'test',
                'ipVersion': 'v4',
                'startAddress': '74.125.225.229',
                'endAddress': '74.125.225.229',
                'entities': entity
            },
                       asn_data=val['asn_data'],
                       depth=1), dict)
Example #4
0
    def test__RDAPLookup(self):

        data_dir = path.dirname(__file__)

        with io.open(str(data_dir) + '/rdap.json', 'r') as data_file:
            data = json.load(data_file)

        for key, val in data.items():

            log.debug('Testing: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(obj.lookup(response=val['response'],
                                                 asn_data=val['asn_data'],
                                                 depth=0), dict)

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))

            self.assertRaises(NetError, RDAP, 'a')

        for key, val in data.items():

            log.debug('Testing bootstrap and raw: {0}'.format(key))
            net = Net(key)
            obj = RDAP(net)

            try:

                self.assertIsInstance(obj.lookup(response=val['response'],
                                                 asn_data=val['asn_data'],
                                                 depth=0,
                                                 bootstrap=True,
                                                 inc_raw=True), dict)

            except AssertionError as e:

                raise e

            except Exception as e:

                self.fail('Unexpected exception raised: {0}'.format(e))

            break

        log.debug('Testing rdap.lookup response checks')
        net = Net('74.125.225.229')
        obj = RDAP(net)
        self.assertIsInstance(obj.lookup(response={
                                             'handle': 'test',
                                             'ipVersion': 'v4',
                                             'startAddress': '74.125.225.229',
                                             'endAddress': '74.125.225.229'
                                         },
                                         asn_data=val['asn_data'],
                                         depth=0), dict)

        log.debug('Testing rdap.lookup entitiy checks')
        net = Net('74.125.225.229')
        obj = RDAP(net)
        entity = [{'handle': 'test', 'roles': [
            'administrative', 'technical'], 'entities': [
            {'handle': 'GOGL', 'roles': ['administrative', 'technical']}]}]

        self.assertIsInstance(obj.lookup(response={
                                             'handle': 'test',
                                             'ipVersion': 'v4',
                                             'startAddress': '74.125.225.229',
                                             'endAddress': '74.125.225.229',
                                             'entities': entity
                                         },
                                         asn_data=val['asn_data'],
                                         depth=1), dict)

        self.assertIsInstance(obj.lookup(response={
                                             'handle': 'test',
                                             'ipVersion': 'v4',
                                             'startAddress': '74.125.225.229',
                                             'endAddress': '74.125.225.229',
                                             'entities': entity
                                         },
                                         asn_data=val['asn_data'],
                                         depth=1,
                                         bootstrap=True,
                                         inc_raw=True), dict)