diff --git a/app/wireguard/tests.py b/app/wireguard/tests.py index 2978de64290c690e7cc08ae478e562c1546b4b49..847606adb098a01c4119c7f685b147c577f82743 100644 --- a/app/wireguard/tests.py +++ b/app/wireguard/tests.py @@ -4,28 +4,33 @@ from django.contrib.auth.models import Group from guardian.shortcuts import assign_perm from . import models -class KeyDecodeerror(TestCase): - """Check pages load even if the key cannot be decoded""" +class WireguardTest(TestCase): + """Check keys are listed""" - def setUp(self): - self.toykey = models.SSHPublicKey.objects.create( - hostname="example.com", - keytype="", - key="no such thing", + def test_list_public(self): + """Check that public keys are listed""" + toykey = models.WireguardPublicKey.objects.create( + interface="example.com", + key="mykey", ) any_user = Group.objects.get(name="any-user") - assign_perm('view_sshpublickey', any_user, self.toykey) + assign_perm('view_wireguardpublickey', any_user, toykey) - def test_detail(self): - """Check that the detail page loads successfully""" response = self.client.get( - reverse('ssh-detail', args=[self.toykey.pk]) + reverse('wireguard-list') ) self.assertEqual(response.status_code, 200) + self.assertContains(response, toykey.key) + + def test_list_private(self): + """Check that private keys are not listed""" + toykey = models.WireguardPublicKey.objects.create( + interface="example.com", + key="mykey", + ) - def test_list(self): - """Check that the list page loads successfully""" response = self.client.get( - reverse('ssh-list') + reverse('wireguard-list') ) self.assertEqual(response.status_code, 200) + self.assertNotContains(response, toykey.key)