diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ejabberd_SUITE.erl | 73 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.extauth.yml | 5 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.ldap.yml | 35 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.mnesia.yml | 61 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.mysql.yml | 68 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.pgsql.yml | 68 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.redis.yml | 62 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.riak.yml | 44 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.sqlite.yml | 62 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/ejabberd.yml | 586 | ||||
-rw-r--r-- | test/ejabberd_SUITE_data/macros.yml | 24 | ||||
-rw-r--r-- | test/ldap_srv.erl | 2 | ||||
-rw-r--r-- | test/mam_tests.erl | 4 | ||||
-rw-r--r-- | test/muc_tests.erl | 6 | ||||
-rw-r--r-- | test/offline_tests.erl | 12 | ||||
-rw-r--r-- | test/suite.erl | 118 | ||||
-rw-r--r-- | test/suite.hrl | 2 |
17 files changed, 632 insertions, 600 deletions
diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl index 6fa424e76..0f4db5e8f 100644 --- a/test/ejabberd_SUITE.erl +++ b/test/ejabberd_SUITE.erl @@ -20,10 +20,7 @@ %%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %%% %%%---------------------------------------------------------------------- - - -module(ejabberd_SUITE). - -compile(export_all). -import(suite, [init_config/1, connect/1, disconnect/1, recv_message/1, @@ -62,23 +59,12 @@ init_per_suite(Config) -> start_ejabberd(NewConfig), NewConfig. -start_ejabberd(Config) -> - case proplists:get_value(backends, Config) of - all -> - {ok, _} = application:ensure_all_started(ejabberd, transient); - Backends when is_list(Backends) -> - Hosts = lists:map(fun(Backend) -> Backend ++ ".localhost" end, Backends), - application:load(ejabberd), - AllHosts = Hosts ++ ["localhost"], %% We always need localhost for the generic no_db tests - application:set_env(ejabberd, hosts, AllHosts), - {ok, _} = application:ensure_all_started(ejabberd, transient) - end. +start_ejabberd(_) -> + {ok, _} = application:ensure_all_started(ejabberd, transient). end_per_suite(_Config) -> application:stop(ejabberd). --define(BACKENDS, [mnesia,redis,mysql,pgsql,sqlite,ldap,extauth,riak]). - init_per_group(Group, Config) -> case lists:member(Group, ?BACKENDS) of false -> @@ -91,7 +77,7 @@ init_per_group(Group, Config) -> do_init_per_group(Group, Config); Backends -> %% Skipped backends that were not explicitely enabled - case lists:member(atom_to_list(Group), Backends) of + case lists:member(Group, Backends) of true -> do_init_per_group(Group, Config); false -> @@ -149,8 +135,8 @@ do_init_per_group(riak, Config) -> {skip, {riak_not_available, Err}} end; do_init_per_group(s2s, Config) -> - ejabberd_config:add_option(s2s_use_starttls, required_trusted), - ejabberd_config:add_option(domain_certfile, "cert.pem"), + ejabberd_config:set_option({s2s_use_starttls, ?COMMON_VHOST}, required), + ejabberd_config:set_option(ca_file, "ca.pem"), Port = ?config(s2s_port, Config), set_opt(server, ?COMMON_VHOST, set_opt(xmlns, ?NS_SERVER, @@ -200,8 +186,9 @@ end_per_group(riak, Config) -> end; end_per_group(component, _Config) -> ok; -end_per_group(s2s, _Config) -> - ejabberd_config:add_option(s2s_use_starttls, false); +end_per_group(s2s, Config) -> + Server = ?config(server, Config), + ejabberd_config:set_option({s2s_use_starttls, Server}, false); end_per_group(_GroupName, Config) -> stop_event_relay(Config), set_opt(anonymous, false, Config). @@ -297,7 +284,7 @@ init_per_testcase(TestCase, OrigConfig) -> "test_starttls" ++ _ -> connect(Config); "test_zlib" -> - connect(Config); + auth(connect(starttls(connect(Config)))); "test_register" -> connect(Config); "auth_md5" -> @@ -355,8 +342,8 @@ no_db_tests() -> unauthenticated_message, unauthenticated_presence, test_starttls, - test_zlib, test_auth, + test_zlib, test_bind, test_open_session, codec_failure, @@ -373,8 +360,7 @@ no_db_tests() -> presence, s2s_dialback, s2s_optional, - s2s_required, - s2s_required_trusted]}, + s2s_required]}, auth_external, auth_external_no_jid, auth_external_no_user, @@ -389,7 +375,9 @@ no_db_tests() -> proxy65_tests:single_cases(), proxy65_tests:master_slave_cases(), replaced_tests:master_slave_cases(), - upload_tests:single_cases()]. + upload_tests:single_cases(), + carbons_tests:single_cases(), + carbons_tests:master_slave_cases()]. db_tests(riak) -> %% No support for mod_pubsub @@ -406,15 +394,13 @@ db_tests(riak) -> vcard_tests:single_cases(), muc_tests:single_cases(), offline_tests:single_cases(), - carbons_tests:single_cases(), test_unregister]}, muc_tests:master_slave_cases(), privacy_tests:master_slave_cases(), roster_tests:master_slave_cases(), offline_tests:master_slave_cases(riak), vcard_tests:master_slave_cases(), - announce_tests:master_slave_cases(), - carbons_tests:master_slave_cases()]; + announce_tests:master_slave_cases()]; db_tests(DB) when DB == mnesia; DB == redis -> [{single_user, [sequence], [test_register, @@ -431,7 +417,6 @@ db_tests(DB) when DB == mnesia; DB == redis -> muc_tests:single_cases(), offline_tests:single_cases(), mam_tests:single_cases(), - carbons_tests:single_cases(), csi_tests:single_cases(), push_tests:single_cases(), test_unregister]}, @@ -443,7 +428,6 @@ db_tests(DB) when DB == mnesia; DB == redis -> mam_tests:master_slave_cases(), vcard_tests:master_slave_cases(), announce_tests:master_slave_cases(), - carbons_tests:master_slave_cases(), csi_tests:master_slave_cases(), push_tests:master_slave_cases()]; db_tests(DB) -> @@ -472,7 +456,6 @@ db_tests(DB) -> mam_tests:master_slave_cases(), vcard_tests:master_slave_cases(), announce_tests:master_slave_cases(), - carbons_tests:master_slave_cases(), push_tests:master_slave_cases()]. ldap_tests() -> @@ -754,27 +737,29 @@ test_component_send(Config) -> disconnect(Config). s2s_dialback(Config) -> + Server = ?config(server, Config), ejabberd_s2s:stop_s2s_connections(), - ejabberd_config:add_option(s2s_use_starttls, false), - ejabberd_config:add_option(domain_certfile, "self-signed-cert.pem"), + ejabberd_config:set_option({s2s_use_starttls, Server}, false), + ejabberd_config:set_option({s2s_use_starttls, ?MNESIA_VHOST}, false), + ejabberd_config:set_option(ca_file, pkix:get_cafile()), s2s_ping(Config). s2s_optional(Config) -> + Server = ?config(server, Config), ejabberd_s2s:stop_s2s_connections(), - ejabberd_config:add_option(s2s_use_starttls, optional), - ejabberd_config:add_option(domain_certfile, "self-signed-cert.pem"), + ejabberd_config:set_option({s2s_use_starttls, Server}, optional), + ejabberd_config:set_option({s2s_use_starttls, ?MNESIA_VHOST}, optional), + ejabberd_config:set_option(ca_file, pkix:get_cafile()), s2s_ping(Config). s2s_required(Config) -> + Server = ?config(server, Config), ejabberd_s2s:stop_s2s_connections(), - ejabberd_config:add_option(s2s_use_starttls, required), - ejabberd_config:add_option(domain_certfile, "self-signed-cert.pem"), - s2s_ping(Config). - -s2s_required_trusted(Config) -> - ejabberd_s2s:stop_s2s_connections(), - ejabberd_config:add_option(s2s_use_starttls, required), - ejabberd_config:add_option(domain_certfile, "cert.pem"), + gen_mod:stop_module(Server, mod_s2s_dialback), + gen_mod:stop_module(?MNESIA_VHOST, mod_s2s_dialback), + ejabberd_config:set_option({s2s_use_starttls, Server}, required), + ejabberd_config:set_option({s2s_use_starttls, ?MNESIA_VHOST}, required), + ejabberd_config:set_option(ca_file, "ca.pem"), s2s_ping(Config). s2s_ping(Config) -> diff --git a/test/ejabberd_SUITE_data/ejabberd.extauth.yml b/test/ejabberd_SUITE_data/ejabberd.extauth.yml new file mode 100644 index 000000000..660ddccd6 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.extauth.yml @@ -0,0 +1,5 @@ +define_macro: + EXTAUTH_CONFIG: + queue_type: ram + extauth_program: "python extauth.py" + auth_method: external diff --git a/test/ejabberd_SUITE_data/ejabberd.ldap.yml b/test/ejabberd_SUITE_data/ejabberd.ldap.yml new file mode 100644 index 000000000..5c481cbc6 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.ldap.yml @@ -0,0 +1,35 @@ +define_macro: + LDAP_CONFIG: + queue_type: ram + ldap_servers: + - "localhost" + ldap_rootdn: "cn=admin,dc=localhost" + ldap_port: 1389 + ldap_password: "password" + ldap_base: "ou=users,dc=localhost" + auth_method: ldap + modules: + mod_vcard: + db_type: ldap + mod_roster: [] # mod_roster is required by mod_shared_roster + mod_shared_roster_ldap: + ldap_auth_check: off + ldap_base: "dc=localhost" + ldap_rfilter: "(objectClass=posixGroup)" + ldap_gfilter: "(&(objectClass=posixGroup)(cn=%g))" + ldap_memberattr: "memberUid" + ldap_ufilter: "(uid=%u)" + ldap_userdesc: "cn" + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.mnesia.yml b/test/ejabberd_SUITE_data/ejabberd.mnesia.yml new file mode 100644 index 000000000..70975123c --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.mnesia.yml @@ -0,0 +1,61 @@ +define_macro: + MNESIA_CONFIG: + queue_type: ram + auth_method: internal + modules: + mod_announce: + db_type: internal + access: local + mod_blocking: [] + mod_caps: + db_type: internal + mod_last: + db_type: internal + mod_muc: + db_type: internal + mod_offline: + db_type: internal + mod_privacy: + db_type: internal + mod_private: + db_type: internal + mod_pubsub: + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "pep" + mod_roster: + versioning: true + store_current_id: true + db_type: internal + mod_mam: + db_type: internal + mod_vcard: + db_type: internal + mod_vcard_xupdate: [] + mod_client_state: + queue_presence: true + queue_chat_states: true + queue_pep: true + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_push: + include_body: false + mod_push_keepalive: [] + mod_s2s_dialback: [] + mod_stream_mgmt: + resume_timeout: 3 + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.mysql.yml b/test/ejabberd_SUITE_data/ejabberd.mysql.yml new file mode 100644 index 000000000..0b0550e18 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.mysql.yml @@ -0,0 +1,68 @@ +define_macro: + MYSQL_CONFIG: + sql_username: MYSQL_USER + sql_type: mysql + sql_server: MYSQL_SERVER + sql_port: MYSQL_PORT + sql_pool_size: 1 + sql_password: MYSQL_PASS + sql_database: MYSQL_DB + auth_method: sql + sm_db_type: sql + modules: + mod_announce: + db_type: sql + access: local + mod_blocking: [] + mod_caps: + db_type: sql + mod_last: + db_type: sql + mod_muc: + db_type: sql + ram_db_type: sql + mod_offline: + use_cache: true + db_type: sql + mod_privacy: + db_type: sql + mod_private: + db_type: sql + mod_pubsub: + db_type: sql + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "pep" + mod_roster: + versioning: true + store_current_id: true + db_type: sql + mod_mam: + db_type: sql + mod_vcard: + db_type: sql + mod_vcard_xupdate: [] + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_push: + db_type: sql + include_body: false + mod_push_keepalive: [] + mod_s2s_dialback: [] + mod_stream_mgmt: + resume_timeout: 3 + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.pgsql.yml b/test/ejabberd_SUITE_data/ejabberd.pgsql.yml new file mode 100644 index 000000000..637fc61bc --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.pgsql.yml @@ -0,0 +1,68 @@ +define_macro: + PGSQL_CONFIG: + sql_username: PGSQL_USER + sql_type: pgsql + sql_server: PGSQL_SERVER + sql_port: PGSQL_PORT + sql_pool_size: 1 + sql_password: PGSQL_PASS + sql_database: PGSQL_DB + auth_method: sql + sm_db_type: sql + modules: + mod_announce: + db_type: sql + access: local + mod_blocking: [] + mod_caps: + db_type: sql + mod_last: + db_type: sql + mod_muc: + db_type: sql + ram_db_type: sql + mod_offline: + use_cache: true + db_type: sql + mod_privacy: + db_type: sql + mod_private: + db_type: sql + mod_pubsub: + db_type: sql + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "pep" + mod_roster: + versioning: true + store_current_id: true + db_type: sql + mod_mam: + db_type: sql + mod_vcard: + db_type: sql + mod_vcard_xupdate: [] + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_push: + db_type: sql + include_body: false + mod_push_keepalive: [] + mod_s2s_dialback: [] + mod_stream_mgmt: + resume_timeout: 3 + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.redis.yml b/test/ejabberd_SUITE_data/ejabberd.redis.yml new file mode 100644 index 000000000..1c0ac6de7 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.redis.yml @@ -0,0 +1,62 @@ +define_macro: + REDIS_CONFIG: + queue_type: ram + auth_method: internal + sm_db_type: redis + modules: + mod_announce: + db_type: internal + access: local + mod_blocking: [] + mod_caps: + db_type: internal + mod_last: + db_type: internal + mod_muc: + db_type: internal + mod_offline: + db_type: internal + mod_privacy: + db_type: internal + mod_private: + db_type: internal + mod_pubsub: + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "pep" + mod_roster: + versioning: true + store_current_id: true + db_type: internal + mod_mam: + db_type: internal + mod_vcard: + db_type: internal + mod_vcard_xupdate: [] + mod_client_state: + queue_presence: true + queue_chat_states: true + queue_pep: true + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_push: + include_body: false + mod_push_keepalive: [] + mod_s2s_dialback: [] + mod_stream_mgmt: + resume_timeout: 3 + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.riak.yml b/test/ejabberd_SUITE_data/ejabberd.riak.yml new file mode 100644 index 000000000..0a64db915 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.riak.yml @@ -0,0 +1,44 @@ +define_macro: + RIAK_CONFIG: + queue_type: ram + auth_method: riak + sm_db_type: riak + modules: + mod_announce: + db_type: riak + access: local + mod_blocking: [] + mod_caps: + db_type: riak + mod_last: + db_type: riak + mod_muc: + db_type: riak + mod_offline: + db_type: riak + mod_privacy: + db_type: riak + mod_private: + db_type: riak + mod_roster: + versioning: true + store_current_id: true + db_type: riak + mod_vcard: + db_type: riak + mod_vcard_xupdate: [] + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_s2s_dialback: [] + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.sqlite.yml b/test/ejabberd_SUITE_data/ejabberd.sqlite.yml new file mode 100644 index 000000000..b0bfdb473 --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.sqlite.yml @@ -0,0 +1,62 @@ +define_macro: + SQLITE_CONFIG: + sql_type: sqlite + sql_pool_size: 1 + auth_method: sql + sm_db_type: sql + modules: + mod_announce: + db_type: sql + access: local + mod_blocking: [] + mod_caps: + db_type: sql + mod_last: + db_type: sql + mod_muc: + db_type: sql + ram_db_type: sql + mod_offline: + db_type: sql + mod_privacy: + db_type: sql + mod_private: + db_type: sql + mod_pubsub: + db_type: sql + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "pep" + mod_roster: + versioning: true + store_current_id: true + db_type: sql + mod_mam: + db_type: sql + mod_vcard: + db_type: sql + mod_vcard_xupdate: [] + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_push: + db_type: sql + include_body: false + mod_push_keepalive: [] + mod_s2s_dialback: [] + mod_stream_mgmt: + resume_timeout: 3 + mod_legacy_auth: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] diff --git a/test/ejabberd_SUITE_data/ejabberd.yml b/test/ejabberd_SUITE_data/ejabberd.yml index e720ac103..e5c3e783d 100644 --- a/test/ejabberd_SUITE_data/ejabberd.yml +++ b/test/ejabberd_SUITE_data/ejabberd.yml @@ -1,504 +1,116 @@ -host_config: - "pgsql.localhost": - sql_username: "@@pgsql_user@@" - sql_type: pgsql - sql_server: "@@pgsql_server@@" - sql_port: @@pgsql_port@@ - sql_pool_size: 1 - sql_password: "@@pgsql_pass@@" - sql_database: "@@pgsql_db@@" - auth_method: sql - sm_db_type: sql - modules: - mod_announce: - db_type: sql - access: local - mod_blocking: [] - mod_caps: - db_type: sql - mod_last: - db_type: sql - mod_muc: - db_type: sql - ram_db_type: sql - mod_offline: - db_type: sql - mod_privacy: - db_type: sql - mod_private: - db_type: sql - mod_pubsub: - db_type: sql - access_createnode: pubsub_createnode - ignore_pep_from_offline: true - last_item_cache: false - plugins: - - "flat" - - "hometree" - - "pep" - mod_roster: - versioning: true - store_current_id: true - db_type: sql - mod_mam: - db_type: sql - mod_vcard: - db_type: sql - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: sql - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_push: - db_type: sql - include_body: false - mod_push_keepalive: [] - mod_s2s_dialback: [] - mod_stream_mgmt: - resume_timeout: 3 - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "sqlite.localhost": - sql_type: sqlite - sql_pool_size: 1 - auth_method: sql - sm_db_type: sql - modules: - mod_announce: - db_type: sql - access: local - mod_blocking: [] - mod_caps: - db_type: sql - mod_last: - db_type: sql - mod_muc: - db_type: sql - ram_db_type: sql - mod_offline: - db_type: sql - mod_privacy: - db_type: sql - mod_private: - db_type: sql - mod_pubsub: - db_type: sql - access_createnode: pubsub_createnode - ignore_pep_from_offline: true - last_item_cache: false - plugins: - - "flat" - - "hometree" - - "pep" - mod_roster: - versioning: true - store_current_id: true - db_type: sql - mod_mam: - db_type: sql - mod_vcard: - db_type: sql - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: sql - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_push: - db_type: sql - include_body: false - mod_push_keepalive: [] - mod_s2s_dialback: [] - mod_stream_mgmt: - resume_timeout: 3 - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "mysql.localhost": - sql_username: "@@mysql_user@@" - sql_type: mysql - sql_server: "@@mysql_server@@" - sql_port: @@mysql_port@@ - sql_pool_size: 1 - sql_password: "@@mysql_pass@@" - sql_database: "@@mysql_db@@" - auth_method: sql - sm_db_type: sql - modules: - mod_announce: - db_type: sql - access: local - mod_blocking: [] - mod_caps: - db_type: sql - mod_last: - db_type: sql - mod_muc: - db_type: sql - ram_db_type: sql - mod_offline: - db_type: sql - mod_privacy: - db_type: sql - mod_private: - db_type: sql - mod_pubsub: - db_type: sql - access_createnode: pubsub_createnode - ignore_pep_from_offline: true - last_item_cache: false - plugins: - - "flat" - - "hometree" - - "pep" - mod_roster: - versioning: true - store_current_id: true - db_type: sql - mod_mam: - db_type: sql - mod_vcard: - db_type: sql - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: sql - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_push: - db_type: sql - include_body: false - mod_push_keepalive: [] - mod_s2s_dialback: [] - mod_stream_mgmt: - resume_timeout: 3 - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "mnesia.localhost": - queue_type: ram - auth_method: internal - modules: - mod_announce: - db_type: internal - access: local - mod_blocking: [] - mod_caps: - db_type: internal - mod_last: - db_type: internal - mod_muc: - db_type: internal - mod_offline: - db_type: internal - mod_privacy: - db_type: internal - mod_private: - db_type: internal - mod_pubsub: - access_createnode: pubsub_createnode - ignore_pep_from_offline: true - last_item_cache: false - plugins: - - "flat" - - "hometree" - - "pep" - mod_roster: - versioning: true - store_current_id: true - db_type: internal - mod_mam: - db_type: internal - mod_vcard: - db_type: internal - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: internal - mod_client_state: - queue_presence: true - queue_chat_states: true - queue_pep: true - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_push: - include_body: false - mod_push_keepalive: [] - mod_s2s_dialback: [] - mod_stream_mgmt: - resume_timeout: 3 - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "redis.localhost": - queue_type: ram - auth_method: internal - sm_db_type: redis - modules: - mod_announce: - db_type: internal - access: local - mod_blocking: [] - mod_caps: - db_type: internal - mod_last: - db_type: internal - mod_muc: - db_type: internal - mod_offline: - db_type: internal - mod_privacy: - db_type: internal - mod_private: - db_type: internal - mod_pubsub: - access_createnode: pubsub_createnode - ignore_pep_from_offline: true - last_item_cache: false - plugins: - - "flat" - - "hometree" - - "pep" - mod_roster: - versioning: true - store_current_id: true - db_type: internal - mod_mam: - db_type: internal - mod_vcard: - db_type: internal - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: redis - mod_client_state: - queue_presence: true - queue_chat_states: true - queue_pep: true - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_push: - include_body: false - mod_push_keepalive: [] - mod_s2s_dialback: [] - mod_stream_mgmt: - resume_timeout: 3 - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "riak.localhost": - queue_type: ram - auth_method: riak - sm_db_type: riak - modules: - mod_announce: - db_type: riak - access: local - mod_blocking: [] - mod_caps: - db_type: riak - mod_last: - db_type: riak - mod_muc: - db_type: riak - mod_offline: - db_type: riak - mod_privacy: - db_type: riak - mod_private: - db_type: riak - mod_roster: - versioning: true - store_current_id: true - db_type: riak - mod_vcard: - db_type: riak - mod_vcard_xupdate: [] - mod_carboncopy: - ram_db_type: riak - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_s2s_dialback: [] - mod_legacy_auth: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "localhost": - auth_method: [internal, anonymous] - "ldap.localhost": - queue_type: ram - ldap_servers: - - "localhost" - ldap_rootdn: "cn=admin,dc=localhost" - ldap_port: 1389 - ldap_password: "password" - ldap_base: "ou=users,dc=localhost" - auth_method: ldap - modules: - mod_vcard: - db_type: ldap - mod_roster: [] # mod_roster is required by mod_shared_roster - mod_shared_roster_ldap: - ldap_auth_check: off - ldap_base: "dc=localhost" - ldap_rfilter: "(objectClass=posixGroup)" - ldap_gfilter: "(&(objectClass=posixGroup)(cn=%g))" - ldap_memberattr: "memberUid" - ldap_ufilter: "(uid=%u)" - ldap_userdesc: "cn" - mod_adhoc: [] - mod_configure: [] - mod_disco: [] - mod_ping: [] - mod_proxy65: [] - mod_register: - welcome_message: - subject: "Welcome!" - body: "Hi. -Welcome to this XMPP server." - mod_stats: [] - mod_time: [] - mod_version: [] - "extauth.localhost": - queue_type: ram - extauth_program: "python extauth.py" - auth_method: external -hosts: - - "localhost" - - "mnesia.localhost" - - "redis.localhost" - - "mysql.localhost" - - "pgsql.localhost" - - "extauth.localhost" - - "ldap.localhost" - - "riak.localhost" - - "sqlite.localhost" -access: - announce: - admin: allow - c2s: - blocked: deny - all: allow - c2s_shaper: - admin: none - all: normal - configure: - admin: allow - local: - local: allow - max_user_offline_messages: - all: infinity - max_user_sessions: - all: 10 - muc: - all: allow - muc_admin: - admin: allow - muc_create: - local: allow - pubsub_createnode: - local: allow - register: - all: allow - s2s_shaper: - all: fast -acl: - local: +include_config_file: + - macros.yml + - ejabberd.extauth.yml + - ejabberd.ldap.yml + - ejabberd.mnesia.yml + - ejabberd.mysql.yml + - ejabberd.pgsql.yml + - ejabberd.redis.yml + - ejabberd.riak.yml + - ejabberd.sqlite.yml + +host_config: + pgsql.localhost: PGSQL_CONFIG + sqlite.localhost: SQLITE_CONFIG + mysql.localhost: MYSQL_CONFIG + mnesia.localhost: MNESIA_CONFIG + redis.localhost: REDIS_CONFIG + riak.localhost: RIAK_CONFIG + ldap.localhost: LDAP_CONFIG + extauth.localhost: EXTAUTH_CONFIG + localhost: + auth_method: + - internal + - anonymous + +hosts: + - localhost + - mnesia.localhost + - redis.localhost + - mysql.localhost + - pgsql.localhost + - extauth.localhost + - ldap.localhost + - riak.localhost + - sqlite.localhost + +shaper_rules: + c2s_shaper: + none: admin + normal: all + max_user_offline_messages: + infinity: all + max_user_sessions: + 10: all + s2s_shaper: + fast: all + +access_rules: + announce: + allow: admin + c2s: + deny: blocked + allow: all + configure: + allow: admin + local: + allow: local + muc: + allow: all + muc_admin: + allow: admin + muc_create: + allow: local + pubsub_createnode: + allow: local + register: + allow: all + +acl: + local: user_regexp: "" -define_macro: - CERTFILE: "cert.pem" - CAFILE: "ca.pem" -language: "en" -listen: - - - port: @@c2s_port@@ +language: en +listen: + - + port: C2S_PORT module: ejabberd_c2s max_stanza_size: 65536 - certfile: CERTFILE - cafile: CAFILE zlib: true starttls: true tls_verify: true shaper: c2s_shaper access: c2s - - - port: @@s2s_port@@ + - + port: S2S_PORT module: ejabberd_s2s_in - - - port: @@web_port@@ + - + port: WEB_PORT module: ejabberd_http - captcha: true request_handlers: "/api": mod_http_api "/upload": mod_http_upload - - - port: @@component_port@@ + "/captcha": ejabberd_captcha + - + port: COMPONENT_PORT module: ejabberd_service - password: >- - @@password@@ -loglevel: @@loglevel@@ + password: PASSWORD +loglevel: LOGLEVEL max_fsm_queue: 1000 queue_type: file -modules: +modules: mod_adhoc: [] + mod_announce: [] mod_configure: [] mod_disco: [] mod_ping: [] mod_proxy65: [] mod_muc: [] mod_muc_admin: [] - mod_register: - welcome_message: + mod_carboncopy: [] + mod_mam: [] + mod_last: [] + mod_register: + welcome_message: subject: "Welcome!" body: "Hi. Welcome to this XMPP server." @@ -511,21 +123,23 @@ Welcome to this XMPP server." mod_time: [] mod_version: [] mod_http_upload: - docroot: "@@priv_dir@@" - put_url: "http://upload.@HOST@:@@web_port@@/upload" - get_url: "http://upload.@HOST@:@@web_port@@/upload" + docroot: PRIV_DIR + put_url: PUT_URL + get_url: GET_URL max_size: 10000 registration_timeout: infinity route_subdomains: s2s -domain_certfile: CERTFILE s2s_use_starttls: false -s2s_cafile: CAFILE -outgoing_s2s_port: @@s2s_port@@ -shaper: +ca_file: CAFILE +c2s_cafile: CAFILE +outgoing_s2s_port: S2S_PORT +shaper: fast: 50000 normal: 10000 +certfiles: + - CERTFILE -new_sql_schema: @@new_schema@@ +new_sql_schema: NEW_SCHEMA api_permissions: "public commands": diff --git a/test/ejabberd_SUITE_data/macros.yml b/test/ejabberd_SUITE_data/macros.yml new file mode 100644 index 000000000..9ba6a561b --- /dev/null +++ b/test/ejabberd_SUITE_data/macros.yml @@ -0,0 +1,24 @@ +define_macro: + CERTFILE: cert.pem + CAFILE: ca.pem + C2S_PORT: @@c2s_port@@ + S2S_PORT: @@s2s_port@@ + WEB_PORT: @@web_port@@ + COMPONENT_PORT: @@component_port@@ + PASSWORD: >- + @@password@@ + LOGLEVEL: @@loglevel@@ + PRIV_DIR: "@@priv_dir@@" + PUT_URL: "http://upload.@HOST@:@@web_port@@/upload" + GET_URL: "http://upload.@HOST@:@@web_port@@/upload" + NEW_SCHEMA: @@new_schema@@ + MYSQL_USER: "@@mysql_user@@" + MYSQL_SERVER: "@@mysql_server@@" + MYSQL_PORT: @@mysql_port@@ + MYSQL_PASS: "@@mysql_pass@@" + MYSQL_DB: "@@mysql_db@@" + PGSQL_USER: "@@pgsql_user@@" + PGSQL_SERVER: "@@pgsql_server@@" + PGSQL_PORT: @@pgsql_port@@ + PGSQL_PASS: "@@pgsql_pass@@" + PGSQL_DB: "@@pgsql_db@@" diff --git a/test/ldap_srv.erl b/test/ldap_srv.erl index 8ac5a7b89..7ad53dda3 100644 --- a/test/ldap_srv.erl +++ b/test/ldap_srv.erl @@ -71,7 +71,7 @@ init([LDIFFile]) -> case load_ldif(LDIFFile) of {ok, Tree} -> ?INFO_MSG("LDIF tree loaded, " - "ready to accept connections", []), + "ready to accept connections at ~B", [1389]), {_Pid, MRef} = spawn_monitor( fun() -> accept(ListenSocket, Tree) end diff --git a/test/mam_tests.erl b/test/mam_tests.erl index 69afacd2e..75229becb 100644 --- a/test/mam_tests.erl +++ b/test/mam_tests.erl @@ -387,9 +387,9 @@ mucsub_from_muc_master(Config) -> mucsub_from_muc_slave(Config) -> Server = ?config(server, Config), - gen_mod:update_module_opts(Server, mod_mam, [{user_mucsub_from_muc_archive, true}]), + gen_mod:update_module(Server, mod_mam, #{user_mucsub_from_muc_archive => true}), Config2 = mucsub_slave(Config), - gen_mod:update_module_opts(Server, mod_mam, [{user_mucsub_from_muc_archive, false}]), + gen_mod:update_module(Server, mod_mam, #{user_mucsub_from_muc_archive => false}), Config2. mucsub_from_muc_non_persistent_master(Config) -> diff --git a/test/muc_tests.erl b/test/muc_tests.erl index e744e3fc9..2eb52eb19 100644 --- a/test/muc_tests.erl +++ b/test/muc_tests.erl @@ -468,7 +468,7 @@ history_master(Config) -> MyNick = ?config(nick, Config), MyNickJID = jid:replace_resource(Room, MyNick), PeerNickJID = peer_muc_jid(Config), - Size = gen_mod:get_module_opt(ServerHost, mod_muc, history_size, 20), + Size = mod_muc_opt:history_size(iolist_to_binary(ServerHost)), ok = join_new(Config), ct:comment("Putting ~p+1 messages in the history", [Size]), %% Only Size messages will be stored @@ -496,7 +496,7 @@ history_slave(Config) -> PeerNick = ?config(peer_nick, Config), PeerNickJID = jid:replace_resource(Room, PeerNick), ServerHost = ?config(server_host, Config), - Size = gen_mod:get_module_opt(ServerHost, mod_muc, history_size, 20), + Size = mod_muc_opt:history_size(iolist_to_binary(ServerHost)), ct:comment("Waiting for 'join' command from the master"), join = get_event(Config), {History, _, _} = join(Config), @@ -1785,7 +1785,7 @@ master_join(Config) -> wait_for_slave(Config), #muc_user{items = [#muc_item{jid = PeerJID, role = participant, - affiliation = none}]} = + affiliation = none}]} = recv_muc_presence(Config, PeerNickJID, available), ok. diff --git a/test/offline_tests.erl b/test/offline_tests.erl index 97d9ee58b..a3a7aad90 100644 --- a/test/offline_tests.erl +++ b/test/offline_tests.erl @@ -189,11 +189,11 @@ from_mam_master(Config) -> from_mam_slave(Config) -> Server = ?config(server, Config), - gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]), + gen_mod:update_module(Server, mod_offline, #{use_mam_for_storage => true}), ok = mam_tests:set_default(Config, always), C2 = lists:keystore(mam_enabled, 1, Config, {mam_enabled, true}), C3 = send_all_slave(C2), - gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]), + gen_mod:update_module(Server, mod_offline, #{use_mam_for_storage => false}), C4 = lists:keydelete(mam_enabled, 1, C3), mam_tests:clean(C4). @@ -234,8 +234,8 @@ mucsub_mam_master(Config) -> mucsub_mam_slave(Config) -> Server = ?config(server, Config), - gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]), - gen_mod:update_module_opts(Server, mod_mam, [{user_mucsub_from_muc_archive, true}]), + gen_mod:update_module(Server, mod_offline, #{use_mam_for_storage => true}), + gen_mod:update_module(Server, mod_mam, #{user_mucsub_from_muc_archive => true}), Room = suite:muc_room_jid(Config), MyJID = my_jid(Config), @@ -268,8 +268,8 @@ mucsub_mam_slave(Config) -> ]}, #iq{type = result}), suite:put_event(Config, ready), mam_tests:clean(clean(disconnect(Config))), - gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]), - gen_mod:update_module_opts(Server, mod_mam, [{user_mucsub_from_muc_archive, false}]). + gen_mod:update_module(Server, mod_offline, #{use_mam_for_storage => false}), + gen_mod:update_module(Server, mod_mam, #{user_mucsub_from_muc_archive => false}). send_all_master(Config) -> wait_for_slave(Config), diff --git a/test/suite.erl b/test/suite.erl index b466bd02a..7e5fa3eba 100644 --- a/test/suite.erl +++ b/test/suite.erl @@ -38,7 +38,8 @@ init_config(Config) -> PrivDir = proplists:get_value(priv_dir, Config), [_, _|Tail] = lists:reverse(filename:split(DataDir)), BaseDir = filename:join(lists:reverse(Tail)), - ConfigPathTpl = filename:join([DataDir, "ejabberd.yml"]), + MacrosPathTpl = filename:join([DataDir, "macros.yml"]), + ConfigPath = filename:join([DataDir, "ejabberd.yml"]), LogPath = filename:join([PrivDir, "ejabberd.log"]), SASLPath = filename:join([PrivDir, "sasl.log"]), MnesiaDir = filename:join([PrivDir, "mnesia"]), @@ -50,46 +51,32 @@ init_config(Config) -> {ok, _} = file:copy(SelfSignedCertFile, filename:join([CWD, "self-signed-cert.pem"])), {ok, _} = file:copy(CAFile, filename:join([CWD, "ca.pem"])), - {ok, CfgContentTpl} = file:read_file(ConfigPathTpl), + {ok, MacrosContentTpl} = file:read_file(MacrosPathTpl), Password = <<"password!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>, - CfgContent = process_config_tpl(CfgContentTpl, [ - {c2s_port, 5222}, - {loglevel, 4}, - {new_schema, false}, - {s2s_port, 5269}, - {component_port, 5270}, - {web_port, 5280}, - {password, Password}, - {mysql_server, <<"localhost">>}, - {mysql_port, 3306}, - {mysql_db, <<"ejabberd_test">>}, - {mysql_user, <<"ejabberd_test">>}, - {mysql_pass, <<"ejabberd_test">>}, - {pgsql_server, <<"localhost">>}, - {pgsql_port, 5432}, - {pgsql_db, <<"ejabberd_test">>}, - {pgsql_user, <<"ejabberd_test">>}, - {pgsql_pass, <<"ejabberd_test">>}, - {priv_dir, PrivDir} - ]), - HostTypes = re:split(CfgContent, "(\\s*- \"(.*)\\.localhost\")", - [group, {return, binary}]), - Types = [binary_to_list(Type) || [_, _, Type] <- HostTypes], - Backends = get_config_backends(Types), - HostTypes = re:split(CfgContent, "(\\s*- \"(.*)\\.localhost\")", - [group, {return, binary}]), - CfgContent2 = lists:foldl(fun([Pre, Frag, Type], Acc) -> - case lists:member(binary_to_list(Type), Backends) of - true -> - <<Acc/binary, Pre/binary, Frag/binary>>; - _ -> - <<Acc/binary, Pre/binary>> - end; - ([Rest], Acc) -> - <<Acc/binary, Rest/binary>> - end, <<>>, HostTypes), - ConfigPath = filename:join([CWD, "ejabberd.yml"]), - ok = file:write_file(ConfigPath, CfgContent2), + Backends = get_config_backends(), + MacrosContent = process_config_tpl( + MacrosContentTpl, + [{c2s_port, 5222}, + {loglevel, 4}, + {new_schema, false}, + {s2s_port, 5269}, + {component_port, 5270}, + {web_port, 5280}, + {password, Password}, + {mysql_server, <<"localhost">>}, + {mysql_port, 3306}, + {mysql_db, <<"ejabberd_test">>}, + {mysql_user, <<"ejabberd_test">>}, + {mysql_pass, <<"ejabberd_test">>}, + {pgsql_server, <<"localhost">>}, + {pgsql_port, 5432}, + {pgsql_db, <<"ejabberd_test">>}, + {pgsql_user, <<"ejabberd_test">>}, + {pgsql_pass, <<"ejabberd_test">>}, + {priv_dir, PrivDir}]), + MacrosPath = filename:join([CWD, "macros.yml"]), + ok = file:write_file(MacrosPath, MacrosContent), + copy_backend_configs(DataDir, CWD, Backends), setup_ejabberd_lib_path(Config), case application:load(sasl) of ok -> ok; @@ -141,6 +128,29 @@ init_config(Config) -> {backends, Backends} |Config]. +copy_backend_configs(DataDir, CWD, Backends) -> + Files = filelib:wildcard(filename:join([DataDir, "ejabberd.*.yml"])), + lists:foreach( + fun(Src) -> + File = filename:basename(Src), + case string:tokens(File, ".") of + ["ejabberd", SBackend, "yml"] -> + Backend = list_to_atom(SBackend), + Macro = list_to_atom(string:to_upper(SBackend) ++ "_CONFIG"), + Dst = filename:join([CWD, File]), + case lists:member(Backend, Backends) of + true -> + {ok, _} = file:copy(Src, Dst); + false -> + ok = file:write_file( + Dst, fast_yaml:encode( + [{define_macro, [{Macro, []}]}])) + end; + _ -> + ok + end + end, Files). + find_top_dir(Dir) -> case file:read_file_info(filename:join([Dir, ebin])) of {ok, #file_info{type = directory}} -> @@ -165,29 +175,19 @@ setup_ejabberd_lib_path(Config) -> %% Read environment variable CT_DB=riak,mysql to limit the backends to test. %% You can thus limit the backend you want to test with: %% CT_BACKENDS=riak,mysql rebar ct suites=ejabberd -get_config_backends(Types) -> +get_config_backends() -> EnvBackends = case os:getenv("CT_BACKENDS") of - false -> Types; + false -> ?BACKENDS; String -> Backends0 = string:tokens(String, ","), - lists:map(fun(Backend) -> string:strip(Backend, both, $ ) end, Backends0) + lists:map( + fun(Backend) -> + list_to_atom(string:strip(Backend, both, $ )) + end, Backends0) end, application:load(ejabberd), - EnabledBackends = lists:map(fun(V) when is_atom(V) -> - atom_to_list(V); - (V) -> - V - end, - application:get_env(ejabberd, enabled_backends, Types)), - lists:foldl(fun(Backend, Backends) -> - case lists:member(Backend, EnabledBackends) of - false -> - lists:delete(Backend, Backends); - _ -> - Backends - end - end, EnvBackends, ["odbc", "mysql", "pgsql", - "sqlite", "riak", "redis"]). + EnabledBackends = application:get_env(ejabberd, enabled_backends, EnvBackends), + misc:intersection(EnvBackends, [mnesia, ldap, extauth|EnabledBackends]). process_config_tpl(Content, []) -> Content; @@ -489,6 +489,8 @@ wait_auth_SASL_result(Config, ShouldFail) -> set_opt(csi, true, ConfigAcc); (#rosterver_feature{}, ConfigAcc) -> set_opt(rosterver, true, ConfigAcc); + (#compression{methods = Ms}, ConfigAcc) -> + set_opt(compression, Ms, ConfigAcc); (_, ConfigAcc) -> ConfigAcc end, Config2, Fs) diff --git a/test/suite.hrl b/test/suite.hrl index b48932848..2f2abc662 100644 --- a/test/suite.hrl +++ b/test/suite.hrl @@ -100,6 +100,8 @@ -define(S2S_VHOST, <<"s2s.localhost">>). -define(UPLOAD_VHOST, <<"upload.localhost">>). +-define(BACKENDS, [mnesia, redis, mysql, pgsql, sqlite, ldap, extauth, riak]). + insert(Val, N, Tuple) -> L = tuple_to_list(Tuple), {H, T} = lists:split(N-1, L), |