Allow SASL mechanism to be set when creating a ClientXMPP instance.
Instead of using:
ClientXMPP(jid, password, plugin_config={
'feature_mechanisms': {'use_mech': 'SOME-MECH'}})
You can use:
ClientXMPP(jid, password, sasl_mech='SOME-MECH')
If you need to change the mechanism after instantiation, use:
xmpp['feature_mechanisms'].sasl.mech = 'SCRAM-MD5'
This commit is contained in:
@@ -59,7 +59,7 @@ class ClientXMPP(BaseXMPP):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, jid, password, ssl=False, plugin_config={},
|
def __init__(self, jid, password, ssl=False, plugin_config={},
|
||||||
plugin_whitelist=[], escape_quotes=True):
|
plugin_whitelist=[], escape_quotes=True, sasl_mech=None):
|
||||||
"""
|
"""
|
||||||
Create a new SleekXMPP client.
|
Create a new SleekXMPP client.
|
||||||
|
|
||||||
@@ -114,9 +114,10 @@ class ClientXMPP(BaseXMPP):
|
|||||||
|
|
||||||
# Setup default stream features
|
# Setup default stream features
|
||||||
self.register_plugin('feature_starttls')
|
self.register_plugin('feature_starttls')
|
||||||
self.register_plugin('feature_mechanisms')
|
|
||||||
self.register_plugin('feature_bind')
|
self.register_plugin('feature_bind')
|
||||||
self.register_plugin('feature_session')
|
self.register_plugin('feature_session')
|
||||||
|
self.register_plugin('feature_mechanisms',
|
||||||
|
pconfig={'use_mech': sasl_mech} if sasl_mech else None)
|
||||||
|
|
||||||
def connect(self, address=tuple(), reattempt=True, use_tls=True):
|
def connect(self, address=tuple(), reattempt=True, use_tls=True):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -293,7 +293,8 @@ class SleekTest(unittest.TestCase):
|
|||||||
def stream_start(self, mode='client', skip=True, header=None,
|
def stream_start(self, mode='client', skip=True, header=None,
|
||||||
socket='mock', jid='tester@localhost',
|
socket='mock', jid='tester@localhost',
|
||||||
password='test', server='localhost',
|
password='test', server='localhost',
|
||||||
port=5222, plugins=None, plugin_config={}):
|
port=5222, sasl_mech=None,
|
||||||
|
plugins=None, plugin_config={}):
|
||||||
"""
|
"""
|
||||||
Initialize an XMPP client or component using a dummy XML stream.
|
Initialize an XMPP client or component using a dummy XML stream.
|
||||||
|
|
||||||
@@ -317,7 +318,9 @@ class SleekTest(unittest.TestCase):
|
|||||||
are loaded.
|
are loaded.
|
||||||
"""
|
"""
|
||||||
if mode == 'client':
|
if mode == 'client':
|
||||||
self.xmpp = ClientXMPP(jid, password, plugin_config=plugin_config)
|
self.xmpp = ClientXMPP(jid, password,
|
||||||
|
sasl_mech=sasl_mech,
|
||||||
|
plugin_config=plugin_config)
|
||||||
elif mode == 'component':
|
elif mode == 'component':
|
||||||
self.xmpp = ComponentXMPP(jid, password,
|
self.xmpp = ComponentXMPP(jid, password,
|
||||||
server, port,
|
server, port,
|
||||||
|
|||||||
Reference in New Issue
Block a user