1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

Support 202109 (#1064)

* Block registering private ASN ranges

* Add a continental region field for facilities #1007

* Incorrect order of search results #232

* Allow users to upload a small logo to their record #346

* Sponsor badge CSS and text translation issues #453

* IXP and Facility summary #18

* poetry relock

* linting

* add libgcc

* lint

* bump version to 2.31.0-beta

Co-authored-by: Stefan Pratter <stefan@20c.com>
Co-authored-by: David Poarch <dpoarch@20c.com>
This commit is contained in:
Matt Griswold
2021-10-12 11:05:25 -05:00
committed by GitHub
parent 5d1f1c455d
commit 0c4ff0b2de
32 changed files with 1159 additions and 260 deletions

View File

@@ -14,9 +14,7 @@ import peeringdb_server.views as pdbviews
from .util import SettingsCase, reset_group_ids
ERR_COULD_NOT_GET_RIR_ENTRY = "This ASN is not assigned by any RIR"
ERR_BOGON_ASN = (
"RDAP Lookup Error: ASNs in this range are not allowed " "in this environment"
)
ERR_BOGON_ASN = "ASNs in this range are private or reserved"
RdapLookup_get_asn = pdbinet.RdapLookup.get_asn

View File

@@ -166,3 +166,46 @@ class SearchTests(TestCase):
assert unidecode.unidecode(rv[k][0]["name"]) == unidecode.unidecode(
inst.search_result_name
)
def test_search_asn_match(self):
"""
Test that exact numeric match on an ASN
always appears at the top of the results (#232)
"""
# network with asn 633 - this should be the first
# resut when searching for `633`
net_1 = models.Network.objects.create(
name="Test ASN Matching", asn=633, org=self.org, status="ok"
)
# network with asn 6333, this should match, but not
# be the first result
net_2 = models.Network.objects.create(
name="Test ASN Matching 2", asn=6333, org=self.org, status="ok"
)
# network with asn 6334 and 633 as part of its name
# this should score high, but should not be the first
# result
net_3 = models.Network.objects.create(
name="Test ASN 633 Matching", asn=6334, org=self.org, status="ok"
)
# rebuild the index
call_command("rebuild_index", "--noinput")
rv = search.search("633")
assert rv["net"][0]["id"] == net_1.id
# clean up
net_1.delete(hard=True)
net_2.delete(hard=True)
net_3.delete(hard=True)
call_command("rebuild_index", "--noinput")

View File

@@ -185,3 +185,18 @@ def test_poc_update(entities):
assert network.netixlan_updated is None
assert network.netfac_updated is None
assert_same_time(network.updated, two_weeks_ago())
@pytest.mark.django_db
def test_region_continent(entities):
org = Organization.objects.first()
fac = Facility.objects.first()
fac.org = org
fac.country.code = "US"
with reversion.create_revision():
fac.save()
assert fac.region_continent == "North America"

View File

@@ -6,8 +6,17 @@ from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.management import call_command
from peeringdb_server.models import REFTAG_MAP, UTC, Network
from peeringdb_server.stats import stats
from peeringdb_server.models import (
REFTAG_MAP,
UTC,
Facility,
InternetExchange,
InternetExchangeFacility,
Network,
NetworkFacility,
NetworkIXLan,
)
from peeringdb_server.stats import get_fac_stats, get_ix_stats, stats
from .util import ClientCase, Group, override_group_id
@@ -87,3 +96,78 @@ def test_global_stats(db, data_stats_global):
global_stats = stats()
assert global_stats == data_stats_global.expected
@pytest.mark.django_db
def test_ix_fac_stats(db, data_stats_global):
setup_data()
exchange = InternetExchange.objects.first()
netixlan = (
NetworkIXLan.handleref.undeleted()
.select_related("network", "ixlan")
.order_by("network__name")
.filter(ixlan__ix=exchange)
)
ixlan = exchange.ixlan
ix_stats = get_ix_stats(netixlan, ixlan)
ipv6_percentage = 0
total_speed = 0
for n in netixlan.filter(status="ok", ixlan=ixlan):
total_speed += n.speed
try:
ipv6_percentage = int(
(
netixlan.filter(status="ok", ixlan=ixlan, ipaddr6__isnull=False).count()
/ netixlan.filter(ixlan=ixlan, status="ok").count()
)
* 100
)
except ZeroDivisionError:
pass
assert (
ix_stats["peer_count"]
== netixlan.values("network").distinct().filter(status="ok").count()
)
assert (
ix_stats["connection_count"]
== netixlan.filter(ixlan=ixlan, status="ok").count()
)
assert ix_stats["open_peer_count"] == (
netixlan.values("network")
.distinct()
.filter(network__policy_general="Open", status="ok")
.count()
)
assert ix_stats["ipv6_percentage"] == ipv6_percentage
assert ix_stats["total_speed"] == total_speed
facility = Facility.objects.first()
ixfac = (
InternetExchangeFacility.handleref.undeleted()
.filter(facility=facility)
.select_related("ix")
.order_by("ix__name")
.all()
)
netfac = (
NetworkFacility.handleref.undeleted()
.filter(facility=facility)
.select_related("network")
.order_by("network__name")
)
fac_stats = get_fac_stats(netfac, ixfac)
assert fac_stats["networks"] == netfac.filter(status="ok").count()
assert fac_stats["ix"] == ixfac.filter(status="ok").count()

View File

@@ -147,7 +147,7 @@ def test_signup_page():
assert response.status_code == 200
# test fallback captcha load
m = re.search("\/captcha\/image\/([^\/]+)\/", content)
m = re.search(r"\/captcha\/image\/([^\/]+)\/", content)
assert m
response = client.get(m[0])
assert response.status_code == 200