fix(api): endpoint `/v5/topics` with invalid topic filter
This commit is contained in:
parent
19bc3c141f
commit
7b60928288
|
@ -115,7 +115,9 @@ do_list(Params) ->
|
||||||
{200, format_list_response(Pager, QResult)}
|
{200, format_list_response(Pager, QResult)}
|
||||||
catch
|
catch
|
||||||
throw:{error, page_limit_invalid} ->
|
throw:{error, page_limit_invalid} ->
|
||||||
{400, #{code => <<"INVALID_PARAMETER">>, message => <<"page_limit_invalid">>}}
|
{400, #{code => <<"INVALID_PARAMETER">>, message => <<"page_limit_invalid">>}};
|
||||||
|
error:{invalid_topic_filter, _} ->
|
||||||
|
{400, #{code => <<"INVALID_PARAMTER">>, message => <<"topic_filter_invalid">>}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
lookup(#{topic := Topic}) ->
|
lookup(#{topic := Topic}) ->
|
||||||
|
|
|
@ -155,3 +155,20 @@ t_shared_topics(_Configs) ->
|
||||||
),
|
),
|
||||||
|
|
||||||
ok = emqtt:stop(Client).
|
ok = emqtt:stop(Client).
|
||||||
|
|
||||||
|
t_shared_topics_invalid(_Config) ->
|
||||||
|
%% no real topic
|
||||||
|
InvalidShareTopicFilter = <<"$share/group">>,
|
||||||
|
Path = emqx_mgmt_api_test_util:api_path(["topics"]),
|
||||||
|
QS = uri_string:compose_query([
|
||||||
|
{"topic", InvalidShareTopicFilter},
|
||||||
|
{"node", atom_to_list(node())}
|
||||||
|
]),
|
||||||
|
Headers = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
|
{error, {{_, 400, _}, _RespHeaders, Body}} = emqx_mgmt_api_test_util:request_api(
|
||||||
|
get, Path, QS, Headers, [], #{return_all => true}
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"code">> := <<"INVALID_PARAMTER">>, <<"message">> := <<"topic_filter_invalid">>},
|
||||||
|
emqx_utils_json:decode(Body, [return_maps])
|
||||||
|
).
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed API endpoint `/v5/topics` to return `InternalError` with HTTP status 500 by invalid topic filter.
|
Loading…
Reference in New Issue