fix(emqx_management): return 404 if plugin does not exist
This commit is contained in:
parent
3fd28f9e18
commit
80e4ffff75
|
@ -132,6 +132,7 @@ schema("/plugins/:name") ->
|
|||
parameters => [hoconsc:ref(name)],
|
||||
responses => #{
|
||||
204 => <<"Uninstall successfully">>,
|
||||
400 => emqx_dashboard_swagger:error_codes(['PARAM_ERROR'], <<"Bad parameter">>),
|
||||
404 => emqx_dashboard_swagger:error_codes(['NOT_FOUND'], <<"Plugin Not Found">>)
|
||||
}
|
||||
}
|
||||
|
@ -484,6 +485,8 @@ ensure_action(Name, restart) ->
|
|||
|
||||
return(Code, ok) ->
|
||||
{Code};
|
||||
return(_, {error, #{error := "bad_info_file", return := {enoent, _} = Reason}}) ->
|
||||
{404, #{code => 'NOT_FOUND', message => iolist_to_binary(io_lib:format("~p", [Reason]))}};
|
||||
return(_, {error, Reason}) ->
|
||||
{400, #{code => 'PARAM_ERROR', message => iolist_to_binary(io_lib:format("~p", [Reason]))}}.
|
||||
|
||||
|
|
|
@ -133,6 +133,14 @@ t_bad_plugin(Config) ->
|
|||
)
|
||||
).
|
||||
|
||||
t_delete_non_existing(_Config) ->
|
||||
Path = emqx_mgmt_api_test_util:api_path(["plugins", "non_exists"]),
|
||||
?assertMatch(
|
||||
{error, {_, 404, _}},
|
||||
emqx_mgmt_api_test_util:request_api(delete, Path)
|
||||
),
|
||||
ok.
|
||||
|
||||
list_plugins() ->
|
||||
Path = emqx_mgmt_api_test_util:api_path(["plugins"]),
|
||||
case emqx_mgmt_api_test_util:request_api(get, Path) of
|
||||
|
|
Loading…
Reference in New Issue