Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ARG APT_LISTCHANGES_FRONTEND=none

WORKDIR /spectrum2

RUN apt-get install --no-install-recommends -y prosody ngircd python3-sleekxmpp python3-dateutil python3-dnspython libcppunit-dev purple-xmpp-carbons libglib2.0-dev psmisc
RUN apt-get install --no-install-recommends -y prosody ngircd python3-slixmpp python3-dateutil python3-dnspython libcppunit-dev purple-xmpp-carbons libglib2.0-dev psmisc

RUN cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TESTS=ON -DENABLE_QT4=OFF -DCMAKE_UNITY_BUILD=ON . && make -j4

Expand Down
31 changes: 17 additions & 14 deletions tests/libcommuni/muc_away.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,46 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.room_password = room_password
self.nick = nick
self.finished = False
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::" + room + "::presence", self.muc_got_online)

self.tests = {}
self.tests["online_received"] = ["libcommuni: Received away presence from 'client'", False]

def muc_got_online(self, presence):
if presence['muc']['nick'] == "client" and presence['show'] == "away":
async def muc_got_online(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
if presence['from'].resource == "client" and presence['show'] == "away":
self.tests["online_received"][1] = True
self.finished = True

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, self.nick, password=self.room_password, wait=True)
async def start(self, event):
self.plugin['xep_0045'].join_muc(self.room, self.nick, password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.finished = False

self.tests = {}

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
self.sendPresence(ptype = "away")
async def start(self, event):
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, self.nick)
self.send_presence(pshow = "away")

20 changes: 11 additions & 9 deletions tests/libcommuni/muc_change_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.finished = False
self.room_password = room_password
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("groupchat_message", self.muc_message)

Expand All @@ -24,13 +25,14 @@ def muc_message(self, msg):
self.send_message(mto=self.room, mbody=None, msubject='The new subject', mtype='groupchat')

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, self.nick, password=self.room_password, wait=True)
self.plugin['xep_0045'].join_muc(self.room, self.nick, password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("groupchat_subject", self.muc_subject)
self.finished = False
Expand All @@ -44,7 +46,7 @@ def muc_subject(self, msg):
self.finished = True

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, self.nick)
self.send_message(mto=self.room, mbody="ready", mtype='groupchat')
20 changes: 11 additions & 9 deletions tests/libcommuni/muc_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.room_password = room_password
Expand All @@ -19,18 +19,19 @@ def __init__(self, jid, password, room, room_password, nick):

self.tests = {}

self.register_plugin('xep_0045') # MUC plugin
def muc_message(self, msg):
if msg['mucnick'] != self.nick:
self.send_message(mto=msg['from'].bare,
mbody="echo %s" % msg['body'],
mtype='groupchat')

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, self.nick, password=self.room_password, wait=True)
self.plugin['xep_0045'].join_muc(self.room, self.nick, password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.add_event_handler("session_start", self.start)
Expand All @@ -40,14 +41,15 @@ def __init__(self, jid, password, room, nick):
self.tests = {}
self.tests["echo_received"] = ["libcommuni: Send and receive messages", False]

self.register_plugin('xep_0045') # MUC plugin
def muc_message(self, msg):
if msg['mucnick'] != self.nick:
if msg['body'] == "echo abc" or msg['body'] == "<owner> echo abc":
self.tests["echo_received"][1] = True
self.finished = True

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, self.nick)
self.send_message(mto=self.room, mbody="abc", mtype='groupchat')
46 changes: 27 additions & 19 deletions tests/libcommuni/muc_join_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,62 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.room_password = room_password
self.nick = nick
self.finished = False
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::" + room + "::got_online", self.muc_got_online)
self.add_event_handler("muc::" + room + "::got_offline", self.muc_got_offline)

self.tests = {}
self.tests["online_received"] = ["libcommuni: Received available presence from 'client'", False]
self.tests["offline_received"] = ["libcommuni: Received unavailable presence frin 'client'", False]
self.tests["offline_received"] = ["libcommuni: Received unavailable presence from 'client'", False]

