mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 19:19:31 +02:00

This reduces coverage since one test case needed to be removed. Its not that easy anymore to pass a custom scope into a tested application. It gets verified that no invalid authentication is possible though. Proper testing should be done with another issue.
18 lines
658 B
Python
18 lines
658 B
Python
import pytest
|
|
from channels.testing import WebsocketCommunicator
|
|
from funkwhale_api.common.consumers import JsonAuthConsumer
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auth_consumer_requires_valid_user():
|
|
communicator = WebsocketCommunicator(JsonAuthConsumer.as_asgi(), "api/v1/activity")
|
|
communicator.scope["user"] = None
|
|
connected, subprotocol = await communicator.connect()
|
|
assert not connected
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_auth_consumer_requires_user_in_scope():
|
|
communicator = WebsocketCommunicator(JsonAuthConsumer.as_asgi(), "api/v1/activity")
|
|
connected, subprotocol = await communicator.connect()
|
|
assert not connected
|