mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-17 03:56:31 +01:00
added test for web socket authentication
This commit is contained in:
parent
c51fa60172
commit
b9e1ed7d7e
1 changed files with 25 additions and 0 deletions
25
src/paperless/tests/test_websockets.py
Normal file
25
src/paperless/tests/test_websockets.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
from channels.testing import WebsocketCommunicator
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from paperless.asgi import application
|
||||||
|
|
||||||
|
|
||||||
|
class TestWebSockets(TestCase):
|
||||||
|
|
||||||
|
async def test_no_auth(self):
|
||||||
|
communicator = WebsocketCommunicator(application, "/ws/status/")
|
||||||
|
connected, subprotocol = await communicator.connect()
|
||||||
|
self.assertFalse(connected)
|
||||||
|
await communicator.disconnect()
|
||||||
|
|
||||||
|
@mock.patch("paperless.consumers.StatusConsumer._authenticated")
|
||||||
|
async def test_auth(self, _authenticated):
|
||||||
|
_authenticated.return_value = True
|
||||||
|
|
||||||
|
communicator = WebsocketCommunicator(application, "/ws/status/")
|
||||||
|
connected, subprotocol = await communicator.connect()
|
||||||
|
self.assertTrue(connected)
|
||||||
|
|
||||||
|
await communicator.disconnect()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue