Commit 93e0a046 authored by Philipp Hörist's avatar Philipp Hörist

Client: Add anonymous login test mode

parent 7fca9538
Pipeline #5251 passed with stages
in 33 seconds
......@@ -62,6 +62,7 @@ class Client(Observable):
resume-failed
resume-successful
login-successful
anonymous-supported
disconnected
connected
connection-failed
......@@ -685,6 +686,15 @@ class Client(Observable):
'register-not-supported')
return
if self._mode.is_anonymous_test:
if features.has_anonymous():
self.notify('anonymous-supported')
self.disconnect()
else:
self._disconnect_with_error(StreamError.SASL,
'anonymous-not-supported')
return
self._start_auth(features)
else:
......
......@@ -391,6 +391,7 @@ class Mode(IntEnum):
CLIENT = 0
REGISTER = 1
LOGIN_TEST = 2
ANONYMOUS_TEST = 3
@property
def is_client(self):
......@@ -404,6 +405,10 @@ class Mode(IntEnum):
def is_login_test(self):
return self == Mode.LOGIN_TEST
@property
def is_anonymous_test(self):
return self == Mode.ANONYMOUS_TEST
MOODS = [
'afraid',
......
......@@ -1833,6 +1833,8 @@ class Features(Node):
def get_mechs(self):
mechanisms = self.getTag('mechanisms', namespace=NS_SASL)
if mechanisms is None:
return set()
mechanisms = mechanisms.getTags('mechanism')
return set(mech.getData() for mech in mechanisms)
......@@ -1862,6 +1864,9 @@ class Features(Node):
return self.getTag(
'register', namespace=NS_REGISTER_FEATURE) is not None
def has_anonymous(self):
return 'ANONYMOUS' in self.get_mechs()
class ErrorNode(Node):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment