mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 12:35:46 +00:00
move buildin token test
This commit is contained in:
@ -143,6 +143,25 @@ class EmailSettingsContext:
|
|||||||
class TestAuth(InvenTreeAPITestCase):
|
class TestAuth(InvenTreeAPITestCase):
|
||||||
"""Test authentication functionality."""
|
"""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):
|
def email_args(self, user=None, email=None):
|
||||||
"""Generate registration arguments."""
|
"""Generate registration arguments."""
|
||||||
return {
|
return {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""API tests for various user / auth API endpoints."""
|
"""API tests for various user / auth API endpoints."""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import unittest
|
|
||||||
|
|
||||||
from django.contrib.auth.models import Group, User
|
from django.contrib.auth.models import Group, User
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -207,17 +206,6 @@ class UserTokenTests(InvenTreeAPITestCase):
|
|||||||
|
|
||||||
self.client.get(me, expected_code=200)
|
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):
|
def test_token_api(self):
|
||||||
"""Test the token API."""
|
"""Test the token API."""
|
||||||
url = reverse('api-token-list')
|
url = reverse('api-token-list')
|
||||||
|
Reference in New Issue
Block a user