From 066a714c6923aa5497f9536ffe7f1d681dc32c96 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 25 Jan 2017 17:41:08 +0300 Subject: Format eacces errors in a more readable way Amended with small whitespace changes and removing an unused clause. --- src/ranch.erl | 1 + test/acceptor_SUITE.erl | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ranch.erl b/src/ranch.erl index 9d2509a..2ef6222 100644 --- a/src/ranch.erl +++ b/src/ranch.erl @@ -85,6 +85,7 @@ maybe_started(Res) -> Res. start_error(E=eaddrinuse, _) -> {error, E}; +start_error(E=eacces, _) -> {error, E}; start_error(E=no_cert, _) -> {error, E}; start_error(_, Error) -> Error. diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index 112e073..878caee 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -36,7 +36,8 @@ groups() -> tcp_set_max_connections, tcp_set_max_connections_clean, tcp_upgrade, - tcp_error_eaddrinuse + tcp_error_eaddrinuse, + tcp_error_eacces ]}, {ssl, [ ssl_accept_error, ssl_accept_socket, @@ -45,7 +46,8 @@ groups() -> ssl_sni_echo, ssl_sni_fail, ssl_error_eaddrinuse, - ssl_error_no_cert + ssl_error_no_cert, + ssl_error_eacces ]}, {misc, [ misc_bad_transport, misc_bad_transport_options, @@ -258,7 +260,7 @@ do_ssl_sni_fail() -> ok. ssl_error_eaddrinuse(_) -> - doc("Check that eaddrinuse returns a simplified error."), + doc("Ensure that failure due to an eaddrinuse returns a compact readable error."), Name = name(), Opts = ct_helper:get_certs_from_ets(), {ok, _} = ranch:start_listener(Name, 1, ranch_ssl, Opts, active_echo_protocol, []), @@ -271,10 +273,18 @@ ssl_error_eaddrinuse(_) -> ok. ssl_error_no_cert(_) -> - doc("Check that missing certificate returns a simplified error."), + doc("Ensure that failure due to missing certificate returns a compact readable error."), {error, no_cert} = ranch:start_listener(name(), 1, ranch_ssl, [], active_echo_protocol, []), ok. +ssl_error_eacces(_) -> + doc("Ensure that failure due to an eacces returns a compact readable error."), + Name = name(), + Opts = ct_helper:get_certs_from_ets(), + {error, eacces} = ranch:start_listener(Name, 1, + ranch_ssl, [{port, 283}|Opts], active_echo_protocol, []), + ok. + %% tcp. tcp_accept_socket(_) -> @@ -461,7 +471,7 @@ tcp_upgrade(_) -> ok = ranch:stop_listener(Name). tcp_error_eaddrinuse(_) -> - doc("Check that eaddrinuse returns a simplified error."), + doc("Ensure that failure due to an eaddrinuse returns a compact readable error."), Name = name(), {ok, _} = ranch:start_listener(Name, 1, ranch_tcp, [], active_echo_protocol, []), Port = ranch:get_port(Name), @@ -472,6 +482,14 @@ tcp_error_eaddrinuse(_) -> {'EXIT', _} = begin catch ranch:get_port(Name) end, ok. +tcp_error_eacces(_) -> + doc("Ensure that failure due to an eacces returns a compact readable error."), + Name = name(), + {error, eacces} = ranch:start_listener(Name, 1, + ranch_tcp, [{port, 283}], active_echo_protocol, []), + ok. + + %% Supervisor tests connection_type_supervisor(_) -> -- cgit v1.2.3