def test_validate_info_prefixes6(): """ Tests peeringdb_server.validators.validate_info_prefixes6 """ with pytest.raises(ValidationError): validate_info_prefixes6(500001) with pytest.raises(ValidationError): validate_info_prefixes6(-1) validate_info_prefixes6(500000) assert validate_info_prefixes6(None) == 0 assert validate_info_prefixes6("") == 0
def test_validate_info_prefixes6(): """ Tests peeringdb_server.validators.validate_info_prefixes6 """ with pytest.raises(ValidationError): validate_info_prefixes6(500001) with pytest.raises(ValidationError): validate_info_prefixes6(-1) validate_info_prefixes6(500000)
def test_bypass_validation(): User = get_user_model() superuser = User.objects.create_user( username="******", password="******", email="su@localhost", is_superuser=True, ) user = User.objects.create_user(username="******", password="******", email="user@localhost") factory = RequestFactory() org = Organization.objects.create(name="Test org", status="ok") ix = InternetExchange.objects.create( name="Text exchange", status="ok", org=org, country="US", city="Some city", region_continent="North America", media="Ethernet", ) net = Network.objects.create(name="Text network", asn=12345, status="ok", org=org) # super user should bypass validation request = factory.get("/") request.user = superuser with current_request(request): validate_address_space("37.77.32.0/20") validate_address_space("131.72.77.240/28") validate_address_space("2403:c240::/32") validate_address_space("2001:504:0:2::/64") validate_info_prefixes4(500001) validate_info_prefixes6(500001) NetworkIXLan(speed=1, network=net, ixlan=ix.ixlan).clean() NetworkIXLan(speed=1000, network=net, ixlan=ix.ixlan).clean() validate_irr_as_set("ripe::as-foo:as123:as345:as678") # user should NOT bypass validation request = factory.get("/") request.user = user with current_request(request): with pytest.raises(ValidationError): validate_address_space("37.77.32.0/20") with pytest.raises(ValidationError): validate_address_space("131.72.77.240/28") with pytest.raises(ValidationError): validate_address_space("2403:c240::/32") with pytest.raises(ValidationError): validate_address_space("2001:504:0:2::/64") with pytest.raises(ValidationError): validate_info_prefixes4(500001) with pytest.raises(ValidationError): validate_info_prefixes6(500001) with pytest.raises(ValidationError): NetworkIXLan(speed=1, network=net, ixlan=ix.ixlan).clean() with pytest.raises(ValidationError): NetworkIXLan(speed=1000, network=net, ixlan=ix.ixlan).clean() with pytest.raises(ValidationError): validate_irr_as_set("ripe::as-foo:as123:as345:as678")