mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 20:15:44 +00:00
move buildin token test
This commit is contained in:
@ -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 {
|
||||
|
@ -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')
|
||||
|
Reference in New Issue
Block a user