mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* 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 * Add sales email and phone contact to ix object #949 * Increase timeout timer for IX-F JSON importer to 30s #962 * IX-F manually triggered import bugs #1054 * remove survey notifications * IX-F importer: manual add followed by IX-F prompted add can result in "The server rejected your data" #807 * performance fix for net view * api documentation generate broken #956 * fix poc set missing from net view * Auto focus cursor on search field on main website #695 * PeeringDB website has a poor choice of line-breaks for IPv6 addresses. #748 * Delete childless org objects #838 * linting * poetry lock * re-add mistakingly dropped translation to email template * fix template variables * regen docs * regen api docs * add u2f api * fix merge cruft * fido u2f webauthn first steps * dont need this * typo * first ux steps for security key management, u2f views * u2f auth * linting * Cascade delete when performed by superuser in django-admin #735 * security key passwordless login * reset webauthn migrations * security key 2fa * linting * ux cleanup * cleanup * Add IXP to AS record / dropdown limited #469 * ignore orgs that have pre-dated or finished sponsorships attached * split out to django_security_keys * default to 90 days * make URL required for new objects #374 * move CONN_MAX_AGE to proper location and expose as env var (#1060) * Error message for invalid password on email change * Registering a new facility or exchange organization is broken #1062 * Creating a facility that matches the name of a soft-deleted facility will cause the entry to bypass the verification queue #901 * irr source validator doesn't allow for hyphens in source #921 * split out javascript * split out js * Clicking "Add" to add a user api-key without providing a name for the key raises Internal Error #1033 * remove security key admin views * global stats don't show up at login screen #284 * Possible for "pending" exchange to have "deleted" ixlan (#1077) * webauthn finalizations * oidc support for oauth provider #1070 * Revert "Merge branch 'gh_1070' into 'support_202111'" * remove unused dev mounts * linting * add django-security-key and relock poetry * re-add imports removed through linting * docs regen * oauth toolkit pinned to 1.6.1 django-security-keys pinned to 1.0.1 * remove debug message * linting * linting Co-authored-by: Stefan Pratter <stefan@20c.com> Co-authored-by: David Poarch <dpoarch@20c.com>
99 lines
3.3 KiB
Python
99 lines
3.3 KiB
Python
import json
|
|
|
|
import pytest
|
|
from rest_framework.test import APIClient, force_authenticate
|
|
|
|
from peeringdb_server.models import REFTAG_MAP, User
|
|
|
|
from .test_api import setup_module, teardown_module
|
|
from .util import ClientCase
|
|
|
|
|
|
class TestAPIClientCompat(ClientCase):
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
super().setUpTestData()
|
|
cls.superuser = User.objects.create_user(
|
|
"su", "su@localhost", "su", is_superuser=True
|
|
)
|
|
cls.org = REFTAG_MAP["org"].objects.create(name="Test Org", status="ok")
|
|
|
|
@property
|
|
def expected_compat_err_str(self):
|
|
return "Your client version is incompatible with server version of the api, please install peeringdb>={},<={} {}>={},<={}".format(
|
|
"0.6", "0.6.5", "django_peeringdb", "0.6", "0.6.5"
|
|
)
|
|
|
|
def _compat(self, ua_c, ua_be, error):
|
|
if ua_c and ua_be:
|
|
useragent = f"PeeringDB/{ua_c} django_peeringdb/{ua_be}"
|
|
self.client = APIClient(HTTP_USER_AGENT=useragent)
|
|
else:
|
|
self.client = APIClient()
|
|
self.client.force_authenticate(self.superuser)
|
|
|
|
org_id = self.org.id
|
|
print(self.org, self.org.id)
|
|
|
|
r = self.client.get(f"/api/org/{org_id}", format="json")
|
|
content = json.loads(r.content)
|
|
if error:
|
|
assert r.status_code == 400
|
|
assert content["meta"]["error"] == self.expected_compat_err_str
|
|
else:
|
|
assert r.status_code == 200
|
|
|
|
r = self.client.post(
|
|
"/api/net",
|
|
{
|
|
"org_id": org_id,
|
|
"name": "Test net",
|
|
"asn": 9000000,
|
|
"website": "https://www.example.com",
|
|
},
|
|
format="json",
|
|
)
|
|
content = json.loads(r.content)
|
|
print(content)
|
|
if error:
|
|
assert r.status_code == 400
|
|
assert content["meta"]["error"] == self.expected_compat_err_str
|
|
net = {"id": 1}
|
|
else:
|
|
assert r.status_code == 201
|
|
net = content["data"][0]
|
|
del net["org"]
|
|
|
|
r = self.client.put("/api/net/{}".format(net["id"]), net, format="json")
|
|
content = json.loads(r.content)
|
|
if error:
|
|
assert r.status_code == 400
|
|
assert content["meta"]["error"] == self.expected_compat_err_str
|
|
else:
|
|
assert r.status_code == 200
|
|
|
|
r = self.client.delete("/api/net/{}".format(net["id"]), {}, format="json")
|
|
if error:
|
|
content = json.loads(r.content)
|
|
assert r.status_code == 400
|
|
assert content["meta"]["error"] == self.expected_compat_err_str
|
|
else:
|
|
assert r.status_code == 204
|
|
|
|
REFTAG_MAP["net"].objects.all().delete()
|
|
|
|
def test_incompatible(self):
|
|
self._compat("0.5.0", "0.4.0", True)
|
|
self._compat("0.6.0", "0.5.0", True)
|
|
self._compat("0.5.0", "0.6.0", True)
|
|
self._compat("0.7.0", "0.6.0", True)
|
|
self._compat("0.6.0", "0.7.0", True)
|
|
|
|
def test_compatible(self):
|
|
self._compat("0.6.0", "0.6.0", False)
|
|
self._compat("0.6", "0.6", False)
|
|
self._compat("0.6.1", "0.6.1", False)
|
|
self._compat("0.6", "0.6.1", False)
|
|
self._compat("0.6.1", "0.6", False)
|
|
self._compat(None, None, False)
|