From aab70fc0666f62cd23828232806a344af352be03 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 26 Jun 2013 12:29:50 +1000 Subject: Fix external authentication --- test/ejabberd_SUITE_data/ejabberd.cfg | 4 ++++ test/ejabberd_SUITE_data/extauth.py | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 test/ejabberd_SUITE_data/extauth.py (limited to 'test/ejabberd_SUITE_data') diff --git a/test/ejabberd_SUITE_data/ejabberd.cfg b/test/ejabberd_SUITE_data/ejabberd.cfg index b50913353..458de2c7d 100644 --- a/test/ejabberd_SUITE_data/ejabberd.cfg +++ b/test/ejabberd_SUITE_data/ejabberd.cfg @@ -3,6 +3,7 @@ "mnesia.localhost", "mysql.localhost", "pgsql.localhost", + "extauth.localhost", "ldap.localhost"]}. {define_macro, 'CERTFILE', "cert.pem"}. {listen, @@ -59,6 +60,9 @@ {mod_version, []} ]}. {host_config, "localhost", [{auth_method, internal}]}. +{host_config, "extauth.localhost", + [{auth_method, external}, + {extauth_program, "python extauth.py"}]}. {host_config, "mnesia.localhost", [{auth_method, internal}, {{add, modules}, [{mod_announce, [{db_type, internal}]}, diff --git a/test/ejabberd_SUITE_data/extauth.py b/test/ejabberd_SUITE_data/extauth.py new file mode 100755 index 000000000..7f32eb8be --- /dev/null +++ b/test/ejabberd_SUITE_data/extauth.py @@ -0,0 +1,36 @@ +import sys +import struct + +def read(): + (pkt_size,) = struct.unpack('>H', sys.stdin.read(2)) + pkt = sys.stdin.read(pkt_size).split(':') + cmd = pkt[0] + args_num = len(pkt) - 1 + if cmd == 'auth' and args_num == 3: + write(True) + elif cmd == 'isuser' and args_num == 2: + write(True) + elif cmd == 'setpass' and args_num == 3: + write(True) + elif cmd == 'tryregister' and args_num == 3: + write(True) + elif cmd == 'removeuser' and args_num == 2: + write(True) + elif cmd == 'removeuser3' and args_num == 3: + write(True) + else: + write(False) + read() + +def write(result): + if result: + sys.stdout.write('\x00\x02\x00\x01') + else: + sys.stdout.write('\x00\x02\x00\x00') + sys.stdout.flush() + +if __name__ == "__main__": + try: + read() + except struct.error: + pass -- cgit v1.2.3