refactor: return `204` instead of `200` for `PUT /authenticator/:id`

This commit is contained in:
Stefan Strigler 2022-11-28 11:27:44 +01:00
parent 5b4feca3cb
commit 3bda905e92
5 changed files with 12 additions and 10 deletions

View File

@ -1006,11 +1006,10 @@ update_authenticator(ConfKeyPath, ChainName, AuthenticatorID, Config) ->
)
of
{ok, #{
post_config_update := #{emqx_authentication := #{id := ID}},
raw_config := AuthenticatorsConfig
post_config_update := #{emqx_authentication := #{id := _ID}},
raw_config := _AuthenticatorsConfig
}} ->
{ok, AuthenticatorConfig} = find_config(ID, AuthenticatorsConfig),
{200, maps:put(id, ID, convert_certs(fill_defaults(AuthenticatorConfig)))};
{204};
{error, {_PrePostConfigUpdate, emqx_authentication, Reason}} ->
serialize_error(Reason);
{error, Reason} ->

View File

@ -22,7 +22,6 @@
-include("emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
-define(TCP_DEFAULT, 'tcp:default').
@ -42,7 +41,7 @@ groups() ->
init_per_testcase(t_authenticator_fail, Config) ->
meck:expect(emqx_authn_proto_v1, lookup_from_all_nodes, 3, [{error, {exception, badarg}}]),
init_per_testcase(default, Config);
init_per_testcase(_, Config) ->
init_per_testcase(_Case, Config) ->
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
emqx_authn_test_lib:delete_authenticators(
[?CONF_NS_ATOM],
@ -213,7 +212,7 @@ test_authenticators(PathPrefix) ->
method => <<"get">>,
headers => #{<<"content-type">> => <<"application/json">>}
},
{ok, 200, _} = request(
{ok, 204, _} = request(
put,
uri(PathPrefix ++ [?CONF_NS, "password_based:http"]),
ValidConfig1
@ -302,14 +301,14 @@ test_authenticator(PathPrefix) ->
method => <<"get">>,
headers => #{<<"content-type">> => <<"application/json">>}
},
{ok, 200, _} = request(
{ok, 204, _} = request(
put,
uri(PathPrefix ++ [?CONF_NS, "password_based:http"]),
ValidConfig1
),
ValidConfig2 = ValidConfig0#{pool_size => 9},
{ok, 200, _} = request(
{ok, 204, _} = request(
put,
uri(PathPrefix ++ [?CONF_NS, "password_based:http"]),
ValidConfig2

View File

@ -448,7 +448,7 @@ t_jwt_not_allow_empty_claim_name(_) ->
),
?assertMatch(
{200, _},
{204},
emqx_authn_api:authenticator(
put, #{
bindings => #{id => <<"jwt">>},

View File

@ -14,6 +14,8 @@
- Refactor authn API by replacing `POST /authentication/{id}/move` with `PUT /authentication/{id}/position/{position}`. [#9419](https://github.com/emqx/emqx/pull/9419).
Same is done for `/listeners/{listener_id}/authentication/id/...`.
- Return `204` instead of `200` for `PUT /authenticator/:id` [#9434](https://github.com/emqx/emqx/pull/9434/).
## Bug fixes
- Fix that the obsolete SSL files aren't deleted after the ExHook config update [#9432](https://github.com/emqx/emqx/pull/9432).

View File

@ -4,6 +4,8 @@
- 通过 `node.global_gc_interval = disabled` 来禁用全局垃圾回收 [#9418](https://github.com/emqx/emqx/pull/9418)。
- 现在,`PUT /authenticator/:id` 将会返回 204 而不再是 200 [#9434](https://github.com/emqx/emqx/pull/9434/)。
- 优化命令行实现, 避免输入错误指令时, 产生不必要的原子表消耗 [#9416](https://github.com/emqx/emqx/pull/9416)。
- 支持在 Apple Silicon 架构下编译苹果系统的发行版本 [#9423](https://github.com/emqx/emqx/pull/9423)。