From 330d5047e7dc6d3c24359969c8ebffdc4a1c8507 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 31 Mar 2021 20:36:28 +0200 Subject: [PATCH] core: add tests for token API Signed-off-by: Jens Langhammer --- ...st_api.py => test_property_mapping_api.py} | 0 authentik/core/tests/test_token_api.py | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+) rename authentik/core/tests/{test_api.py => test_property_mapping_api.py} (100%) create mode 100644 authentik/core/tests/test_token_api.py diff --git a/authentik/core/tests/test_api.py b/authentik/core/tests/test_property_mapping_api.py similarity index 100% rename from authentik/core/tests/test_api.py rename to authentik/core/tests/test_property_mapping_api.py diff --git a/authentik/core/tests/test_token_api.py b/authentik/core/tests/test_token_api.py new file mode 100644 index 000000000..a22982ce3 --- /dev/null +++ b/authentik/core/tests/test_token_api.py @@ -0,0 +1,22 @@ +"""Test token API""" +from django.urls.base import reverse +from rest_framework.test import APITestCase + +from authentik.core.models import Token, User + + +class TestTokenAPI(APITestCase): + """Test token API""" + + def setUp(self) -> None: + super().setUp() + self.user = User.objects.get(username="akadmin") + self.client.force_login(self.user) + + def test_test_call(self): + """Test token creation endpoint""" + response = self.client.post( + reverse("authentik_api:token-list"), {"identifier": "test-token"} + ) + self.assertEqual(response.status_code, 201) + self.assertEqual(Token.objects.get(identifier="test-token").user, self.user)