diff --git a/deps/rabbitmq_web_stomp/Makefile b/deps/rabbitmq_web_stomp/Makefile index 131f9df3ce..c3c795850f 100644 --- a/deps/rabbitmq_web_stomp/Makefile +++ b/deps/rabbitmq_web_stomp/Makefile @@ -20,7 +20,7 @@ define PROJECT_APP_EXTRA_KEYS endef DEPS = cowboy rabbit_common rabbit rabbitmq_stomp -TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers +TEST_DEPS = gun rabbitmq_ct_helpers rabbitmq_ct_client_helpers PLT_APPS += cowlib @@ -28,10 +28,12 @@ PLT_APPS += cowlib # See rabbitmq-components.mk. BUILD_DEPS += ranch +dep_gun = hex 2.2.0 + DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk include ../../rabbitmq-components.mk include ../../erlang.mk -CT_HOOKS = rabbit_ct_hook \ No newline at end of file +CT_HOOKS = rabbit_ct_hook diff --git a/deps/rabbitmq_web_stomp/test/cowboy_websocket_SUITE.erl b/deps/rabbitmq_web_stomp/test/cowboy_websocket_SUITE.erl index 625c0b02a8..1dd08b38fe 100644 --- a/deps/rabbitmq_web_stomp/test/cowboy_websocket_SUITE.erl +++ b/deps/rabbitmq_web_stomp/test/cowboy_websocket_SUITE.erl @@ -27,7 +27,8 @@ groups() -> pubsub_binary, sub_non_existent, disconnect, - http_auth + http_auth, + wss_http2 ]}, %% rabbitmq/rabbitmq-web-stomp#110 {default_login_enabled, [], @@ -48,7 +49,25 @@ init_per_suite(Config) -> [{rmq_nodename_suffix, ?MODULE}, {protocol, "ws"}]), rabbit_ct_helpers:log_environment(), - rabbit_ct_helpers:run_setup_steps(Config1, + Config2 = rabbit_ct_helpers:run_setup_steps(Config1), + {rmq_certsdir, CertsDir} = proplists:lookup(rmq_certsdir, Config2), + Config3 = rabbit_ct_helpers:merge_app_env( + Config2, + {rabbitmq_web_stomp, + [{ssl_config, + [{cacertfile, filename:join([CertsDir, "testca", "cacert.pem"])}, + {certfile, filename:join([CertsDir, "server", "cert.pem"])}, + {keyfile, filename:join([CertsDir, "server", "key.pem"])}, + %% We only want to ensure HTTP/2 Websocket is working. + {fail_if_no_peer_cert, false}, + {versions, ['tlsv1.3']}, + %% We hard code this port number here because it will be computed later by + %% rabbit_ct_broker_helpers:init_tcp_port_numbers/3 when we start the broker. + %% (The alternative is to first start the broker, stop the rabbitmq_web_amqp app, + %% configure tls_config, and then start the app again.) + {port, 21014} + ]}]}), + rabbit_ct_helpers:run_setup_steps(Config3, rabbit_ct_broker_helpers:setup_steps()). end_per_suite(Config) -> @@ -286,3 +305,23 @@ Protocol = ?config(protocol, Config), {close, _} = rfc6455_client:close(WS3), ok. + +wss_http2(Config) -> + {ok, _} = application:ensure_all_started(gun), + Port = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_web_stomp_tls), + {ok, ConnPid} = gun:open("localhost", Port, #{ + transport => tls, + tls_opts => [{verify, verify_none}], + protocols => [http2], + http2_opts => #{notify_settings_changed => true}, + ws_opts => #{protocols => [{<<"v12.stomp">>, gun_ws_h}]} + }), + {ok, http2} = gun:await_up(ConnPid), + {notify, settings_changed, #{enable_connect_protocol := true}} + = gun:await(ConnPid, undefined), + StreamRef = gun:ws_upgrade(ConnPid, "/ws", []), + {upgrade, [<<"websocket">>], _} = gun:await(ConnPid, StreamRef), + gun:ws_send(ConnPid, StreamRef, {text, stomp:marshal("CONNECT", [{"login","guest"}, {"passcode", "guest"}])}), + {ws, {text, P}} = gun:await(ConnPid, StreamRef), + {<<"CONNECTED">>, _, <<>>} = stomp:unmarshal(P), + ok.