mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-11 20:57:49 +02:00
Add basic fail2ban support (#847)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import path, include
|
||||
|
||||
from bookmarks.tests.helpers import HtmlTestMixin
|
||||
from bookmarks.tests.helpers import BookmarkFactoryMixin, HtmlTestMixin
|
||||
from siteroot.urls import urlpatterns as base_patterns
|
||||
|
||||
# Register OIDC urls for this test, otherwise login template can not render when OIDC is enabled
|
||||
@@ -9,7 +9,19 @@ urlpatterns = base_patterns + [path("oidc/", include("mozilla_django_oidc.urls")
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF=__name__)
|
||||
class LoginViewTestCase(TestCase, HtmlTestMixin):
|
||||
class LoginViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
||||
|
||||
def test_failed_login_should_return_401(self):
|
||||
response = self.client.post("/login/", {"username": "test", "password": "test"})
|
||||
self.assertEqual(response.status_code, 401)
|
||||
|
||||
def test_successful_login_should_redirect(self):
|
||||
user = self.setup_user(name="test")
|
||||
user.set_password("test")
|
||||
user.save()
|
||||
|
||||
response = self.client.post("/login/", {"username": "test", "password": "test"})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_should_not_show_oidc_login_by_default(self):
|
||||
response = self.client.get("/login/")
|
||||
|
Reference in New Issue
Block a user