From af4f0a48ed0888f346ea637a46f5059d03538162 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 8 Jan 2025 23:09:38 +0100 Subject: [PATCH] move buildin token test --- src/backend/InvenTree/InvenTree/test_auth.py | 19 +++++++++++++++++++ src/backend/InvenTree/users/test_api.py | 12 ------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/test_auth.py b/src/backend/InvenTree/InvenTree/test_auth.py index cd6e00dd47..091121be84 100644 --- a/src/backend/InvenTree/InvenTree/test_auth.py +++ b/src/backend/InvenTree/InvenTree/test_auth.py @@ -143,6 +143,25 @@ class EmailSettingsContext: class TestAuth(InvenTreeAPITestCase): """Test authentication functionality.""" + def test_buildin_token(self): + """Test the built-in token authentication.""" + self.logout() + response = self.post( + '/api/auth/v1/auth/login', + {'username': self.username, 'password': self.password}, + expected_code=200, + ) + data = response.json() + self.assertIn('meta', data) + self.assertTrue(data['meta']['is_authenticated']) + + # Test for conflicting login + self.post( + '/api/auth/v1/auth/login', + {'username': self.username, 'password': self.password}, + expected_code=409, + ) + def email_args(self, user=None, email=None): """Generate registration arguments.""" return { diff --git a/src/backend/InvenTree/users/test_api.py b/src/backend/InvenTree/users/test_api.py index d812aa96cd..b57b97e965 100644 --- a/src/backend/InvenTree/users/test_api.py +++ b/src/backend/InvenTree/users/test_api.py @@ -1,7 +1,6 @@ """API tests for various user / auth API endpoints.""" import datetime -import unittest from django.contrib.auth.models import Group, User from django.urls import reverse @@ -207,17 +206,6 @@ class UserTokenTests(InvenTreeAPITestCase): self.client.get(me, expected_code=200) - @unittest.skip - def test_buildin_token(self): - """Test the built-in token authentication.""" - response = self.post( - reverse('rest_login'), - {'username': self.username, 'password': self.password}, - expected_code=200, - ) - self.assertIn('key', response.data) - self.assertTrue(response.data['key'].startswith('inv-')) - def test_token_api(self): """Test the token API.""" url = reverse('api-token-list')