|
@@ -32,43 +32,52 @@ class VPNTestCase(TestCase):
|
|
|
v4 = IPSubnet(ip_pool=self.v4_pool, offer_subscription=abo)
|
|
|
v4.full_clean()
|
|
|
v4.save()
|
|
|
- vpn = VPNSubscription(administrative_subscription=abo,
|
|
|
- login=cn + "_vpn",
|
|
|
- password="tata")
|
|
|
+ vpn = VPNSubscription(administrative_subscription=abo)
|
|
|
vpn.full_clean()
|
|
|
vpn.save()
|
|
|
|
|
|
+ # Create additional VPN, they should automatically be attributed a
|
|
|
+ # new login.
|
|
|
+ for i in range(5):
|
|
|
+ abo = OfferSubscription(offer=self.offer, member=self.member)
|
|
|
+ abo.full_clean()
|
|
|
+ abo.save()
|
|
|
+ vpn = VPNSubscription(administrative_subscription=abo)
|
|
|
+ vpn.full_clean()
|
|
|
+ vpn.save()
|
|
|
+
|
|
|
def tearDown(self):
|
|
|
"""Properly clean up objects, so that they don't stay in LDAP"""
|
|
|
- VPNSubscription.objects.get().delete()
|
|
|
+ for vpn in VPNSubscription.objects.all():
|
|
|
+ vpn.delete()
|
|
|
Member.objects.get().delete()
|
|
|
|
|
|
def test_has_ipv4_endpoint(self):
|
|
|
- vpn = VPNSubscription.objects.get()
|
|
|
+ vpn = VPNSubscription.objects.all()[0]
|
|
|
self.assertIsNotNone(vpn.ipv4_endpoint)
|
|
|
|
|
|
def test_has_correct_ipv4_endpoint(self):
|
|
|
"""If there is not endpoint, we consider it to be correct."""
|
|
|
- vpn = VPNSubscription.objects.get()
|
|
|
+ vpn = VPNSubscription.objects.all()[0]
|
|
|
if vpn.ipv4_endpoint is not None:
|
|
|
- abo = OfferSubscription.objects.get()
|
|
|
+ abo = vpn.administrative_subscription
|
|
|
subnet = abo.ip_subnet.get(ip_pool=self.v4_pool)
|
|
|
self.assertIn(vpn.ipv4_endpoint, subnet.inet)
|
|
|
|
|
|
def test_has_ipv6_endpoint(self):
|
|
|
- vpn = VPNSubscription.objects.get()
|
|
|
+ vpn = VPNSubscription.objects.all()[0]
|
|
|
self.assertIsNotNone(vpn.ipv6_endpoint)
|
|
|
|
|
|
def test_has_correct_ipv6_endpoint(self):
|
|
|
"""If there is not endpoint, we consider it to be correct."""
|
|
|
- vpn = VPNSubscription.objects.get()
|
|
|
+ vpn = VPNSubscription.objects.all()[0]
|
|
|
if vpn.ipv6_endpoint is not None:
|
|
|
- abo = OfferSubscription.objects.get()
|
|
|
+ abo = vpn.administrative_subscription
|
|
|
subnet = abo.ip_subnet.get(ip_pool=self.v6_pool)
|
|
|
self.assertIn(vpn.ipv6_endpoint, subnet.inet)
|
|
|
|
|
|
def test_change_v4subnet_is_vpn_endpoint_correct(self):
|
|
|
- abo = OfferSubscription.objects.get()
|
|
|
+ abo = OfferSubscription.objects.all()[0]
|
|
|
subnet = abo.ip_subnet.get(ip_pool=self.v4_pool)
|
|
|
subnet.inet = "192.168.42.42/31"
|
|
|
subnet.full_clean()
|
|
@@ -76,9 +85,18 @@ class VPNTestCase(TestCase):
|
|
|
self.test_has_correct_ipv4_endpoint()
|
|
|
|
|
|
def test_change_v6subnet_is_vpn_endpoint_correct(self):
|
|
|
- abo = OfferSubscription.objects.get()
|
|
|
+ abo = OfferSubscription.objects.all()[0]
|
|
|
subnet = abo.ip_subnet.get(ip_pool=self.v6_pool)
|
|
|
subnet.inet = "2001:db8:4242:4200::/56"
|
|
|
subnet.full_clean()
|
|
|
subnet.save()
|
|
|
self.test_has_correct_ipv6_endpoint()
|
|
|
+
|
|
|
+ def test_automatic_login(self):
|
|
|
+ vpn = VPNSubscription.objects.all()[0]
|
|
|
+ expected_login = vpn.administrative_subscription.member.ldap_cn + "-vpn1"
|
|
|
+ self.assertEqual(vpn.login, expected_login)
|
|
|
+
|
|
|
+ def test_has_multiple_vpn(self):
|
|
|
+ vpns = VPNSubscription.objects.all()
|
|
|
+ self.assertEqual(len(vpns), 6)
|