Refuse to publish things that aren't strings, things will blow up when anyone tries to retrieve them!
This commit is contained in:
parent
87eafbb001
commit
2c9acd03b7
|
|
@ -47,6 +47,10 @@ do_it(ReqData, Context) ->
|
|||
rabbit_mgmt_util:with_decode(
|
||||
[routing_key, properties, payload, payload_encoding], ReqData, Context,
|
||||
fun([RoutingKey, Props0, Payload0, Enc], _) ->
|
||||
case Payload0 of
|
||||
P when is_binary(P) -> ok;
|
||||
_ -> throw({error, payload_not_string})
|
||||
end,
|
||||
rabbit_mgmt_util:with_channel(
|
||||
VHost, ReqData, Context,
|
||||
fun (Ch) ->
|
||||
|
|
|
|||
|
|
@ -860,6 +860,12 @@ publish_fail_test() ->
|
|||
{payload, <<"Hello world">>},
|
||||
{payload_encoding, <<"string">>}],
|
||||
http_post("/exchanges/%2f/amq.default/publish", Msg2, ?BAD_REQUEST),
|
||||
Msg3 = [{exchange, <<"">>},
|
||||
{routing_key, <<"myqueue">>},
|
||||
{properties, []},
|
||||
{payload, [<<"not a string">>]},
|
||||
{payload_encoding, <<"string">>}],
|
||||
http_post("/exchanges/%2f/amq.default/publish", Msg3, ?BAD_REQUEST),
|
||||
http_delete("/users/myuser", ?NO_CONTENT),
|
||||
ok.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue