aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_basic_SUITE.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2015-06-09 18:19:12 +0200
committerHans Nilsson <[email protected]>2015-06-15 12:03:58 +0200
commit9ba9728528f309933fd95aa92f748682dd5204f2 (patch)
tree15f517f11a9b089b5b1cb26275cf4e3c0f369407 /lib/ssh/test/ssh_basic_SUITE.erl
parent455ae616947dce6bd6b514226e98b50ef176fd83 (diff)
downloadotp-9ba9728528f309933fd95aa92f748682dd5204f2.tar.gz
otp-9ba9728528f309933fd95aa92f748682dd5204f2.tar.bz2
otp-9ba9728528f309933fd95aa92f748682dd5204f2.zip
ssh: add test case + corr for ssh_info:print/1
Conflicts: lib/ssh/test/ssh_basic_SUITE.erl
Diffstat (limited to 'lib/ssh/test/ssh_basic_SUITE.erl')
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl76
1 files changed, 73 insertions, 3 deletions
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index 873e9a42b1..2ff6aac3b6 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -71,7 +71,8 @@ all() ->
id_string_no_opt_server,
id_string_own_string_server,
id_string_random_server,
- {group, hardening_tests}
+ {group, hardening_tests},
+ ssh_info_print
].
groups() ->
@@ -157,7 +158,8 @@ init_per_group(dir_options, Config) ->
case {file:read_file_info(Dir_unreadable),
file:read_file_info(File_readable)} of
{{ok, #file_info{type=directory, access=Md}},
- {ok, #file_info{type=regular, access=Mf}}} when Md=/=read, Md=/=read_write ->
+ {ok, #file_info{type=regular, access=Mf}}} when Md=/=read, Md=/=read_write,
+ Mf=/=read, Mf=/=read_write ->
%% Save:
[{unreadable_dir, Dir_unreadable},
{readable_file, File_readable}
@@ -820,7 +822,7 @@ connectfun_disconnectfun_client(Config) ->
{user_dir, UserDir},
{password, "morot"},
{failfun, fun ssh_test_lib:failfun/2}]),
- ConnectionRef =
+ _ConnectionRef =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
{user, "foo"},
{password, "morot"},
@@ -1695,6 +1697,74 @@ max_sessions(Config, ParallelLogin, Connect0) when is_function(Connect0,2) ->
end.
%%--------------------------------------------------------------------
+ssh_info_print(Config) ->
+ %% Just check that ssh_print:info() crashes
+ PrivDir = ?config(priv_dir, Config),
+ PrintFile = filename:join(PrivDir,info),
+ UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
+ file:make_dir(UserDir),
+ SysDir = ?config(data_dir, Config),
+
+ Parent = self(),
+ UnexpFun = fun(Msg,_Peer) ->
+ Parent ! {unexpected,Msg,self()},
+ skip
+ end,
+ ConnFun = fun(_,_,_) -> Parent ! {connect,self()} end,
+
+ {DaemonRef, Host, Port} =
+ ssh_test_lib:daemon([{system_dir, SysDir},
+ {user_dir, UserDir},
+ {password, "morot"},
+ {unexpectedfun, UnexpFun},
+ {connectfun, ConnFun},
+ {failfun, fun ssh_test_lib:failfun/2}]),
+ ClientConnRef1 =
+ ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
+ {user, "foo"},
+ {password, "morot"},
+ {user_dir, UserDir},
+ {unexpectedfun, UnexpFun},
+ {user_interaction, false}]),
+ ClientConnRef2 =
+ ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
+ {user, "foo"},
+ {password, "morot"},
+ {user_dir, UserDir},
+ {unexpectedfun, UnexpFun},
+ {user_interaction, false}]),
+ receive
+ {connect,DaemonConnRef} ->
+ ct:log("DaemonRef=~p, DaemonConnRef=~p, ClientConnRefs=~p",[DaemonRef, DaemonConnRef,
+ [ClientConnRef1,ClientConnRef2]
+ ])
+ after 2000 ->
+ ok
+ end,
+
+ {ok,D} = file:open(PrintFile, write),
+ ssh_info:print(D),
+ ok = file:close(D),
+
+ {ok,Bin} = file:read_file(PrintFile),
+ ct:log("~s",[Bin]),
+
+ receive
+ {unexpected, Msg, Pid} ->
+ ct:log("~p got unexpected msg ~p",[Pid,Msg]),
+ ct:log("process_info(~p) = ~n~p",[Pid,process_info(Pid)]),
+ ok = ssh:close(ClientConnRef1),
+ ok = ssh:close(ClientConnRef2),
+ ok = ssh:stop_daemon(DaemonRef),
+ {fail,"unexpected msg"}
+ after 1000 ->
+ ok = ssh:close(ClientConnRef1),
+ ok = ssh:close(ClientConnRef2),
+ ok = ssh:stop_daemon(DaemonRef)
+ end.
+
+
+%%--------------------------------------------------------------------
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------