diff --git a/big_tests/tests/xep_0352_csi_SUITE.erl b/big_tests/tests/xep_0352_csi_SUITE.erl index 753a84de175..a991a1be68b 100644 --- a/big_tests/tests/xep_0352_csi_SUITE.erl +++ b/big_tests/tests/xep_0352_csi_SUITE.erl @@ -28,7 +28,8 @@ all_tests() -> alice_gets_buffered_messages_after_reconnection_with_sm, alice_gets_buffered_messages_after_stream_resumption, bob_gets_msgs_from_inactive_alice, - alice_is_inactive_but_sends_sm_req_and_recives_ack + alice_is_inactive_but_sends_sm_req_and_recives_ack, + invalid_csi_request_returns_error ]. suite() -> @@ -65,6 +66,13 @@ server_announces_csi(Config) -> {ok, _Client, Features} = escalus_connection:start(Spec, Steps), true = proplists:get_value(client_state_indication, Features). +invalid_csi_request_returns_error(Config) -> + escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> + escalus:send(Alice, csi_stanza(<<"invalid">>)), + Stanza = escalus:wait_for_stanza(Alice), + escalus:assert(is_error, [<<"modify">>, <<"bad-request">>], Stanza) + end). + alice_is_inactive_and_no_stanza_arrived(Config) -> escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) -> given_client_is_inactive_and_no_messages_arrive(Alice), diff --git a/src/mod_csi.erl b/src/mod_csi.erl index f53d0acf2db..d84e35a409e 100644 --- a/src/mod_csi.erl +++ b/src/mod_csi.erl @@ -147,7 +147,12 @@ reroute_unacked_messages(Acc, #{c2s_data := C2SData}, _) -> handle_csi_request(Acc, Params, #xmlel{name = <<"inactive">>}) -> handle_inactive_request(Acc, Params); handle_csi_request(Acc, Params, #xmlel{name = <<"active">>}) -> - handle_active_request(Acc, Params). + handle_active_request(Acc, Params); +handle_csi_request(Acc, _, _) -> + {From, To, El} = mongoose_acc:packet(Acc), + Error = jlib:make_error_reply(El, mongoose_xmpp_errors:bad_request()), + ErrorAcc = mongoose_acc:update_stanza(#{from_jid => From, to_jid => To, element => Error }, Acc), + mongoose_c2s_acc:to_acc(Acc, route, ErrorAcc). -spec handle_inactive_request(mongoose_acc:t(), mongoose_c2s_hooks:params()) -> mongoose_acc:t(). handle_inactive_request(Acc, #{c2s_data := C2SData} = _Params) ->