@@ -24,6 +24,7 @@ groups() ->
2424 ,unacceptable_data_type
2525 ,handle_invalid_packets
2626 ,duplicate_connect
27+ ,wss_http2
2728 ]}
2829 ].
2930
@@ -36,7 +37,25 @@ init_per_suite(Config) ->
3637 {rmq_nodename_suffix , ? MODULE },
3738 {protocol , " ws" }
3839 ]),
39- rabbit_ct_helpers :run_setup_steps (Config1 ,
40+ Config2 = rabbit_ct_helpers :run_setup_steps (Config1 ),
41+ {rmq_certsdir , CertsDir } = proplists :lookup (rmq_certsdir , Config2 ),
42+ Config3 = rabbit_ct_helpers :merge_app_env (
43+ Config2 ,
44+ {rabbitmq_web_mqtt ,
45+ [{ssl_config ,
46+ [{cacertfile , filename :join ([CertsDir , " testca" , " cacert.pem" ])},
47+ {certfile , filename :join ([CertsDir , " server" , " cert.pem" ])},
48+ {keyfile , filename :join ([CertsDir , " server" , " key.pem" ])},
49+ % % We only want to ensure HTTP/2 Websocket is working.
50+ {fail_if_no_peer_cert , false },
51+ {versions , ['tlsv1.3' ]},
52+ % % We hard code this port number here because it will be computed later by
53+ % % rabbit_ct_broker_helpers:init_tcp_port_numbers/3 when we start the broker.
54+ % % (The alternative is to first start the broker, stop the rabbitmq_web_amqp app,
55+ % % configure tls_config, and then start the app again.)
56+ {port , 21010 }
57+ ]}]}),
58+ rabbit_ct_helpers :run_setup_steps (Config3 ,
4059 rabbit_ct_broker_helpers :setup_steps () ++
4160 rabbit_ct_client_helpers :setup_steps ()).
4261
@@ -114,6 +133,26 @@ duplicate_connect(Config) ->
114133 after 500 -> ct :fail (" expected web socket to exit" )
115134 end .
116135
136+ wss_http2 (Config ) ->
137+ {ok , _ } = application :ensure_all_started (gun ),
138+ Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_web_mqtt_tls ),
139+ {ok , ConnPid } = gun :open (" localhost" , Port , #{
140+ transport => tls ,
141+ tls_opts => [{verify , verify_none }],
142+ protocols => [http2 ],
143+ http2_opts => #{notify_settings_changed => true },
144+ ws_opts => #{protocols => [{<<" mqtt" >>, gun_ws_h }]}
145+ }),
146+ {ok , http2 } = gun :await_up (ConnPid ),
147+ {notify , settings_changed , #{enable_connect_protocol := true }}
148+ = gun :await (ConnPid , undefined ),
149+ StreamRef = gun :ws_upgrade (ConnPid , " /ws" , []),
150+ {upgrade , [<<" websocket" >>], _ } = gun :await (ConnPid , StreamRef ),
151+ gun :ws_send (ConnPid , StreamRef , {binary , rabbit_ws_test_util :mqtt_3_1_1_connect_packet ()}),
152+ {ws , {binary , _P }} = gun :await (ConnPid , StreamRef ),
153+ eventually (? _assertEqual (1 , num_mqtt_connections (Config , 0 ))),
154+ ok .
155+
117156% % -------------------------------------------------------------------
118157% % Internal helpers
119158% % -------------------------------------------------------------------
0 commit comments