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)