Skip to content

Commit

Permalink
Merge pull request #3904 from esl/c2s/merge_master
Browse files Browse the repository at this point in the history
C2s/merge master
  • Loading branch information
pawlooss1 committed Dec 16, 2022
2 parents 22ebb0b + d0ead02 commit 8756003
Show file tree
Hide file tree
Showing 95 changed files with 1,887 additions and 1,783 deletions.
2 changes: 1 addition & 1 deletion .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ jobs:
docs_build_deploy:
parallelism: 1
docker:
- image: cimg/python:3.9.0-node
- image: cimg/python:3.11.0-node
steps:
- checkout
- run:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* [Developer's guide](https://esl.github.io/MongooseDocs/latest/developers-guide/Testing-MongooseIM/)
* [Packages](https://www.erlang-solutions.com/resources/download.html)
* Product page: [https://www.erlang-solutions.com/products/mongooseim.html](https://www.erlang-solutions.com/products/mongooseim.html)
* Documentation: [https://esl.github.io/MongooseDocs/](https://esl.github.io/MongooseDocs/)
* Documentation: [https://esl.github.io/MongooseDocs/](https://esl.github.io/MongooseDocs/latest/)

## Get to know MongooseIM
MongooseIM is a robust, scalable and efficient XMPP server at the core of an Instant Messaging platform aimed at large installations.
Expand Down
4 changes: 4 additions & 0 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ all() ->
{group, mam_removal},
{group, mam_removal_incremental},
{group, inbox_removal},
{group, inbox_removal_incremental},
{group, muc_light_removal},
{group, muc_removal},
{group, private_removal},
Expand All @@ -39,6 +40,7 @@ groups() ->
{mam_removal_incremental, [], [mam_pm_removal,
mam_muc_removal]},
{inbox_removal, [], [inbox_removal]},
{inbox_removal_incremental, [], [inbox_removal]},
{muc_light_removal, [], [muc_light_removal,
muc_light_blocking_removal]},
{muc_removal, [], [muc_removal]},
Expand Down Expand Up @@ -108,6 +110,8 @@ group_to_modules(muc_removal) ->
[{mod_muc, muc_helper:make_opts(Opts)}];
group_to_modules(inbox_removal) ->
[{mod_inbox, inbox_helper:inbox_opts()}];
group_to_modules(inbox_removal_incremental) ->
[{mod_inbox, (inbox_helper:inbox_opts())#{delete_domain_limit => 1}}];
group_to_modules(private_removal) ->
[{mod_private, #{iqdisc => one_queue, backend => rdbms}}];
group_to_modules(roster_removal) ->
Expand Down
71 changes: 69 additions & 2 deletions big_tests/tests/graphql_account_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-module(graphql_account_SUITE).

-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").

-compile([export_all, nowarn_export_all]).

Expand All @@ -26,8 +27,8 @@ all() ->

groups() ->
[{user_account, [parallel], user_account_tests()},
{admin_account_http, [], admin_account_tests()},
{admin_account_cli, [], admin_account_tests()},
{admin_account_http, [], admin_account_tests() ++ admin_account_http_tests()},
{admin_account_cli, [], admin_account_tests() ++ admin_account_cli_tests()},
{domain_admin_account, [], domain_admin_tests()}].

user_account_tests() ->
Expand Down Expand Up @@ -55,6 +56,12 @@ admin_account_tests() ->
admin_change_user_password,
admin_change_non_existing_user_password].

admin_account_http_tests() ->
[admin_import_users_http].

admin_account_cli_tests() ->
[admin_import_users_cli].

domain_admin_tests() ->
[admin_list_users,
domain_admin_list_users_no_permission,
Expand Down Expand Up @@ -168,6 +175,11 @@ end_per_testcase(domain_admin_register_user = C, Config) ->
{Username, Domain} = proplists:get_value(user, Config),
rpc(mim(), mongoose_account_api, unregister_user, [Username, Domain]),
escalus:end_per_testcase(C, Config);
end_per_testcase(CaseName, Config)
when CaseName == admin_import_users_http; CaseName == admin_import_users_cli ->
Domain = domain_helper:domain(),
rpc(mim(), mongoose_account_api, unregister_user, [<<"john">>, Domain]),
escalus:end_per_testcase(CaseName, Config);
end_per_testcase(CaseName, Config) ->
escalus:end_per_testcase(CaseName, Config).

Expand Down Expand Up @@ -401,6 +413,57 @@ admin_change_non_existing_user_password(Config) ->
Resp3 = ban_user(?EMPTY_NAME_JID, NewPassword, Config),
get_coercion_err_msg(Resp3).

admin_import_users_cli(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(_Alice) ->
% Non-existing file
Resp = import_users(<<"nonexisting.csv">>, Config),
?assertEqual(<<"File not found">>, get_err_msg(Resp)),
% Summary
Path = filename:join(?config(mim_data_dir, Config), "users.csv"),
Path2 = replace_hosts_in_file(Path),
Resp2 = import_users(list_to_binary(Path2), Config),
Domain = domain_helper:domain(),
?assertEqual(#{<<"status">> => <<"Completed">>,
<<"created">> => [<<"john@", Domain/binary>>],
<<"emptyPassword">> => [<<"elise@", Domain/binary>>],
<<"existing">> => [<<"alice@", Domain/binary>>],
<<"invalidJID">> => [<<",", Domain/binary, ",password">>],
<<"invalidRecord">> => [<<"elise,elise,", Domain/binary, ",esile">>],
<<"notAllowed">> => null},
get_ok_value([data, account, importUsers], Resp2))
end).

admin_import_users_http(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(_Alice) ->
% Summary
Path = filename:join(?config(mim_data_dir, Config), "users.csv"),
Path2 = replace_hosts_in_file(Path),
Resp2 = import_users(list_to_binary(Path2), Config),
?assertEqual(#{<<"status">> => <<"ImportUsers scheduled">>,
<<"created">> => null,
<<"emptyPassword">> => null,
<<"existing">> => null,
<<"invalidJID">> => null,
<<"invalidRecord">> => null,
<<"notAllowed">> => null},
get_ok_value([data, account, importUsers], Resp2)),
Domain = domain_helper:domain(),
mongoose_helper:wait_until(fun() ->
rpc(mim(), mongoose_account_api, check_account, [<<"john">>, Domain])
end,
{ok, io_lib:format("User ~s exists", [<<"john@", Domain/binary>>])},
#{time_left => timer:seconds(20),
sleep_time => 1000,
name => verify_account_created})
end).

replace_hosts_in_file(Path) ->
{ok, Content} = file:read_file(Path),
Content2 = binary:replace(Content, <<"$host$">>, domain_helper:domain(), [global]),
Path2 = Path ++ ".tmp",
ok = file:write_file(Path2, Content2),
Path2.

domain_admin_list_users_no_permission(Config) ->
% An unknown domain
Resp1 = list_users(<<"unknown-domain">>, Config),
Expand Down Expand Up @@ -551,3 +614,7 @@ ban_user(JID, Reason, Config) ->
change_user_password(JID, NewPassword, Config) ->
Vars = #{<<"user">> => JID, <<"newPassword">> => NewPassword},
execute_command(<<"account">>, <<"changeUserPassword">>, Vars, Config).

import_users(Filename, Config) ->
Vars = #{<<"filename">> => Filename},
execute_command(<<"account">>, <<"importUsers">>, Vars, Config).
5 changes: 5 additions & 0 deletions big_tests/tests/graphql_account_SUITE_data/users.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
john,$host$,smith
alice,$host$,smith
elise,$host$,
,$host$,password
elise,elise,$host$,esile
2 changes: 1 addition & 1 deletion big_tests/tests/graphql_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ get_value([Field | Fields], Data) ->
get_value(Fields, Data2).

is_graphql_config(#{module := ejabberd_cowboy, handlers := Handlers}, ExpEpName) ->
lists:any(fun(#{module := mongoose_graphql_cowboy_handler, schema_endpoint := EpName}) ->
lists:any(fun(#{module := mongoose_graphql_handler, schema_endpoint := EpName}) ->
ExpEpName =:= EpName;
(_) -> false
end, Handlers);
Expand Down
Loading

0 comments on commit 8756003

Please sign in to comment.