aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-11-06 10:54:02 +0100
committerIngela Anderton Andin <[email protected]>2013-11-13 10:58:20 +0100
commit422ed9ecd9c95c25964381b7ca2888a0320a8ee4 (patch)
treeb501003998429de1850d0b067f285dcfbd8dcf18 /lib/ssh/test
parent24f37acef3e7e33576bcd071569a94de980b6544 (diff)
downloadotp-422ed9ecd9c95c25964381b7ca2888a0320a8ee4.tar.gz
otp-422ed9ecd9c95c25964381b7ca2888a0320a8ee4.tar.bz2
otp-422ed9ecd9c95c25964381b7ca2888a0320a8ee4.zip
ssh: Simplify handling of connection attributes (e.i. user and sockname)
OTP-11296
Diffstat (limited to 'lib/ssh/test')
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl14
-rw-r--r--lib/ssh/test/ssh_peername_sockname_server.erl8
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index 813031eab2..b9745dda9c 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -478,7 +478,7 @@ send(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
peername_sockname() ->
- [{doc, "Test ssh:peername/1 and ssh:sockname/1"}].
+ [{doc, "Test ssh:connection_info([peername, sockname])"}].
peername_sockname(Config) when is_list(Config) ->
process_flag(trap_exit, true),
SystemDir = filename:join(?config(priv_dir, Config), system),
@@ -496,13 +496,17 @@ peername_sockname(Config) when is_list(Config) ->
{user_interaction, false}]),
{ok, ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
success = ssh_connection:subsystem(ConnectionRef, ChannelId, "peername_sockname", infinity),
- {ok,{HostPeerClient,PortPeerClient}} = ssh:peername(ConnectionRef),
- {ok,{HostSockClient,PortSockClient}} = ssh:sockname(ConnectionRef),
+ [{peer, {_Name, {HostPeerClient,PortPeerClient} = ClientPeer}}] =
+ ssh:connection_info(ConnectionRef, [peer]),
+ [{sockname, {HostSockClient,PortSockClient} = ClientSock}] =
+ ssh:connection_info(ConnectionRef, [sockname]),
+ ct:pal("Client: ~p ~p", [ClientPeer, ClientSock]),
receive
{ssh_cm, ConnectionRef, {data, ChannelId, _, Response}} ->
{PeerNameSrv,SockNameSrv} = binary_to_term(Response),
- {ok,{HostPeerSrv,PortPeerSrv}} = PeerNameSrv,
- {ok,{HostSockSrv,PortSockSrv}} = SockNameSrv,
+ {HostPeerSrv,PortPeerSrv} = PeerNameSrv,
+ {HostSockSrv,PortSockSrv} = SockNameSrv,
+ ct:pal("Server: ~p ~p", [PeerNameSrv, SockNameSrv]),
host_equal(HostPeerSrv, HostSockClient),
PortPeerSrv = PortSockClient,
host_equal(HostSockSrv, HostPeerClient),
diff --git a/lib/ssh/test/ssh_peername_sockname_server.erl b/lib/ssh/test/ssh_peername_sockname_server.erl
index 7664f3ee25..bc505695d3 100644
--- a/lib/ssh/test/ssh_peername_sockname_server.erl
+++ b/lib/ssh/test/ssh_peername_sockname_server.erl
@@ -34,12 +34,10 @@ init([]) ->
{ok, #state{}}.
handle_msg({ssh_channel_up, ChannelId, ConnectionManager}, State) ->
+ [{peer, {_Name, Peer}}] = ssh:connection_info(ConnectionManager, [peer]),
+ [{sockname, Sock}] = ssh:connection_info(ConnectionManager, [sockname]),
ssh_connection:send(ConnectionManager, ChannelId,
- term_to_binary(
- {catch ssh:peername(ConnectionManager),
- catch ssh:sockname(ConnectionManager)
- })
- ),
+ term_to_binary({Peer, Sock})),
{ok, State}.
handle_ssh_msg({ssh_cm, _, {exit_signal, ChannelId, _, _Error, _}},