fix(emqx_authz_api_sources): return 'code' in response body for 404
This commit is contained in:
parent
073989834b
commit
e0ed0855ff
|
@ -241,7 +241,7 @@ source(Method, #{bindings := #{type := Type} = Bindings} = Req) when
|
||||||
source(get, #{bindings := #{type := Type}}) ->
|
source(get, #{bindings := #{type := Type}}) ->
|
||||||
case get_raw_source(Type) of
|
case get_raw_source(Type) of
|
||||||
[] ->
|
[] ->
|
||||||
{404, #{message => <<"Not found ", Type/binary>>}};
|
{404, #{code => <<"NOT_FOUND">>, message => <<"Not found ", Type/binary>>}};
|
||||||
[#{<<"type">> := <<"file">>, <<"enable">> := Enable, <<"path">> := Path}] ->
|
[#{<<"type">> := <<"file">>, <<"enable">> := Enable, <<"path">> := Path}] ->
|
||||||
case file:read_file(Path) of
|
case file:read_file(Path) of
|
||||||
{ok, Rules} ->
|
{ok, Rules} ->
|
||||||
|
|
|
@ -181,6 +181,12 @@ t_api(_) ->
|
||||||
{ok, 200, Result1} = request(get, uri(["authorization", "sources"]), []),
|
{ok, 200, Result1} = request(get, uri(["authorization", "sources"]), []),
|
||||||
?assertEqual([], get_sources(Result1)),
|
?assertEqual([], get_sources(Result1)),
|
||||||
|
|
||||||
|
{ok, 404, ErrResult} = request(get, uri(["authorization", "sources", "http"]), []),
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"code">> := <<"NOT_FOUND">>, <<"message">> := <<"Not found http">>},
|
||||||
|
jsx:decode(ErrResult)
|
||||||
|
),
|
||||||
|
|
||||||
[
|
[
|
||||||
begin
|
begin
|
||||||
{ok, 204, _} = request(post, uri(["authorization", "sources"]), Source)
|
{ok, 204, _} = request(post, uri(["authorization", "sources"]), Source)
|
||||||
|
|
Loading…
Reference in New Issue