Skip to content

Commit

Permalink
Restore and fix test for spa-only view
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Nov 29, 2024
1 parent d17ec17 commit d2e267a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/auth/test_spa_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.conf import settings
from django.test import override_settings, tag

from rest_framework import status
from rest_framework.test import APIClient, APITestCase

from argus.auth.factories import AdminUserFactory, BaseUserFactory
from argus.util.testing import disconnect_signals, connect_signals


@tag("API", "integration", "spa")
@override_settings(
ROOT_URLCONF="argus.spa.root_urls",
)
class SpaViewTests(APITestCase):
def setUp(self):
disconnect_signals()
self.user = BaseUserFactory(username="user")

self.rest_client = APIClient()
self.rest_client.force_authenticate(user=self.user)

def teardown(self):
connect_signals()

@override_settings(
AUTHENTICATION_BACKENDS=[
"django.contrib.auth.backends.RemoteUserBackend",
"django.contrib.auth.backends.ModelBackend",
],
)
def test_can_get_login_methods(self):
response = self.rest_client.get(path="/login-methods/")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.data,
[
{"type": "username_password", "url": "http://testserver/api/v1/token-auth/", "name": "user_pw"},
],
)

0 comments on commit d2e267a

Please sign in to comment.