@@ -34,7 +34,8 @@ groups() ->
3434 parse_amqp10 ,
3535 parse_amqp10_minimal ,
3636 validate_amqp10 ,
37- validate_amqp10_with_a_map
37+ validate_amqp10_with_a_map ,
38+ validate_amqp10_with_wrong_capabilities_type
3839 ]}
3940 ].
4041
@@ -230,6 +231,7 @@ parse_amqp10(_Config) ->
230231 {<<" src-address" >>, <<" a-src-queue" >>},
231232 {<<" src-delete-after" >>, <<" never" >>},
232233 {<<" src-prefetch-count" >>, 30 },
234+ {<<" src-capabilities" >>, []},
233235
234236 {<<" dest-protocol" >>, <<" amqp10" >>},
235237 {<<" dest-uri" >>, <<" amqp://remotehost:5672" >>},
@@ -240,7 +242,8 @@ parse_amqp10(_Config) ->
240242 <<" app-prop-value" >>}]},
241243 {<<" dest-message-annotations" >>, [{<<" some-message-ann" >>,
242244 <<" message-ann-value" >>}]},
243- {<<" dest-properties" >>, [{<<" user_id" >>, <<" some-user" >>}]}
245+ {<<" dest-properties" >>, [{<<" user_id" >>, <<" some-user" >>}]},
246+ {<<" dest-capabilities" >>, [<<" one" >>, <<" two" >>]}
244247 ],
245248 ObfuscatedParams = rabbit_shovel_parameters :obfuscate_uris_in_definition (Params ),
246249 ? assertMatch (
@@ -250,7 +253,8 @@ parse_amqp10(_Config) ->
250253 uris := [" amqp://localhost:5672" ],
251254 delete_after := never ,
252255 prefetch_count := 30 ,
253- source_address := <<" a-src-queue" >>
256+ source_address := <<" a-src-queue" >>,
257+ receiver_capabilities := []
254258 },
255259 dest := #{module := rabbit_amqp10_shovel ,
256260 uris := [" amqp://remotehost:5672" ],
@@ -261,7 +265,8 @@ parse_amqp10(_Config) ->
261265 <<" app-prop-value" >>},
262266 properties := #{user_id := <<" some-user" >>},
263267 add_timestamp_header := true ,
264- add_forward_headers := true
268+ add_forward_headers := true ,
269+ sender_capabilities := [<<" one" >>, <<" two" >>]
265270 }
266271 }},
267272 rabbit_shovel_parameters :parse ({" vhost" , " my_shovel" }, " my-cluster" ,
@@ -327,6 +332,34 @@ validate_amqp10(_Config) ->
327332 [] = validate_ok (Res ),
328333 ok .
329334
335+ validate_amqp10_with_wrong_capabilities_type (_Config ) ->
336+ Params =
337+ #{
338+ <<" ack-mode" >> => <<" on-publish" >>,
339+ <<" reconnect-delay" >> => 1001 ,
340+
341+ <<" src-protocol" >> => <<" amqp10" >>,
342+ <<" src-uri" >> => <<" amqp://localhost:5672" >>,
343+ <<" src-address" >> => <<" a-src-queue" >>,
344+ <<" src-delete-after" >> => <<" never" >>,
345+ <<" src-prefetch-count" >> => 30 ,
346+ <<" src-capabilities" >> => <<" one" >>,
347+
348+ <<" dest-protocol" >> => <<" amqp10" >>,
349+ <<" dest-uri" >> => <<" amqp://remotehost:5672" >>,
350+ <<" dest-address" >> => <<" a-dest-queue" >>,
351+ <<" dest-add-forward-headers" >> => true ,
352+ <<" dest-add-timestamp-header" >> => true ,
353+ <<" dest-application-properties" >> => [{<<" some-app-prop" >>,
354+ <<" app-prop-value" >>}],
355+ <<" dest-message-annotations" >> => [{<<" some-message-ann" >>, <<" message-ann-value" >>}],
356+ <<" dest-properties" >> => #{<<" user_id" >> => <<" some-user" >>}
357+ },
358+ Res = rabbit_shovel_parameters :validate (" my-vhost" , <<" shovel" >>,
359+ " my-shovel" , Params , none ),
360+ {error , _ , [<<" src-capabilities" >>, <<" one" >>]} = find_first_error (Res ).
361+
362+
330363validate_amqp10_with_a_map (_Config ) ->
331364 Params =
332365 #{
@@ -352,8 +385,7 @@ validate_amqp10_with_a_map(_Config) ->
352385
353386 Res = rabbit_shovel_parameters :validate (" my-vhost" , <<" shovel" >>,
354387 " my-shovel" , Params , none ),
355- [] = validate_ok (Res ),
356- ok .
388+ validate_ok (Res ).
357389
358390validate_ok ([ok | T ]) ->
359391 validate_ok (T );
@@ -362,3 +394,10 @@ validate_ok([[_|_] = L | T]) ->
362394validate_ok ([]) -> [];
363395validate_ok (X ) ->
364396 exit ({not_ok , X }).
397+ find_first_error ([]) ->
398+ undefined ;
399+ find_first_error ([V | T ]) ->
400+ case V of
401+ {error , _ , _ } = E -> E ;
402+ _ -> find_first_error (T )
403+ end .
0 commit comments