aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMagnus Henoch <[email protected]>2015-11-17 14:10:21 +0000
committerMagnus Henoch <[email protected]>2015-11-24 15:15:53 +0000
commitd00d68f96c51cc7f36d2030c7c7c6277adf998f0 (patch)
tree60cc555de5cbcfb1262d3c304a1f20d0b8dc7bc9 /lib
parent991d3fa399154b6166a4974406fc2bdda02a2668 (diff)
downloadotp-d00d68f96c51cc7f36d2030c7c7c6277adf998f0.tar.gz
otp-d00d68f96c51cc7f36d2030c7c7c6277adf998f0.tar.bz2
otp-d00d68f96c51cc7f36d2030c7c7c6277adf998f0.zip
Test interface listen option for TLS distribution
Add test that checks that the option inet_dist_use_interface is used when starting a node with TLS distribution.
Diffstat (limited to 'lib')
-rw-r--r--lib/ssl/test/ssl_dist_SUITE.erl30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/ssl/test/ssl_dist_SUITE.erl b/lib/ssl/test/ssl_dist_SUITE.erl
index cc644ce6da..508a968474 100644
--- a/lib/ssl/test/ssl_dist_SUITE.erl
+++ b/lib/ssl/test/ssl_dist_SUITE.erl
@@ -41,7 +41,7 @@
%%--------------------------------------------------------------------
all() ->
[basic, payload, plain_options, plain_verify_options, listen_port_options,
- listen_options].
+ listen_options, use_interface].
groups() ->
[].
@@ -352,6 +352,34 @@ do_listen_options(Prio, Config) ->
stop_ssl_node(NH1),
stop_ssl_node(NH2),
success(Config).
+%%--------------------------------------------------------------------
+use_interface() ->
+ [{doc, "Test inet_dist_use_interface"}].
+use_interface(Config) when is_list(Config) ->
+ %% Force the node to listen only on the loopback interface.
+ IpString = "'{127,0,0,1}'",
+ Options = "-kernel inet_dist_use_interface " ++ IpString,
+
+ %% Start a node, and get the port number it's listening on.
+ NH1 = start_ssl_node([{additional_dist_opts, Options} | Config]),
+ Node1 = NH1#node_handle.nodename,
+ Name = lists:takewhile(fun(C) -> C =/= $@ end, atom_to_list(Node1)),
+ {ok, NodesPorts} = apply_on_ssl_node(NH1, fun net_adm:names/0),
+ {Name, Port} = lists:keyfind(Name, 1, NodesPorts),
+
+ %% Now find the socket listening on that port, and check its sockname.
+ Sockets = apply_on_ssl_node(
+ NH1,
+ fun() ->
+ [inet:sockname(P) ||
+ P <- erlang:ports(),
+ {ok, Port} =:= (catch inet:port(P))]
+ end),
+ %% And check that it's actually listening on localhost.
+ [{ok,{{127,0,0,1},Port}}] = Sockets,
+
+ stop_ssl_node(NH1),
+ success(Config).
%%--------------------------------------------------------------------
%%% Internal functions -----------------------------------------------