recovery: add additional tests for commands
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
e08077c73a
commit
0d739f5c1a
|
@ -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)
|
||||||
|
|
Reference in New Issue