mirror of
https://github.com/SaraSmiseth/prosody.git
synced 2025-04-19 16:01:14 +00:00
wip tests 6
This commit is contained in:
parent
42401df95e
commit
d064d7b3de
3 changed files with 54 additions and 12 deletions
|
@ -14,7 +14,7 @@ services:
|
|||
DOMAIN: localhost
|
||||
#E2E_POLICY_CHAT: optional
|
||||
#E2E_POLICY_MUC: optional
|
||||
E2E_POLICY_WHITELIST: "admin@localhost"
|
||||
E2E_POLICY_WHITELIST: "admin@localhost, user1@localhost"
|
||||
LOG_LEVEL: debug
|
||||
PROSODY_ADMINS: "admin@localhost, admin2@localhost"
|
||||
extra_hosts:
|
||||
|
|
|
@ -25,8 +25,9 @@ sudo docker-compose down \
|
|||
&& sudo docker-compose up -d \
|
||||
\
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register admin localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user1 localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user2 localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user3 localhost 12345678" \
|
||||
\
|
||||
&& python -m venv venv \
|
||||
&& source venv/bin/activate \
|
||||
|
@ -37,6 +38,9 @@ sudo docker-compose down \
|
|||
&& sudo docker-compose logs | grep "message to" \
|
||||
&& sudo docker-compose logs | grep "type='error'"
|
||||
|
||||
# Received[c2s]: <message to='*@localhost' * type='chat'>
|
||||
# Should be five times in log
|
||||
|
||||
# TODO Call bats and create tests to check log output
|
||||
|
||||
sudo docker-compose down
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import aiosasl
|
||||
import aioxmpp
|
||||
import aioxmpp.dispatcher
|
||||
import asyncio
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def client(client_username):
|
||||
def client(client_username, password):
|
||||
|
||||
jid = aioxmpp.JID.fromstr(client_username)
|
||||
password = "12345678"
|
||||
|
||||
client = aioxmpp.PresenceManagedClient(
|
||||
jid,
|
||||
|
@ -39,9 +39,9 @@ def client_with_message_dispatcher(client):
|
|||
return client
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username", ["admin@localhost"])
|
||||
async def test_send_message_from_admin_to_user(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("user@localhost")
|
||||
@pytest.mark.parametrize("client_username, password", [("admin@localhost", "12345678")])
|
||||
async def test_send_message_from_admin_to_user1(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("user1@localhost")
|
||||
async with client.connected() as stream:
|
||||
msg = aioxmpp.Message(
|
||||
to=recipient_jid,
|
||||
|
@ -53,7 +53,7 @@ async def test_send_message_from_admin_to_user(client):
|
|||
await client.send(msg)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username", ["admin@localhost"])
|
||||
@pytest.mark.parametrize("client_username, password", [("admin@localhost", "12345678")])
|
||||
async def test_send_message_from_admin_to_user2(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("user2@localhost")
|
||||
async with client.connected() as stream:
|
||||
|
@ -61,21 +61,59 @@ async def test_send_message_from_admin_to_user2(client):
|
|||
to=recipient_jid,
|
||||
type_=aioxmpp.MessageType.CHAT,
|
||||
)
|
||||
# None is for "default language"
|
||||
msg.body[None] = "Hello World!"
|
||||
|
||||
await client.send(msg)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username", ["user@localhost"])
|
||||
async def test_send_message_from_user_to_user2(client):
|
||||
@pytest.mark.parametrize("client_username, password", [("user1@localhost", "12345678")])
|
||||
async def test_send_message_from_user1_to_user2(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("user2@localhost")
|
||||
async with client.connected() as stream:
|
||||
msg = aioxmpp.Message(
|
||||
to=recipient_jid,
|
||||
type_=aioxmpp.MessageType.CHAT,
|
||||
)
|
||||
# None is for "default language"
|
||||
msg.body[None] = "Hello World!"
|
||||
|
||||
await client.send(msg)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username, password", [("user2@localhost", "12345678")])
|
||||
async def test_send_message_from_user2_to_user3(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("user3@localhost")
|
||||
async with client.connected() as stream:
|
||||
msg = aioxmpp.Message(
|
||||
to=recipient_jid,
|
||||
type_=aioxmpp.MessageType.CHAT,
|
||||
)
|
||||
msg.body[None] = "Hello World!"
|
||||
|
||||
await client.send(msg)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username, password", [("user2@localhost", "12345678")])
|
||||
async def test_send_message_from_user2_to_nonexisting(client):
|
||||
recipient_jid = aioxmpp.JID.fromstr("nonexisting@localhost")
|
||||
async with client.connected() as stream:
|
||||
msg = aioxmpp.Message(
|
||||
to=recipient_jid,
|
||||
type_=aioxmpp.MessageType.CHAT,
|
||||
)
|
||||
msg.body[None] = "Hello World!"
|
||||
|
||||
await client.send(msg)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("client_username, password", [("user2@localhost", "wrong password")])
|
||||
async def test_can_not_log_in_with_wrong_password(client):
|
||||
with pytest.raises(aiosasl.AuthenticationFailure):
|
||||
recipient_jid = aioxmpp.JID.fromstr("nonexisting@localhost")
|
||||
async with client.connected() as stream:
|
||||
msg = aioxmpp.Message(
|
||||
to=recipient_jid,
|
||||
type_=aioxmpp.MessageType.CHAT,
|
||||
)
|
||||
msg.body[None] = "Hello World!"
|
||||
|
||||
await client.send(msg)
|
||||
|
|
Loading…
Reference in a new issue