Browse Source

Format eacces errors in a more readable way

Amended with small whitespace changes and removing an unused clause.
Michael Klishin 8 years ago
parent
commit
066a714c69
2 changed files with 24 additions and 5 deletions
  1. 1 0
      src/ranch.erl
  2. 23 5
      test/acceptor_SUITE.erl

+ 1 - 0
src/ranch.erl

@@ -85,6 +85,7 @@ maybe_started(Res) ->
 	Res.
 	Res.
 
 
 start_error(E=eaddrinuse, _) -> {error, E};
 start_error(E=eaddrinuse, _) -> {error, E};
+start_error(E=eacces, _) -> {error, E};
 start_error(E=no_cert, _) -> {error, E};
 start_error(E=no_cert, _) -> {error, E};
 start_error(_, Error) -> Error.
 start_error(_, Error) -> Error.
 
 

+ 23 - 5
test/acceptor_SUITE.erl

@@ -36,7 +36,8 @@ groups() ->
 		tcp_set_max_connections,
 		tcp_set_max_connections,
 		tcp_set_max_connections_clean,
 		tcp_set_max_connections_clean,
 		tcp_upgrade,
 		tcp_upgrade,
-		tcp_error_eaddrinuse
+		tcp_error_eaddrinuse,
+		tcp_error_eacces
 	]}, {ssl, [
 	]}, {ssl, [
 		ssl_accept_error,
 		ssl_accept_error,
 		ssl_accept_socket,
 		ssl_accept_socket,
@@ -45,7 +46,8 @@ groups() ->
 		ssl_sni_echo,
 		ssl_sni_echo,
 		ssl_sni_fail,
 		ssl_sni_fail,
 		ssl_error_eaddrinuse,
 		ssl_error_eaddrinuse,
-		ssl_error_no_cert
+		ssl_error_no_cert,
+		ssl_error_eacces
 	]}, {misc, [
 	]}, {misc, [
 		misc_bad_transport,
 		misc_bad_transport,
 		misc_bad_transport_options,
 		misc_bad_transport_options,
@@ -258,7 +260,7 @@ do_ssl_sni_fail() ->
 	ok.
 	ok.
 
 
 ssl_error_eaddrinuse(_) ->
 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(),
 	Name = name(),
 	Opts = ct_helper:get_certs_from_ets(),
 	Opts = ct_helper:get_certs_from_ets(),
 	{ok, _} = ranch:start_listener(Name, 1, ranch_ssl, Opts, active_echo_protocol, []),
 	{ok, _} = ranch:start_listener(Name, 1, ranch_ssl, Opts, active_echo_protocol, []),
@@ -271,10 +273,18 @@ ssl_error_eaddrinuse(_) ->
 	ok.
 	ok.
 
 
 ssl_error_no_cert(_) ->
 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, []),
 	{error, no_cert} = ranch:start_listener(name(), 1, ranch_ssl, [], active_echo_protocol, []),
 	ok.
 	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.
 
 
 tcp_accept_socket(_) ->
 tcp_accept_socket(_) ->
@@ -461,7 +471,7 @@ tcp_upgrade(_) ->
 	ok = ranch:stop_listener(Name).
 	ok = ranch:stop_listener(Name).
 
 
 tcp_error_eaddrinuse(_) ->
 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(),
 	Name = name(),
 	{ok, _} = ranch:start_listener(Name, 1, ranch_tcp, [], active_echo_protocol, []),
 	{ok, _} = ranch:start_listener(Name, 1, ranch_tcp, [], active_echo_protocol, []),
 	Port = ranch:get_port(Name),
 	Port = ranch:get_port(Name),
@@ -472,6 +482,14 @@ tcp_error_eaddrinuse(_) ->
 	{'EXIT', _} = begin catch ranch:get_port(Name) end,
 	{'EXIT', _} = begin catch ranch:get_port(Name) end,
 	ok.
 	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
 %% Supervisor tests
 
 
 connection_type_supervisor(_) ->
 connection_type_supervisor(_) ->