chore: compatible the contet-type sytanx
This commit is contained in:
parent
92ef848b30
commit
9aad7997ca
|
@ -126,7 +126,7 @@ authenticator_import_users(
|
|||
PasswordType = password_type(Req),
|
||||
Result =
|
||||
case maps:get(<<"content-type">>, Headers, undefined) of
|
||||
<<"application/json">> ->
|
||||
<<"application/json", _/binary>> ->
|
||||
emqx_authn_chains:import_users(
|
||||
?GLOBAL, AuthenticatorID, {PasswordType, prepared_user_list, Body}
|
||||
);
|
||||
|
@ -172,7 +172,7 @@ listener_authenticator_import_users(
|
|||
)
|
||||
end,
|
||||
case maps:get(<<"content-type">>, Headers, undefined) of
|
||||
<<"application/json">> ->
|
||||
<<"application/json", _/binary>> ->
|
||||
DoImport(prepared_user_list, Body);
|
||||
_ ->
|
||||
case Body of
|
||||
|
|
|
@ -342,6 +342,9 @@ test_authenticator_import_users(PathPrefix) ->
|
|||
{ok, 204, _} = request(post, ImportUri ++ "?type=hash", emqx_utils_json:decode(JSONData)),
|
||||
{ok, JSONData1} = file:read_file(filename:join([Dir, <<"data/user-credentials-plain.json">>])),
|
||||
{ok, 204, _} = request(post, ImportUri ++ "?type=plain", emqx_utils_json:decode(JSONData1)),
|
||||
|
||||
%% test application/json; charset=utf-8
|
||||
{ok, 204, _} = request_with_charset(post, ImportUri ++ "?type=plain", JSONData1),
|
||||
ok.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
|
@ -350,3 +353,9 @@ test_authenticator_import_users(PathPrefix) ->
|
|||
|
||||
request(Method, Url) ->
|
||||
request(Method, Url, []).
|
||||
|
||||
request_with_charset(Method, Url, Body) ->
|
||||
Headers = [emqx_mgmt_api_test_util:auth_header_()],
|
||||
Opts = #{compatible_mode => true, httpc_req_opts => [{body_format, binary}]},
|
||||
Request = {Url, Headers, "application/json; charset=utf-8", Body},
|
||||
emqx_mgmt_api_test_util:do_request_api(Method, Request, Opts).
|
||||
|
|
Loading…
Reference in New Issue