@@ -64,7 +64,9 @@ groups() ->
6464 test_super_stream_duplicate_partitions ,
6565 authentication_error_should_close_with_delay ,
6666 unauthorized_vhost_access_should_close_with_delay ,
67- sasl_anonymous
67+ sasl_anonymous ,
68+ test_publisher_with_too_long_reference_errors ,
69+ test_consumer_with_too_long_reference_errors
6870 ]},
6971 % % Run `test_global_counters` on its own so the global metrics are
7072 % % initialised to 0 for each testcase
@@ -945,6 +947,70 @@ unauthorized_vhost_access_should_close_with_delay(Config) ->
945947 closed = wait_for_socket_close (T , S , 10 ),
946948 ok .
947949
950+ test_publisher_with_too_long_reference_errors (Config ) ->
951+ FunctionName = atom_to_binary (? FUNCTION_NAME , utf8 ),
952+ T = gen_tcp ,
953+ Port = get_port (T , Config ),
954+ Opts = get_opts (T ),
955+ {ok , S } = T :connect (" localhost" , Port , Opts ),
956+ C = rabbit_stream_core :init (0 ),
957+ ConnectionName = FunctionName ,
958+ test_peer_properties (T , S , #{<<" connection_name" >> => ConnectionName }, C ),
959+ test_authenticate (T , S , C ),
960+
961+ Stream = FunctionName ,
962+ test_create_stream (T , S , Stream , C ),
963+
964+ MaxSize = 255 ,
965+ ReferenceOK = iolist_to_binary (lists :duplicate (MaxSize , <<" a" >>)),
966+ ReferenceKO = iolist_to_binary (lists :duplicate (MaxSize + 1 , <<" a" >>)),
967+
968+ Tests = [{1 , ReferenceOK , ? RESPONSE_CODE_OK },
969+ {2 , ReferenceKO , ? RESPONSE_CODE_PRECONDITION_FAILED }],
970+
971+ [begin
972+ F = request ({declare_publisher , PubId , Ref , Stream }),
973+ ok = T :send (S , F ),
974+ {Cmd , C } = receive_commands (T , S , C ),
975+ ? assertMatch ({response , 1 , {declare_publisher , ExpectedResponseCode }}, Cmd )
976+ end || {PubId , Ref , ExpectedResponseCode } <- Tests ],
977+
978+ test_delete_stream (T , S , Stream , C ),
979+ test_close (T , S , C ),
980+ ok .
981+
982+ test_consumer_with_too_long_reference_errors (Config ) ->
983+ FunctionName = atom_to_binary (? FUNCTION_NAME , utf8 ),
984+ T = gen_tcp ,
985+ Port = get_port (T , Config ),
986+ Opts = get_opts (T ),
987+ {ok , S } = T :connect (" localhost" , Port , Opts ),
988+ C = rabbit_stream_core :init (0 ),
989+ ConnectionName = FunctionName ,
990+ test_peer_properties (T , S , #{<<" connection_name" >> => ConnectionName }, C ),
991+ test_authenticate (T , S , C ),
992+
993+ Stream = FunctionName ,
994+ test_create_stream (T , S , Stream , C ),
995+
996+ MaxSize = 255 ,
997+ ReferenceOK = iolist_to_binary (lists :duplicate (MaxSize , <<" a" >>)),
998+ ReferenceKO = iolist_to_binary (lists :duplicate (MaxSize + 1 , <<" a" >>)),
999+
1000+ Tests = [{1 , ReferenceOK , ? RESPONSE_CODE_OK },
1001+ {2 , ReferenceKO , ? RESPONSE_CODE_PRECONDITION_FAILED }],
1002+
1003+ [begin
1004+ F = request ({subscribe , SubId , Stream , first , 1 , #{<<" name" >> => Ref }}),
1005+ ok = T :send (S , F ),
1006+ {Cmd , C } = receive_commands (T , S , C ),
1007+ ? assertMatch ({response , 1 , {subscribe , ExpectedResponseCode }}, Cmd )
1008+ end || {SubId , Ref , ExpectedResponseCode } <- Tests ],
1009+
1010+ test_delete_stream (T , S , Stream , C ),
1011+ test_close (T , S , C ),
1012+ ok .
1013+
9481014consumer_offset_info (Config , ConnectionName ) ->
9491015 [[{offset , Offset },
9501016 {offset_lag , Lag }]] = rpc (Config , 0 , ? MODULE ,
0 commit comments