Merge branch 'release-50' into merge-r50-into-v50-20230524
This commit is contained in:
commit
324459990f
|
@ -623,6 +623,30 @@ t_publish_success(Config) ->
|
||||||
),
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
t_publish_success_infinity_timeout(Config) ->
|
||||||
|
ServiceAccountJSON = ?config(service_account_json, Config),
|
||||||
|
Topic = <<"t/topic">>,
|
||||||
|
{ok, _} = create_bridge(Config, #{
|
||||||
|
<<"resource_opts">> => #{<<"request_timeout">> => <<"infinity">>}
|
||||||
|
}),
|
||||||
|
{ok, #{<<"id">> := RuleId}} = create_rule_and_action_http(Config),
|
||||||
|
on_exit(fun() -> ok = emqx_rule_engine:delete_rule(RuleId) end),
|
||||||
|
Payload = <<"payload">>,
|
||||||
|
Message = emqx_message:make(Topic, Payload),
|
||||||
|
emqx:publish(Message),
|
||||||
|
DecodedMessages = assert_http_request(ServiceAccountJSON),
|
||||||
|
?assertMatch(
|
||||||
|
[
|
||||||
|
#{
|
||||||
|
<<"topic">> := Topic,
|
||||||
|
<<"payload">> := Payload,
|
||||||
|
<<"metadata">> := #{<<"rule_id">> := RuleId}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
DecodedMessages
|
||||||
|
),
|
||||||
|
ok.
|
||||||
|
|
||||||
t_publish_success_local_topic(Config) ->
|
t_publish_success_local_topic(Config) ->
|
||||||
ResourceId = ?config(resource_id, Config),
|
ResourceId = ?config(resource_id, Config),
|
||||||
ServiceAccountJSON = ?config(service_account_json, Config),
|
ServiceAccountJSON = ?config(service_account_json, Config),
|
||||||
|
|
|
@ -422,7 +422,7 @@ decode_cursor(Cursor) ->
|
||||||
true = is_list(Name),
|
true = is_list(Name),
|
||||||
{Node, #{transfer => {ClientId, FileId}, name => Name}}
|
{Node, #{transfer => {ClientId, FileId}, name => Name}}
|
||||||
catch
|
catch
|
||||||
error:{_, invalid_json} ->
|
error:{Loc, JsonError} when is_integer(Loc), is_atom(JsonError) ->
|
||||||
error({badarg, cursor});
|
error({badarg, cursor});
|
||||||
error:{badmatch, _} ->
|
error:{badmatch, _} ->
|
||||||
error({badarg, cursor});
|
error({badarg, cursor});
|
||||||
|
|
|
@ -167,7 +167,7 @@ parse_filepath(PathBin) ->
|
||||||
throw({invalid, PathBin})
|
throw({invalid, PathBin})
|
||||||
end,
|
end,
|
||||||
PathComponents = filename:split(PathBin),
|
PathComponents = filename:split(PathBin),
|
||||||
case lists:any(fun is_special_component/1, PathComponents) of
|
case PathComponents == [] orelse lists:any(fun is_special_component/1, PathComponents) of
|
||||||
false ->
|
false ->
|
||||||
filename:join(PathComponents);
|
filename:join(PathComponents);
|
||||||
true ->
|
true ->
|
||||||
|
|
|
@ -47,6 +47,7 @@ groups() ->
|
||||||
t_invalid_topic_format,
|
t_invalid_topic_format,
|
||||||
t_meta_conflict,
|
t_meta_conflict,
|
||||||
t_nasty_clientids_fileids,
|
t_nasty_clientids_fileids,
|
||||||
|
t_nasty_filenames,
|
||||||
t_no_meta,
|
t_no_meta,
|
||||||
t_no_segment,
|
t_no_segment,
|
||||||
t_simple_transfer
|
t_simple_transfer
|
||||||
|
@ -205,10 +206,6 @@ t_invalid_filename(Config) ->
|
||||||
encode_meta(meta(lists:duplicate(1000, $A), <<>>)),
|
encode_meta(meta(lists:duplicate(1000, $A), <<>>)),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
),
|
|
||||||
?assertRCName(
|
|
||||||
success,
|
|
||||||
emqtt:publish(C, mk_init_topic(<<"f5">>), encode_meta(meta("146%", <<>>)), 1)
|
|
||||||
).
|
).
|
||||||
|
|
||||||
t_simple_transfer(Config) ->
|
t_simple_transfer(Config) ->
|
||||||
|
@ -265,6 +262,22 @@ t_nasty_clientids_fileids(_Config) ->
|
||||||
Transfers
|
Transfers
|
||||||
).
|
).
|
||||||
|
|
||||||
|
t_nasty_filenames(_Config) ->
|
||||||
|
Filenames = [
|
||||||
|
{<<"nasty1">>, "146%"},
|
||||||
|
{<<"nasty2">>, "🌚"},
|
||||||
|
{<<"nasty3">>, "中文.txt"}
|
||||||
|
],
|
||||||
|
ok = lists:foreach(
|
||||||
|
fun({ClientId, Filename}) ->
|
||||||
|
FileId = unicode:characters_to_binary(Filename),
|
||||||
|
ok = emqx_ft_test_helpers:upload_file(ClientId, FileId, Filename, FileId),
|
||||||
|
[Export] = list_files(ClientId),
|
||||||
|
?assertEqual({ok, FileId}, read_export(Export))
|
||||||
|
end,
|
||||||
|
Filenames
|
||||||
|
).
|
||||||
|
|
||||||
t_meta_conflict(Config) ->
|
t_meta_conflict(Config) ->
|
||||||
C = ?config(client, Config),
|
C = ?config(client, Config),
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,7 @@ t_download_transfer(Config) ->
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
uri(["file_transfer", "file"]) ++
|
uri(["file_transfer", "file"]) ++
|
||||||
query(#{
|
query(#{fileref => FileId, node => <<"nonode@nohost">>})
|
||||||
fileref => FileId,
|
|
||||||
node => <<"nonode@nohost">>
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -152,10 +149,25 @@ t_download_transfer(Config) ->
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
uri(["file_transfer", "file"]) ++
|
uri(["file_transfer", "file"]) ++
|
||||||
query(#{
|
query(#{fileref => <<"unknown_file">>, node => node()})
|
||||||
fileref => <<"unknown_file">>,
|
)
|
||||||
node => node()
|
),
|
||||||
})
|
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 404, #{<<"message">> := <<"Invalid query parameter", _/bytes>>}},
|
||||||
|
request_json(
|
||||||
|
get,
|
||||||
|
uri(["file_transfer", "file"]) ++
|
||||||
|
query(#{fileref => <<>>, node => node()})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 404, #{<<"message">> := <<"Invalid query parameter", _/bytes>>}},
|
||||||
|
request_json(
|
||||||
|
get,
|
||||||
|
uri(["file_transfer", "file"]) ++
|
||||||
|
query(#{fileref => <<"/etc/passwd">>, node => node()})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -204,6 +216,16 @@ t_list_files_paging(Config) ->
|
||||||
request_json(get, uri(["file_transfer", "files"]) ++ query(#{limit => 0}))
|
request_json(get, uri(["file_transfer", "files"]) ++ query(#{limit => 0}))
|
||||||
),
|
),
|
||||||
|
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 400, #{<<"code">> := <<"BAD_REQUEST">>}},
|
||||||
|
request_json(get, uri(["file_transfer", "files"]) ++ query(#{following => <<>>}))
|
||||||
|
),
|
||||||
|
|
||||||
|
?assertMatch(
|
||||||
|
{ok, 400, #{<<"code">> := <<"BAD_REQUEST">>}},
|
||||||
|
request_json(get, uri(["file_transfer", "files"]) ++ query(#{following => <<"{\"\":}">>}))
|
||||||
|
),
|
||||||
|
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
{ok, 400, #{<<"code">> := <<"BAD_REQUEST">>}},
|
{ok, 400, #{<<"code">> := <<"BAD_REQUEST">>}},
|
||||||
request_json(
|
request_json(
|
||||||
|
|
|
@ -1115,7 +1115,11 @@ date_to_unix_ts(TimeUnit, Offset, FormatString, InputString) ->
|
||||||
'$handle_undefined_function'(schema_decode, Args) ->
|
'$handle_undefined_function'(schema_decode, Args) ->
|
||||||
error({args_count_error, {schema_decode, Args}});
|
error({args_count_error, {schema_decode, Args}});
|
||||||
'$handle_undefined_function'(schema_encode, [SchemaId, Term | MoreArgs]) ->
|
'$handle_undefined_function'(schema_encode, [SchemaId, Term | MoreArgs]) ->
|
||||||
emqx_ee_schema_registry_serde:encode(SchemaId, Term, MoreArgs);
|
%% encode outputs iolists, but when the rule actions process those
|
||||||
|
%% it might wrongly encode them as JSON lists, so we force them to
|
||||||
|
%% binaries here.
|
||||||
|
IOList = emqx_ee_schema_registry_serde:encode(SchemaId, Term, MoreArgs),
|
||||||
|
iolist_to_binary(IOList);
|
||||||
'$handle_undefined_function'(schema_encode, Args) ->
|
'$handle_undefined_function'(schema_encode, Args) ->
|
||||||
error({args_count_error, {schema_encode, Args}});
|
error({args_count_error, {schema_encode, Args}});
|
||||||
'$handle_undefined_function'(sprintf, [Format | Args]) ->
|
'$handle_undefined_function'(sprintf, [Format | Args]) ->
|
||||||
|
|
|
@ -82,8 +82,12 @@ make_trace_fn_action() ->
|
||||||
#{function => Fn, args => #{}}.
|
#{function => Fn, args => #{}}.
|
||||||
|
|
||||||
create_rule_http(RuleParams) ->
|
create_rule_http(RuleParams) ->
|
||||||
|
create_rule_http(RuleParams, _Overrides = #{}).
|
||||||
|
|
||||||
|
create_rule_http(RuleParams, Overrides) ->
|
||||||
RepublishTopic = <<"republish/schema_registry">>,
|
RepublishTopic = <<"republish/schema_registry">>,
|
||||||
emqx:subscribe(RepublishTopic),
|
emqx:subscribe(RepublishTopic),
|
||||||
|
PayloadTemplate = maps:get(payload_template, Overrides, <<>>),
|
||||||
DefaultParams = #{
|
DefaultParams = #{
|
||||||
enable => true,
|
enable => true,
|
||||||
actions => [
|
actions => [
|
||||||
|
@ -93,7 +97,7 @@ create_rule_http(RuleParams) ->
|
||||||
<<"args">> =>
|
<<"args">> =>
|
||||||
#{
|
#{
|
||||||
<<"topic">> => RepublishTopic,
|
<<"topic">> => RepublishTopic,
|
||||||
<<"payload">> => <<>>,
|
<<"payload">> => PayloadTemplate,
|
||||||
<<"qos">> => 0,
|
<<"qos">> => 0,
|
||||||
<<"retain">> => false,
|
<<"retain">> => false,
|
||||||
<<"user_properties">> => <<>>
|
<<"user_properties">> => <<>>
|
||||||
|
@ -177,10 +181,12 @@ test_params_for(avro, encode1) ->
|
||||||
"from t\n"
|
"from t\n"
|
||||||
>>,
|
>>,
|
||||||
Payload = #{<<"i">> => 10, <<"s">> => <<"text">>},
|
Payload = #{<<"i">> => 10, <<"s">> => <<"text">>},
|
||||||
|
PayloadTemplate = <<"${.encoded}">>,
|
||||||
ExtraArgs = [],
|
ExtraArgs = [],
|
||||||
#{
|
#{
|
||||||
sql => SQL,
|
sql => SQL,
|
||||||
payload => Payload,
|
payload => Payload,
|
||||||
|
payload_template => PayloadTemplate,
|
||||||
extra_args => ExtraArgs
|
extra_args => ExtraArgs
|
||||||
};
|
};
|
||||||
test_params_for(avro, decode1) ->
|
test_params_for(avro, decode1) ->
|
||||||
|
@ -251,10 +257,12 @@ test_params_for(protobuf, encode1) ->
|
||||||
"from t\n"
|
"from t\n"
|
||||||
>>,
|
>>,
|
||||||
Payload = #{<<"name">> => <<"some name">>, <<"id">> => 10, <<"email">> => <<"emqx@emqx.io">>},
|
Payload = #{<<"name">> => <<"some name">>, <<"id">> => 10, <<"email">> => <<"emqx@emqx.io">>},
|
||||||
|
PayloadTemplate = <<"${.encoded}">>,
|
||||||
ExtraArgs = [<<"Person">>],
|
ExtraArgs = [<<"Person">>],
|
||||||
#{
|
#{
|
||||||
sql => SQL,
|
sql => SQL,
|
||||||
payload => Payload,
|
payload => Payload,
|
||||||
|
payload_template => PayloadTemplate,
|
||||||
extra_args => ExtraArgs
|
extra_args => ExtraArgs
|
||||||
};
|
};
|
||||||
test_params_for(protobuf, union1) ->
|
test_params_for(protobuf, union1) ->
|
||||||
|
@ -487,17 +495,18 @@ t_encode(Config) ->
|
||||||
#{
|
#{
|
||||||
sql := SQL,
|
sql := SQL,
|
||||||
payload := Payload,
|
payload := Payload,
|
||||||
|
payload_template := PayloadTemplate,
|
||||||
extra_args := ExtraArgs
|
extra_args := ExtraArgs
|
||||||
} = test_params_for(SerdeType, encode1),
|
} = test_params_for(SerdeType, encode1),
|
||||||
{ok, _} = create_rule_http(#{sql => SQL}),
|
{ok, _} = create_rule_http(#{sql => SQL}, #{payload_template => PayloadTemplate}),
|
||||||
PayloadBin = emqx_utils_json:encode(Payload),
|
PayloadBin = emqx_utils_json:encode(Payload),
|
||||||
emqx:publish(emqx_message:make(<<"t">>, PayloadBin)),
|
emqx:publish(emqx_message:make(<<"t">>, PayloadBin)),
|
||||||
Published = receive_published(?LINE),
|
Published = receive_published(?LINE),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
#{payload := #{<<"encoded">> := _}},
|
#{payload := P} when is_binary(P),
|
||||||
Published
|
Published
|
||||||
),
|
),
|
||||||
#{payload := #{<<"encoded">> := Encoded}} = Published,
|
#{payload := Encoded} = Published,
|
||||||
{ok, #{deserializer := Deserializer}} = emqx_ee_schema_registry:get_serde(SerdeName),
|
{ok, #{deserializer := Deserializer}} = emqx_ee_schema_registry:get_serde(SerdeName),
|
||||||
?assertEqual(Payload, apply(Deserializer, [Encoded | ExtraArgs])),
|
?assertEqual(Payload, apply(Deserializer, [Encoded | ExtraArgs])),
|
||||||
ok.
|
ok.
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -49,7 +49,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:redbug, "2.0.8"},
|
{:redbug, "2.0.8"},
|
||||||
{:covertool, github: "zmstone/covertool", tag: "2.0.4.1", override: true},
|
{:covertool, github: "zmstone/covertool", tag: "2.0.4.1", override: true},
|
||||||
{:typerefl, github: "ieQu1/typerefl", tag: "0.9.1", override: true},
|
{:typerefl, github: "ieQu1/typerefl", tag: "0.9.1", override: true},
|
||||||
{:ehttpc, github: "emqx/ehttpc", tag: "0.4.8", override: true},
|
{:ehttpc, github: "emqx/ehttpc", tag: "0.4.10", override: true},
|
||||||
{:gproc, github: "emqx/gproc", tag: "0.9.0.1", override: true},
|
{:gproc, github: "emqx/gproc", tag: "0.9.0.1", override: true},
|
||||||
{:jiffy, github: "emqx/jiffy", tag: "1.0.5", override: true},
|
{:jiffy, github: "emqx/jiffy", tag: "1.0.5", override: true},
|
||||||
{:cowboy, github: "emqx/cowboy", tag: "2.9.0", override: true},
|
{:cowboy, github: "emqx/cowboy", tag: "2.9.0", override: true},
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
, {gpb, "4.19.7"}
|
, {gpb, "4.19.7"}
|
||||||
, {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}}
|
, {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}}
|
||||||
, {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}}
|
, {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}}
|
||||||
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.8"}}}
|
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.10"}}}
|
||||||
, {gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}}
|
, {gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}}
|
||||||
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}
|
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}
|
||||||
, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.0"}}}
|
, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.0"}}}
|
||||||
|
|
Loading…
Reference in New Issue