Exemplo n.º 1
0
    def _test_rpki_roas_per_provider(self, provider):
        cfg = ConfigParserGeneral()
        urls = cfg.get_schema(
        )["cfg"]["rpki_roas"]["ripe_rpki_validator_url"].default
        for url in urls:
            if provider in url:
                rpki_roas = RIPE_RPKI_ROAs(ripe_rpki_validator_url=[url],
                                           **cache_cfg)
                break
        rpki_roas.load_data()
        self.assertTrue(len(rpki_roas.roas) > 0)
        self.assertTrue(
            any([
                r for r in rpki_roas.roas["roas"]
                if r["prefix"] == "193.0.0.0/21"
            ]))

        allowed_per_ta = {}

        allowed_tas = cfg.get_schema(
        )["cfg"]["rpki_roas"]["allowed_trust_anchors"].default
        for roa in rpki_roas.roas["roas"]:
            ta = roa["ta"]
            if ta not in allowed_per_ta:
                allowed_per_ta[ta] = 0
            if roa["ta"] in allowed_tas:
                allowed_per_ta[ta] += 1

        tas_with_allowed_roas = 0
        for ta in allowed_per_ta:
            if allowed_per_ta[ta] > 0:
                tas_with_allowed_roas += 1

        self.assertTrue(tas_with_allowed_roas >= 4)
 def test_arin_db_dump(self):
     """External resources: ARIN Whois database dump"""
     cfg = ConfigParserGeneral()
     url = cfg.get_schema()["cfg"]["filtering"]["irrdb"]["use_arin_bulk_whois_data"]["source"].default
     db_dump = ARINWhoisDBDump(arin_whois_db_source=url, **cache_cfg)
     db_dump.load_data()
     self.assertTrue(len(db_dump.whois_records) > 0)
 def test_ripe_rpki_cache(self):
     """External resources: RIPE RPKI cache"""
     cfg = ConfigParserGeneral()
     url = cfg.get_schema()["cfg"]["rpki_roas"]["ripe_rpki_validator_url"].default
     ripe_rpki_cache = RIPE_RPKI_ROAs(ripe_rpki_validator_url=url, **cache_cfg)
     ripe_rpki_cache.load_data()
     self.assertTrue(len(ripe_rpki_cache.roas) > 0)
     self.assertTrue(any([r for r in ripe_rpki_cache.roas["roas"] if r["prefix"] == "193.0.0.0/21"]))