From 0d739f5c1a9d770a12fc6d18c06709f42ebfcd07 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 15 Nov 2021 16:41:37 +0100 Subject: [PATCH] recovery: add additional tests for commands Signed-off-by: Jens Langhammer --- authentik/recovery/tests.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/authentik/recovery/tests.py b/authentik/recovery/tests.py index b1f7886c8..eea5549b0 100644 --- a/authentik/recovery/tests.py +++ b/authentik/recovery/tests.py @@ -12,7 +12,7 @@ class TestRecovery(TestCase): """recovery tests""" 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): """Test creation of a new key""" @@ -35,3 +35,16 @@ class TestRecovery(TestCase): """Test recovery view with invalid token""" response = self.client.get(reverse("authentik_recovery:use-token", kwargs={"key": "abc"})) 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)