def muc_got_online(self, presence):
if presence['muc']['nick'] == "client":
async def muc_got_online(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
print(f"DEBUG: Responder muc_got_online called, from={presence['from']}, resource={presence['from'].resource if presence['from'] else 'None'}")
if presence['from'] and presence['from'].resource == "client":
self.tests["online_received"][1] = True

def muc_got_offline(self, presence):
if presence['muc']['nick'] == "client":
async def muc_got_offline(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
print(f"DEBUG: Responder muc_got_offline called, from={presence['from']}, resource={presence['from'].resource if presence['from'] else 'None'}")
if presence['from'] and presence['from'].resource == "client":
self.tests["offline_received"][1] = True
self.finished = True

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, self.nick, password=self.room_password, wait=True)
async def start(self, event):
self.plugin['xep_0045'].join_muc(self.room, self.nick, password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::" + room + "::got_online", self.muc_got_online)
self.finished = False

self.tests = {}
self.tests["online_received"] = ["libcommuni: Received available presence from 'responder'", False]

def muc_got_online(self, presence):
if presence['muc']['nick'] == "responder":
async def muc_got_online(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
print(f"DEBUG: Client muc_got_online called, from={presence['from']}, resource={presence['from'].resource if presence['from'] else 'None'}")
if presence['from'] and presence['from'].resource == "responder":
self.tests["online_received"][1] = True
self.plugin['xep_0045'].leaveMUC(self.room, self.nick)
self.plugin['xep_0045'].leave_muc(self.room, self.nick)

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
async def start(self, event):
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, self.nick)
38 changes: 21 additions & 17 deletions tests/libcommuni/muc_join_nickname_used.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.room_password = room_password
self.nick = nick
self.finished = False
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::" + room + "::got_online", self.muc_got_online)
self.add_event_handler("muc::" + room + "::got_offline", self.muc_got_offline)
Expand All @@ -22,36 +23,39 @@ def __init__(self, jid, password, room, room_password, nick):
self.tests["online_received"] = ["libcommuni: Received available presence", False]
self.tests["offline_received"] = ["libcommuni: Received unavailable presence", False]

def muc_got_online(self, presence):
if presence['muc']['nick'] == "respond_":
async def muc_got_online(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
if presence['from'].resource == "respond_":
self.tests["online_received"][1] = True
self.send_message(mto=self.room,
mbody="disconnect please :)",
mtype='groupchat')

def muc_got_offline(self, presence):
if presence['muc']['nick'] == "respond_":
async def muc_got_offline(self, presence):
# In slixmpp, nick is in presence['from'].resource, not presence['muc']['nick']
if presence['from'].resource == "respond_":
self.tests["offline_received"][1] = True
self.finished = True

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, "respond", password=self.room_password, wait=True)
async def start(self, event):
self.plugin['xep_0045'].join_muc(self.room, "respond", password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.register_plugin('xep_0045') # MUC plugin
self.add_event_handler("session_start", self.start)
self.add_event_handler("groupchat_message", self.muc_message)
self.finished = False

self.tests = {}

def muc_message(self, msg):
self.plugin['xep_0045'].leaveMUC(self.room, "respond_")
async def muc_message(self, msg):
self.plugin['xep_0045'].leave_muc(self.room, "respond_")

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, "respond", wait=True)
async def start(self, event):
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, "respond")
20 changes: 11 additions & 9 deletions tests/libcommuni/muc_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import subprocess
import os

import sleekxmpp
import slixmpp


class Responder(sleekxmpp.ClientXMPP):
class Responder(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, room_password, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.room_password = room_password
self.nick = nick
Expand All @@ -19,6 +19,7 @@ def __init__(self, jid, password, room, room_password, nick):

self.tests = {}

self.register_plugin('xep_0045') # MUC plugin
def message(self, msg):
if msg['body'] == "abc" and msg['from'] == self.room + "/client":
self.send_message(mto=self.room + "/client",
Expand All @@ -32,11 +33,11 @@ def message(self, msg):
self.finished = True

def start(self, event):
self.plugin['xep_0045'].joinMUC(self.room, self.nick, password=self.room_password, wait=True)
self.plugin['xep_0045'].join_muc(self.room, self.nick, password=self.room_password)

class Client(sleekxmpp.ClientXMPP):
class Client(slixmpp.ClientXMPP):
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
slixmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.add_event_handler("session_start", self.start)
Expand All @@ -47,6 +48,7 @@ def __init__(self, jid, password, room, nick):
self.tests["echo1_received"] = ["libcommuni: Send and receive private messages - 1st msg", False]
self.tests["echo2_received"] = ["libcommuni: Send and receive private messages - 2nd msg", False]

self.register_plugin('xep_0045') # MUC plugin
def message(self, msg):
if msg['body'] == "echo abc" and msg['from'] == self.room + "/responder":
self.tests["echo1_received"][1] = True
Expand All @@ -56,7 +58,7 @@ def message(self, msg):
self.finished = True

def start(self, event):
self.getRoster()
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].join_muc(self.room, self.nick)
self.send_message(mto=self.room + "/responder", mbody="abc", mtype='chat')
Loading
Loading