mirror of
https://github.com/SaraSmiseth/prosody.git
synced 2025-04-19 16:01:14 +00:00
wip tests 2
This commit is contained in:
parent
5ba200af3d
commit
c8d5367408
4 changed files with 73 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
data/*
|
||||
tests/certs/
|
||||
tests/venv/
|
||||
|
|
|
@ -11,13 +11,16 @@ services:
|
|||
- "5269:5269"
|
||||
- "5281:5281"
|
||||
environment:
|
||||
DOMAIN: prosody
|
||||
PROSODY_ADMINS: "admin@prosody, admin2@prosody"
|
||||
DOMAIN: localhost
|
||||
E2E_POLICY_CHAT: optional
|
||||
E2E_POLICY_MUC: optional
|
||||
LOG_LEVEL: debug
|
||||
PROSODY_ADMINS: "admin@localhost, admin2@localhost"
|
||||
extra_hosts:
|
||||
- "conference.prosody:127.0.0.1"
|
||||
- "pubsub.prosody:127.0.0.1"
|
||||
- "proxy.prosody:127.0.0.1"
|
||||
- "upload.prosody:127.0.0.1"
|
||||
- "conference.localhost:127.0.0.1"
|
||||
- "pubsub.localhost:127.0.0.1"
|
||||
- "proxy.localhost:127.0.0.1"
|
||||
- "upload.localhost:127.0.0.1"
|
||||
volumes:
|
||||
- ./certs:/usr/local/etc/prosody/certs
|
||||
#- ./data:/usr/local/var/lib/prosody
|
||||
|
|
50
tests/test.py
Normal file
50
tests/test.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
import asyncio
|
||||
import aioxmpp
|
||||
import aioxmpp.dispatcher
|
||||
|
||||
jid = aioxmpp.JID.fromstr("admin@localhost")
|
||||
recipient_jid = aioxmpp.JID.fromstr("admin@localhost")
|
||||
password = "12345678"
|
||||
|
||||
client = aioxmpp.PresenceManagedClient(
|
||||
jid,
|
||||
aioxmpp.make_security_layer(
|
||||
password,
|
||||
no_verify=True
|
||||
),
|
||||
)
|
||||
|
||||
def message_received(msg):
|
||||
print(msg)
|
||||
print(msg.body)
|
||||
|
||||
# obtain an instance of the service
|
||||
message_dispatcher = client.summon(
|
||||
aioxmpp.dispatcher.SimpleMessageDispatcher
|
||||
)
|
||||
|
||||
# register a message callback here
|
||||
message_dispatcher.register_callback(
|
||||
aioxmpp.MessageType.CHAT,
|
||||
None,
|
||||
message_received,
|
||||
)
|
||||
|
||||
async def sendMessage():
|
||||
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)
|
||||
|
||||
def main():
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(sendMessage())
|
||||
loop.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -11,8 +11,16 @@ generateCert() {
|
|||
cd ../../
|
||||
}
|
||||
|
||||
generateCert "prosody"
|
||||
generateCert "conference.prosody"
|
||||
generateCert "pubsub.prosody"
|
||||
generateCert "proxy.prosody"
|
||||
generateCert "upload.prosody"
|
||||
generateCert "localhost"
|
||||
generateCert "conference.localhost"
|
||||
generateCert "pubsub.localhost"
|
||||
generateCert "proxy.localhost"
|
||||
generateCert "upload.localhost"
|
||||
|
||||
sudo docker-compose up -d
|
||||
|
||||
sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register admin localhost 12345678"
|
||||
|
||||
python test.py
|
||||
|
||||
sudo docker-compose down
|
||||
|
|
Loading…
Reference in a new issue