test(frame): variable_byte_integer and proxy_protocol disabled
This commit is contained in:
parent
3505e286ba
commit
c5c3f78c5a
|
@ -78,6 +78,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
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -44,7 +44,9 @@ groups() ->
|
||||||
[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_malformed_utf8_string
|
t_parse_frame_variable_byte_integer,
|
||||||
|
t_parse_malformed_utf8_string,
|
||||||
|
t_parse_frame_proxy_protocol %% proxy_protocol_config_disabled packet.
|
||||||
]},
|
]},
|
||||||
{connect, [parallel],
|
{connect, [parallel],
|
||||||
[t_serialize_parse_v3_connect,
|
[t_serialize_parse_v3_connect,
|
||||||
|
@ -137,6 +139,10 @@ t_parse_frame_malformed_variable_byte_integer(_) ->
|
||||||
?catch_error(malformed_variable_byte_integer,
|
?catch_error(malformed_variable_byte_integer,
|
||||||
emqx_frame:parse(MalformedPayload, ParseState)).
|
emqx_frame:parse(MalformedPayload, ParseState)).
|
||||||
|
|
||||||
|
t_parse_frame_variable_byte_integer(_) ->
|
||||||
|
Bin = <<2#10010011, 2#10000000, 2#10001000, 2#10011001, 2#10101101, 2#00110010>>,
|
||||||
|
?catch_error(malformed_variable_byte_integer,
|
||||||
|
emqx_frame:parse_variable_byte_integer(Bin)).
|
||||||
|
|
||||||
t_parse_malformed_utf8_string(_) ->
|
t_parse_malformed_utf8_string(_) ->
|
||||||
MalformedPacket = <<16,31,0,4,
|
MalformedPacket = <<16,31,0,4,
|
||||||
|
@ -155,6 +161,13 @@ t_parse_malformed_utf8_string(_) ->
|
||||||
ParseState = emqx_frame:initial_parse_state(#{strict_mode => true}),
|
ParseState = emqx_frame:initial_parse_state(#{strict_mode => true}),
|
||||||
?catch_error(utf8_string_invalid, emqx_frame:parse(MalformedPacket, ParseState)).
|
?catch_error(utf8_string_invalid, emqx_frame:parse(MalformedPacket, ParseState)).
|
||||||
|
|
||||||
|
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,
|
||||||
|
@ -550,4 +563,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)).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue