Skip to content

Commit

Permalink
added ip test
Browse files Browse the repository at this point in the history
added test for validation the ip so for the port forwardings
  • Loading branch information
agmes4 committed Sep 24, 2023
1 parent c565ca0 commit c00dcc8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,33 @@ def test_good_macs(self, mac, validatemac):
validatemac(mac)
except ValidationError:
pytest.fail()


class TestAddPortForwardForm:

@pytest.fixture(scope="class")
def validate_ip(self):
def validate_ip(ip):
form = forms.AddPortForwardForm(data={
"ip_address": ip, "source_port": 12, "dest_port": 12, "prot": "tcp"})
ip = form.ip_address

forms.ip_validatior(None, ip)
return validate_ip

@pytest.mark.parametrize(
"ip",
[
"1.1",
"0z:80:41:ae:fd:7e",
"0+:80:41:ae:fd:7e",
"awda ssfsfwa",
"a",
"ab",
"1000",
"1.6.7."
],
)
def test_bad_ip(self, ip, validate_ip):
with pytest.raises(ValidationError):
validate_ip(ip)

0 comments on commit c00dcc8

Please sign in to comment.