@@ -46,13 +46,15 @@ all_tests() ->
4646 unbind_from_volatile_queue ,
4747 binding_args_direct_exchange ,
4848 binding_args_fanout_exchange ,
49+ empty_binding_key_queue_to_topic_exchange ,
4950
5051 % % Exchange bindings
5152 bind_and_unbind_direct_exchange ,
5253 bind_and_unbind_fanout_exchange ,
5354 bind_and_delete_exchange_source ,
5455 bind_and_delete_exchange_destination ,
55- bind_to_unknown_exchange
56+ bind_to_unknown_exchange ,
57+ empty_binding_key_exchange_to_topic_exchange
5658 ].
5759
5860% % -------------------------------------------------------------------
@@ -842,6 +844,38 @@ bind_and_delete_exchange_source(Config) ->
842844 rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_binding , list , [<<" /" >>])),
843845 ok .
844846
847+ empty_binding_key_queue_to_topic_exchange (Config ) ->
848+ Server = rabbit_ct_broker_helpers :get_node_config (Config , 0 , nodename ),
849+ Ch = rabbit_ct_client_helpers :open_channel (Config , Server ),
850+ Q = ? config (queue_name , Config ),
851+
852+ # 'queue.declare_ok' {} = declare (Ch , Q , []),
853+ ? assertExit (
854+ {{shutdown ,
855+ {server_initiated_close , 406 ,
856+ <<" PRECONDITION_FAILED - topic exchange binding key cannot be empty" >>}},
857+ _ },
858+ amqp_channel :call (Ch , # 'queue.bind' {exchange = <<" amq.topic" >>,
859+ queue = Q ,
860+ routing_key = <<" " >>})),
861+ ? assertEqual ([], rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_binding , list_explicit , [])).
862+
863+ empty_binding_key_exchange_to_topic_exchange (Config ) ->
864+ Server = rabbit_ct_broker_helpers :get_node_config (Config , 0 , nodename ),
865+ Ch = rabbit_ct_client_helpers :open_channel (Config , Server ),
866+ X = ? config (exchange_name , Config ),
867+
868+ # 'exchange.declare_ok' {} = amqp_channel :call (Ch , # 'exchange.declare' {exchange = X }),
869+ ? assertExit (
870+ {{shutdown ,
871+ {server_initiated_close , 406 ,
872+ <<" PRECONDITION_FAILED - topic exchange binding key cannot be empty" >>}},
873+ _ },
874+ amqp_channel :call (Ch , # 'exchange.bind' {source = <<" amq.topic" >>,
875+ destination = X ,
876+ routing_key = <<" " >>})),
877+ ? assertEqual ([], rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_binding , list_explicit , [])).
878+
845879% % Internal
846880
847881delete_queues () ->
0 commit comments