25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Merge pull request #1837 from marcphilipp/feature/set_room_affiliation_test

Add integration test for set_room_affiliation
This commit is contained in:
Christophe Romain 2017-08-02 14:34:30 +02:00 committed by GitHub
commit f65492e27f
2 changed files with 36 additions and 1 deletions

View File

@ -450,6 +450,8 @@ listen:
port: @@web_port@@ port: @@web_port@@
module: ejabberd_http module: ejabberd_http
captcha: true captcha: true
request_handlers:
"/api": mod_http_api
- -
port: @@component_port@@ port: @@component_port@@
module: ejabberd_service module: ejabberd_service
@ -466,6 +468,7 @@ modules:
mod_proxy65: [] mod_proxy65: []
mod_legacy: [] mod_legacy: []
mod_muc: [] mod_muc: []
mod_muc_admin: []
mod_register: mod_register:
welcome_message: welcome_message:
subject: "Welcome!" subject: "Welcome!"
@ -488,3 +491,8 @@ outgoing_s2s_port: @@s2s_port@@
shaper: shaper:
fast: 50000 fast: 50000
normal: 10000 normal: 10000
api_permissions:
"public commands":
who: all
what: "*"

View File

@ -53,7 +53,8 @@ single_cases() ->
single_test(service_vcard), single_test(service_vcard),
single_test(configure_non_existent), single_test(configure_non_existent),
single_test(cancel_configure_non_existent), single_test(cancel_configure_non_existent),
single_test(service_subscriptions)]}. single_test(service_subscriptions),
single_test(set_room_affiliation)]}.
service_presence_error(Config) -> service_presence_error(Config) ->
Service = muc_jid(Config), Service = muc_jid(Config),
@ -242,6 +243,32 @@ service_subscriptions(Config) ->
end, Rooms), end, Rooms),
disconnect(Config). disconnect(Config).
set_room_affiliation(Config) ->
#jid{server = RoomService} = muc_jid(Config),
RoomName = <<"set_room_affiliation">>,
RoomJID = jid:make(RoomName, RoomService),
MyJID = my_jid(Config),
PeerJID = jid:remove_resource(?config(slave, Config)),
ct:pal("joining room ~p", [RoomJID]),
ok = join_new(Config, RoomJID),
ct:pal("setting affiliation in room ~p to 'member' for ~p", [RoomJID, PeerJID]),
ServerHost = ?config(server_host, Config),
WebPort = ct:get_config(web_port, 5280),
RequestURL = "http://" ++ ServerHost ++ ":" ++ integer_to_list(WebPort) ++ "/api/set_room_affiliation",
Headers = [{"X-Admin", "true"}],
ContentType = "application/json",
Body = jiffy:encode(#{name => RoomName, service => RoomService, jid => jid:encode(PeerJID), affiliation => member}),
{ok, {{_, 200, _}, _, _}} = httpc:request(post, {RequestURL, Headers, ContentType, Body}, [], []),
#message{id = _, from = RoomJID, to = MyJID, sub_els = [
#muc_user{items = [
#muc_item{affiliation = member, role = none, jid = PeerJID}]}]} = recv_message(Config),
ok = leave(Config, RoomJID),
disconnect(Config).
%%%=================================================================== %%%===================================================================
%%% Master-slave tests %%% Master-slave tests
%%%=================================================================== %%%===================================================================