Adds testing for unauthenticated API calls, simplify logging logic

This commit is contained in:
shamoon
2023-06-03 08:50:54 -07:00
parent aaf2ba2ba0
commit e9e1483685
2 changed files with 31 additions and 11 deletions

View File

@@ -12,6 +12,26 @@ class TestFailedLoginLogging(TestCase):
"username": "john lennon",
}
def test_unauthenticated(self):
"""
GIVEN:
- Request with no authentication provided
WHEN:
- Request provided to signal handler
THEN:
- Unable to determine logged for unauthenticated user
"""
request = HttpRequest()
request.META = {}
with self.assertLogs("paperless.auth") as logs:
handle_failed_login(None, {}, request)
self.assertEqual(
logs.output,
[
"INFO:paperless.auth:No authentication provided. Unable to determine IP address.",
],
)
def test_none(self):
"""
GIVEN: