XMLStream.connect() is supposed to persist the parameters it gets called with to allow follow-up calls to call XMLStream.connect() without any parameters to result in a connection with the same properties as the original one. That's for example used by XMLStream.reconnect() when establishing a new connection.
Unfortunately that was broken for some of the parameters and resulted different TLS related settings on reconnections. This commit fixes that.
Here is some sample code to reproduce the bug:
#!/usr/bin/python3
from asyncio import Future
from slixmpp import ClientXMPP
JID = "user@ejabberd"
PASSWORD = "password"
class TestXMPP(ClientXMPP):
reconnected = False
finished = Future()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.add_event_handler('session_start', self._session_start)
def _session_start(self, event):
print(f"{self.use_ssl=}")
print(f"{self.force_starttls=}")
print(f"{self.disable_starttls=}")
print()
if self.reconnected:
self.disconnect()
self.finished.set_result(True)
self.reconnected = True
self.reconnect()
xmpp = TestXMPP(JID, PASSWORD)
# The bug gets also triggered for use_ssl=True
xmpp.connect(None, use_ssl=False, force_starttls=False, disable_starttls=True)
xmpp.loop.run_until_complete(xmpp.finished)