recovery: add additional tests for commands

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-15 16:41:37 +01:00
parent e08077c73a
commit 0d739f5c1a
1 changed files with 14 additions and 1 deletions

View File

@ -12,7 +12,7 @@ class TestRecovery(TestCase):
"""recovery tests""" """recovery tests"""
def setUp(self): def setUp(self):
self.user = User.objects.create_user(username="recovery-test-user") self.user: User = User.objects.create_user(username="recovery-test-user")
def test_create_key(self): def test_create_key(self):
"""Test creation of a new key""" """Test creation of a new key"""
@ -35,3 +35,16 @@ class TestRecovery(TestCase):
"""Test recovery view with invalid token""" """Test recovery view with invalid token"""
response = self.client.get(reverse("authentik_recovery:use-token", kwargs={"key": "abc"})) response = self.client.get(reverse("authentik_recovery:use-token", kwargs={"key": "abc"}))
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
def test_recovery_admin_group_invalid(self):
"""Test creation of admin group"""
out = StringIO()
call_command("create_admin_group", "1", stderr=out)
self.assertIn("not found", out.getvalue())
def test_recovery_admin_group(self):
"""Test creation of admin group"""
out = StringIO()
call_command("create_admin_group", self.user.username, stdout=out)
self.assertIn("successfully added to", out.getvalue())
self.assertTrue(self.user.is_superuser)