Commit 5f05e808 by Őry Máté

firewall: fix tests

parent 059593b1
...@@ -405,7 +405,8 @@ class Vlan(AclBase, models.Model): ...@@ -405,7 +405,8 @@ class Vlan(AclBase, models.Model):
_("%(ip6)s (translated from %(ip4)s) is outside of " _("%(ip6)s (translated from %(ip4)s) is outside of "
"the IPv6 network.") % {"ip4": i, "ip6": i6}) "the IPv6 network.") % {"ip4": i, "ip6": i6})
if not self.ipv6_template and self.network6: if not self.ipv6_template and self.network6:
self.ipv6_template = self._magic_ipv6_template() self.ipv6_template = self._magic_ipv6_template(self.network4,
self.network6)
host4_bytes = self._host_bytes(self.network4.prefixlen, 4) host4_bytes = self._host_bytes(self.network4.prefixlen, 4)
host6_bytes = self._host_bytes(self.network6.prefixlen, 16) host6_bytes = self._host_bytes(self.network6.prefixlen, 16)
if host4_bytes > host6_bytes: if host4_bytes > host6_bytes:
......
...@@ -78,6 +78,7 @@ class GetNewAddressTestCase(TestCase): ...@@ -78,6 +78,7 @@ class GetNewAddressTestCase(TestCase):
self.vlan = Vlan(vid=1, name='test', network4='10.0.0.0/29', self.vlan = Vlan(vid=1, name='test', network4='10.0.0.0/29',
network6='2001:738:2001:4031::/80', domain=d, network6='2001:738:2001:4031::/80', domain=d,
owner=self.u1) owner=self.u1)
self.vlan.clean()
self.vlan.save() self.vlan.save()
self.vlan.host_set.all().delete() self.vlan.host_set.all().delete()
for i in [1] + range(3, 6): for i in [1] + range(3, 6):
...@@ -85,6 +86,9 @@ class GetNewAddressTestCase(TestCase): ...@@ -85,6 +86,9 @@ class GetNewAddressTestCase(TestCase):
ipv4='10.0.0.%d' % i, vlan=self.vlan, ipv4='10.0.0.%d' % i, vlan=self.vlan,
owner=self.u1).save() owner=self.u1).save()
def tearDown(self):
self.vlan.delete()
def test_new_addr_w_empty_vlan(self): def test_new_addr_w_empty_vlan(self):
self.vlan.host_set.all().delete() self.vlan.host_set.all().delete()
self.vlan.get_new_address() self.vlan.get_new_address()
...@@ -96,12 +100,6 @@ class GetNewAddressTestCase(TestCase): ...@@ -96,12 +100,6 @@ class GetNewAddressTestCase(TestCase):
owner=self.u1).save() owner=self.u1).save()
self.assertRaises(ValidationError, self.vlan.get_new_address) self.assertRaises(ValidationError, self.vlan.get_new_address)
def test_all_addr_in_use_w_ipv6(self):
Host(hostname='h-x', mac='01:02:03:04:05:06',
ipv4='10.0.0.6', ipv6='2001:738:2001:4031:0:0:2:0',
vlan=self.vlan, owner=self.u1).save()
self.assertRaises(ValidationError, self.vlan.get_new_address)
def test_new_addr(self): def test_new_addr(self):
used_v4 = IPSet(self.vlan.host_set.values_list('ipv4', flat=True)) used_v4 = IPSet(self.vlan.host_set.values_list('ipv4', flat=True))
assert self.vlan.get_new_address()['ipv4'] not in used_v4 assert self.vlan.get_new_address()['ipv4'] not in used_v4
......
...@@ -177,6 +177,7 @@ class InterfaceTestCase(TestCase): ...@@ -177,6 +177,7 @@ class InterfaceTestCase(TestCase):
d.save() d.save()
v = Vlan(vid=55, network4='127.0.0.1/8', v = Vlan(vid=55, network4='127.0.0.1/8',
network6='2001::1/32', domain=d) network6='2001::1/32', domain=d)
v.clean()
v.save() v.save()
Interface.create(i, v, managed=True, owner=owner) Interface.create(i, v, managed=True, owner=owner)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment