test(frame): test packet proxy_protocol config disabled

This commit is contained in:
JimMoen 2021-12-09 16:35:18 +08:00
parent b9acf94fd7
commit 3ecc79e1bc
2 changed files with 14 additions and 2 deletions

View File

@ -80,6 +80,10 @@
-dialyzer({no_match, [serialize_utf8_string/2]}). -dialyzer({no_match, [serialize_utf8_string/2]}).
-ifdef(TEST).
-export([parse_variable_byte_integer/1]).
-endif.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Init Parse State %% Init Parse State
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -43,7 +43,9 @@ groups() ->
[{parse, [parallel], [{parse, [parallel],
[t_parse_cont, [t_parse_cont,
t_parse_frame_too_large, t_parse_frame_too_large,
t_parse_frame_malformed_variable_byte_integer t_parse_frame_malformed_variable_byte_integer,
t_parse_frame_variable_byte_integer,
t_parse_frame_proxy_protocol %% proxy_protocol_config_disabled packet.
]}, ]},
{connect, [parallel], {connect, [parallel],
[t_serialize_parse_v3_connect, [t_serialize_parse_v3_connect,
@ -142,6 +144,13 @@ t_parse_frame_variable_byte_integer(_) ->
?catch_error(malformed_variable_byte_integer, ?catch_error(malformed_variable_byte_integer,
emqx_frame:parse_variable_byte_integer(Bin)). emqx_frame:parse_variable_byte_integer(Bin)).
t_parse_frame_proxy_protocol(_) ->
BinList = [ <<"PROXY TCP4 ">>, <<"PROXY TCP6 ">>, <<"PROXY UNKNOWN">>
, <<"\r\n\r\n\0\r\nQUIT\n">>],
[?assertError( proxy_protocol_config_disabled
, emqx_frame:parse(Bin))
|| Bin <- BinList].
t_serialize_parse_v3_connect(_) -> t_serialize_parse_v3_connect(_) ->
Bin = <<16,37,0,6,77,81,73,115,100,112,3,2,0,60,0,23,109,111,115, Bin = <<16,37,0,6,77,81,73,115,100,112,3,2,0,60,0,23,109,111,115,
113,112,117, 98,47,49,48,52,53,49,45,105,77,97,99,46,108, 113,112,117, 98,47,49,48,52,53,49,45,105,77,97,99,46,108,
@ -555,4 +564,3 @@ parse_to_packet(Bin, Opts) ->
Packet. Packet.
payload(Len) -> iolist_to_binary(lists:duplicate(Len, 1)). payload(Len) -> iolist_to_binary(lists:duplicate(Len, 1)).