Skip to content

Commit

Permalink
Merge pull request #3246 from esl/test-commands
Browse files Browse the repository at this point in the history
Test MUC Light commands for dynamic domains
  • Loading branch information
vkatsuba authored Sep 7, 2021
2 parents 55fb5da + 14c71b8 commit 6649962
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
2 changes: 2 additions & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

{suites, "tests", muc_light_legacy_SUITE}.

{suites, "tests", muc_light_http_api_SUITE}.

{suites, "tests", offline_SUITE}.

{suites, "tests", offline_stub_SUITE}.
Expand Down
44 changes: 21 additions & 23 deletions big_tests/tests/muc_light_http_api_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

-import(muc_light_helper, [stanza_create_room/3]).
-import(distributed_helper, [subhost_pattern/1]).
-import(domain_helper, [host_type/0]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand All @@ -38,9 +39,8 @@ all() ->
{group, negative}].

groups() ->
G = [{positive, [parallel], success_response()},
{negative, [parallel], negative_response()}],
ct_helper:repeat_all_until_all_ok(G).
[{positive, [parallel], success_response()},
{negative, [parallel], negative_response()}].

success_response() ->
[create_unique_room,
Expand All @@ -62,15 +62,15 @@ negative_response() ->
%%--------------------------------------------------------------------

init_per_suite(Config) ->
dynamic_modules:start(<<"localhost">>, mod_muc_light,
[{host, subhost_pattern(muc_light_domain())},
dynamic_modules:start(host_type(), mod_muc_light,
[{host, subhost_pattern(muc_light_helper:muc_host_pattern())},
{rooms_in_rosters, true},
{backend, mongoose_helper:mnesia_or_rdbms_backend()}]),
escalus:init_per_suite(Config).

end_per_suite(Config) ->
escalus_fresh:clean(),
dynamic_modules:stop(<<"localhost">>, mod_muc_light),
dynamic_modules:stop(host_type(), mod_muc_light),
escalus:end_per_suite(Config).

init_per_group(_GroupName, Config) ->
Expand All @@ -92,8 +92,7 @@ end_per_testcase(CaseName, Config) ->

create_unique_room(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(Alice) ->
Domain = <<"localhost">>,
Path = <<"/muc-lights", $/, Domain/binary>>,
Path = path([domain()]),
Name = <<"wonderland">>,
Body = #{ name => Name,
owner => escalus_client:short_jid(Alice),
Expand All @@ -108,8 +107,7 @@ create_unique_room(Config) ->

create_identifiable_room(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(Alice) ->
Domain = <<"localhost">>,
Path = <<"/muc-lights", $/, Domain/binary>>,
Path = path([domain()]),
RandBits = base16:encode(crypto:strong_rand_bytes(5)),
Name = <<"wonderland">>,
RoomID = <<"just_some_id_", RandBits/binary>>,
Expand All @@ -129,10 +127,8 @@ create_identifiable_room(Config) ->
end).

invite_to_room(Config) ->
Domain = muc_light_domain(),
Name = <<"wonderland">>,
Path = <<"/muc-lights", $/, Domain/binary, $/, Name/binary, $/,
"participants">>,
Path = path([muc_light_domain(), Name, "participants"]),
escalus:fresh_story(Config, [{alice, 1}, {bob, 1}, {kate, 1}],
fun(Alice, Bob, Kate) ->
%% XMPP: Alice creates a room.
Expand All @@ -158,10 +154,8 @@ invite_to_room(Config) ->
end).

send_message_to_room(Config) ->
Domain = muc_light_domain(),
Name = <<"wonderland">>,
Path = <<"/muc-lights",$/,Domain/binary,$/,
Name/binary,$/,"messages">>,
Path = path([muc_light_domain(), Name, "messages"]),
Text = <<"Hello everyone!">>,
escalus:fresh_story(Config,
[{alice, 1}, {bob, 1}, {kate, 1}],
Expand Down Expand Up @@ -229,8 +223,7 @@ delete_room_without_having_a_membership(Config) ->

create_non_unique_room(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(Alice) ->
Domain = <<"localhost">>,
Path = <<"/muc-lights", $/, Domain/binary>>,
Path = path([domain()]),
RandBits = base16:encode(crypto:strong_rand_bytes(5)),
Name = <<"wonderland">>,
RoomID = <<"just_some_id_", RandBits/binary>>,
Expand Down Expand Up @@ -298,15 +291,20 @@ check_delete_room(Config, RoomNameToCreate, RoomNameToDelete, RoomOwner,
escalus:assert(is_iq_result, CreationResult),
muc_light_helper:verify_aff_bcast(Members, Affiliations),
ShortJID = escalus_client:short_jid(UserToExecuteDelete),
Path = <<"/muc-lights",$/,Domain/binary,$/,
RoomNameToDelete/binary,$/,ShortJID/binary,$/,"management">>,
Path = path([muc_light_domain(), RoomNameToDelete, ShortJID, "management"]),
rest_helper:delete(admin, Path).


%%--------------------------------------------------------------------
%% Constants
%% Helpers
%%--------------------------------------------------------------------

path(Items) ->
AllItems = ["muc-lights" | Items],
iolist_to_binary([[$/, Item] || Item <- AllItems]).

muc_light_domain() ->
XMPPParentDomain = ct:get_config({hosts, mim, domain}),
<<"muclight", ".", XMPPParentDomain/binary>>.
muc_light_helper:muc_host().

domain() ->
ct:get_config({hosts, mim, domain}).
2 changes: 2 additions & 0 deletions rel/mim1.vars-toml.config
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

[host_config.modules.mod_commands]

[host_config.modules.mod_muc_light_commands]

[host_config.modules.mod_stream_management]

[host_config.modules.mod_disco]
Expand Down
3 changes: 0 additions & 3 deletions src/mod_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ stop(_) -> stop().

-spec supported_features() -> [atom()].
supported_features() ->
%% TODO: this module should be reworked into service
%% from the quick look it seems that the conversion for dynamic domains is done,
%% but there's no testing for this module enabled at dynamic_domains.spec yet.
[dynamic_domains].

%%%
Expand Down
3 changes: 0 additions & 3 deletions src/muc_light/mod_muc_light_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ stop(_) ->

-spec supported_features() -> [atom()].
supported_features() ->
%% TODO: this module should be reworked into service
%% from the quick look it seems that the conversion for dynamic domains is done,
%% but there's no testing for this module enabled at dynamic_domains.spec yet.
[dynamic_domains].

%%--------------------------------------------------------------------
Expand Down

0 comments on commit 6649962

Please sign in to comment.