@@ -27,7 +27,8 @@ groups() ->
2727 pubsub_binary ,
2828 sub_non_existent ,
2929 disconnect ,
30- http_auth
30+ http_auth ,
31+ wss_http2
3132 ]},
3233 % % rabbitmq/rabbitmq-web-stomp#110
3334 {default_login_enabled , [],
@@ -48,7 +49,25 @@ init_per_suite(Config) ->
4849 [{rmq_nodename_suffix , ? MODULE },
4950 {protocol , " ws" }]),
5051 rabbit_ct_helpers :log_environment (),
51- rabbit_ct_helpers :run_setup_steps (Config1 ,
52+ Config2 = rabbit_ct_helpers :run_setup_steps (Config1 ),
53+ {rmq_certsdir , CertsDir } = proplists :lookup (rmq_certsdir , Config2 ),
54+ Config3 = rabbit_ct_helpers :merge_app_env (
55+ Config2 ,
56+ {rabbitmq_web_stomp ,
57+ [{ssl_config ,
58+ [{cacertfile , filename :join ([CertsDir , " testca" , " cacert.pem" ])},
59+ {certfile , filename :join ([CertsDir , " server" , " cert.pem" ])},
60+ {keyfile , filename :join ([CertsDir , " server" , " key.pem" ])},
61+ % % We only want to ensure HTTP/2 Websocket is working.
62+ {fail_if_no_peer_cert , false },
63+ {versions , ['tlsv1.3' ]},
64+ % % We hard code this port number here because it will be computed later by
65+ % % rabbit_ct_broker_helpers:init_tcp_port_numbers/3 when we start the broker.
66+ % % (The alternative is to first start the broker, stop the rabbitmq_web_amqp app,
67+ % % configure tls_config, and then start the app again.)
68+ {port , 21014 }
69+ ]}]}),
70+ rabbit_ct_helpers :run_setup_steps (Config3 ,
5271 rabbit_ct_broker_helpers :setup_steps ()).
5372
5473end_per_suite (Config ) ->
@@ -286,3 +305,23 @@ Protocol = ?config(protocol, Config),
286305 {close , _ } = rfc6455_client :close (WS3 ),
287306
288307 ok .
308+
309+ wss_http2 (Config ) ->
310+ {ok , _ } = application :ensure_all_started (gun ),
311+ Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_web_stomp_tls ),
312+ {ok , ConnPid } = gun :open (" localhost" , Port , #{
313+ transport => tls ,
314+ tls_opts => [{verify , verify_none }],
315+ protocols => [http2 ],
316+ http2_opts => #{notify_settings_changed => true },
317+ ws_opts => #{protocols => [{<<" v12.stomp" >>, gun_ws_h }]}
318+ }),
319+ {ok , http2 } = gun :await_up (ConnPid ),
320+ {notify , settings_changed , #{enable_connect_protocol := true }}
321+ = gun :await (ConnPid , undefined ),
322+ StreamRef = gun :ws_upgrade (ConnPid , " /ws" , []),
323+ {upgrade , [<<" websocket" >>], _ } = gun :await (ConnPid , StreamRef ),
324+ gun :ws_send (ConnPid , StreamRef , {text , stomp :marshal (" CONNECT" , [{" login" ," guest" }, {" passcode" , " guest" }])}),
325+ {ws , {text , P }} = gun :await (ConnPid , StreamRef ),
326+ {<<" CONNECTED" >>, _ , <<>>} = stomp :unmarshal (P ),
327+ ok .
0 commit comments