Skip to content

Commit

Permalink
Ensure that rooms can be created in a secondary MUC light domain
Browse files Browse the repository at this point in the history
  • Loading branch information
arkgil committed May 8, 2018
1 parent 19fb5c6 commit 1d40acd
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions big_tests/tests/rest_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ muc_test_cases() ->
user_cant_be_invited_given_room_jid_in_a_non_muc_light_domain,
user_cant_be_removed_given_room_jid_in_a_non_muc_light_domain,
message_cant_be_sent_given_room_jid_in_a_non_muc_light_domain,
messages_cant_be_read_given_room_jid_in_a_non_muc_light_domain
messages_cant_be_read_given_room_jid_in_a_non_muc_light_domain,
room_can_be_created_in_a_secondary_muc_light_domain
].

roster_test_cases() ->
Expand All @@ -88,18 +89,29 @@ init_per_suite(C) ->
dynamic_modules:start(Host, mod_muc_light,
[{host, binary_to_list(MUCLightHost)},
{rooms_in_rosters, true}]),
NonMUCLightHost = <<"nonmuclight.", Host/binary>>, % register!
SecondaryMUCLightHost = <<"othermuclight.", Host/binary>>,
register_secondary_muc_light_service(SecondaryMUCLightHost),
NonMUCLightHost = <<"notamuclight.", Host/binary>>, % register!
[{muc_light_host, MUCLightHost},
{secondary_muc_light_host, SecondaryMUCLightHost},
{non_muc_light_host, NonMUCLightHost} | escalus:init_per_suite(C1)].

end_per_suite(Config) ->
escalus_fresh:clean(),
Host = ct:get_config({hosts, mim, domain}),
rest_helper:maybe_disable_mam(mam_helper:backend(), Host),
dynamic_modules:stop(Host, mod_muc_light),
unregister_secondary_muc_light_service(?config(secondary_muc_light_host, Config)),
application:stop(shotgun),
escalus:end_per_suite(Config).

register_secondary_muc_light_service(MUCLightHost) ->
PacketHandler = escalus_ejabberd:rpc(mongoose_packet_handler, new, [mod_muc_light]),
escalus_ejabberd:rpc(ejabberd_router, register_route, [MUCLightHost, PacketHandler]).

unregister_secondary_muc_light_service(MUCLightHost) ->
escalus_ejabberd:rpc(ejabberd_router, unregister_route, [MUCLightHost]).

init_per_group(_GN, C) ->
C.

Expand Down Expand Up @@ -451,6 +463,19 @@ messages_cant_be_read_given_room_jid_in_a_non_muc_light_domain(Config) ->
?assertEqual(<<"400">>, Status)
end).

room_can_be_created_in_a_secondary_muc_light_domain(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(Alice) ->
RoomID = <<"some_id_but_different_domain">>,
RoomJID = <<RoomID/binary, "@", (?config(secondary_muc_light_host, Config))/binary>>,
Creds = credentials({alice, Alice}),

{{Status, _}, _} = create_room_with_id_request(Creds,
<<"some_name">>,
<<"some subject">>,
RoomJID),
?assertEqual(<<"201">>, Status)
end).

assert_room_messages(RecvMsg, {_ID, _GenFrom, GenMsg}) ->
escalus:assert(is_chat_message, [maps:get(body, RecvMsg)], GenMsg),
ok.
Expand Down

0 comments on commit 1d40acd

Please sign in to comment.