aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_basic_SUITE.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2012-01-16 11:43:15 +0100
committerIngela Anderton Andin <[email protected]>2012-01-16 11:43:15 +0100
commitf8815dc88bd86d6508d2a3dad031ea939fb2b443 (patch)
tree6db7476dddc9a21566d144ee722b676d938646ff /lib/ssh/test/ssh_basic_SUITE.erl
parent27d478f37930d147aaac62a1353e071ca17fbbcc (diff)
parentb89c0042c4839ae8ebb231640f3e66ee52de3aa7 (diff)
downloadotp-f8815dc88bd86d6508d2a3dad031ea939fb2b443.tar.gz
otp-f8815dc88bd86d6508d2a3dad031ea939fb2b443.tar.bz2
otp-f8815dc88bd86d6508d2a3dad031ea939fb2b443.zip
Merge branch 'ia/ssh/test-maint' into maint
* ia/ssh/test-maint: Remove generation of new test keys, use checked in test keys Improve test case structure so that test should pass on all platforms Exec test case should ignore stderr messages Do not run ssh_to_openssh_SUITE if there is no oppenssh server running
Diffstat (limited to 'lib/ssh/test/ssh_basic_SUITE.erl')
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl69
1 files changed, 47 insertions, 22 deletions
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index 5ea0d98980..73b60057cc 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -41,9 +41,20 @@
init_per_suite(Config) ->
case catch crypto:start() of
ok ->
- Dir = ?config(priv_dir, Config),
- {ok, _} = ssh_test_lib:get_id_keys(Dir),
- ssh_test_lib:make_dsa_files(Config),
+ DataDir = ?config(data_dir, Config),
+ UserDir = ?config(priv_dir, Config),
+ ssh_test_lib:copyfile(DataDir, UserDir, "id_rsa"),
+ ssh_test_lib:copyfile(DataDir, UserDir, "id_dsa"),
+ RSAFile = filename:join(DataDir, "id_rsa.pub"),
+ DSAFile = filename:join(DataDir, "id_dsa.pub"),
+ {ok, Ssh1} = file:read_file(RSAFile),
+ {ok, Ssh2} = file:read_file(DSAFile),
+ [{RSA, _}] = public_key:ssh_decode(Ssh1,public_key),
+ [{DSA, _}] = public_key:ssh_decode(Ssh2,public_key),
+ AuthKeys = public_key:ssh_encode([{RSA, [{comment, "Test"}]},
+ {DSA,[{comment, "Test"}]}], auth_keys),
+ AuthKeysFile = filename:join(UserDir, "authorized_keys"),
+ file:write_file(AuthKeysFile, AuthKeys),
Config;
_Else ->
{skip, "Crypto could not be started!"}
@@ -56,9 +67,7 @@ init_per_suite(Config) ->
%% Description: Cleanup after the whole suite
%%--------------------------------------------------------------------
end_per_suite(Config) ->
- Dir = ?config(priv_dir, Config),
crypto:stop(),
- ssh_test_lib:remove_id_keys(Dir),
ok.
%%--------------------------------------------------------------------
@@ -75,7 +84,6 @@ end_per_suite(Config) ->
%% Description: Initialization before each test case
%%--------------------------------------------------------------------
init_per_testcase(_TestCase, Config) ->
- ssh_test_lib:known_hosts(backup),
ssh:start(),
Config.
@@ -87,9 +95,16 @@ init_per_testcase(_TestCase, Config) ->
%% A list of key/value pairs, holding the test case configuration.
%% Description: Cleanup after each test case
%%--------------------------------------------------------------------
-end_per_testcase(_TestCase, _Config) ->
+
+end_per_testcase(TestCase, Config) when TestCase == server_password_option;
+ TestCase == server_userpassword_option ->
+ UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ file:del_dir(UserDir),
+ end_per_testcase(Config);
+end_per_testcase(_TestCase, Config) ->
+ end_per_testcase(Config).
+end_per_testcase(Config) ->
ssh:stop(),
- ssh_test_lib:known_hosts(restore),
ok.
%%--------------------------------------------------------------------
@@ -101,9 +116,8 @@ end_per_testcase(_TestCase, _Config) ->
%% Description: Returns a list of all test cases in this test suite
%%--------------------------------------------------------------------
all() ->
- [exec, exec_compressed, shell, daemon_already_started,
- server_password_option, server_userpassword_option,
- known_hosts].
+ [exec, exec_compressed, shell, daemon_already_started,
+ server_password_option, server_userpassword_option, known_hosts].
groups() ->
[].
@@ -136,10 +150,14 @@ exec(suite) ->
exec(Config) when is_list(Config) ->
process_flag(trap_exit, true),
SystemDir = ?config(data_dir, Config),
+ UserDir = ?config(priv_dir, Config),
+
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
+ {user_dir, UserDir},
{failfun, fun ssh_test_lib:failfun/2}]),
ConnectionRef =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
+ {user_dir, UserDir},
{user_interaction, false}]),
{ok, ChannelId0} = ssh_connection:session_channel(ConnectionRef, infinity),
success = ssh_connection:exec(ConnectionRef, ChannelId0,
@@ -178,12 +196,15 @@ exec_compressed(suite) ->
exec_compressed(Config) when is_list(Config) ->
process_flag(trap_exit, true),
SystemDir = ?config(data_dir, Config),
- {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
+ UserDir = ?config(priv_dir, Config),
+
+ {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},{user_dir, UserDir},
{compression, zlib},
{failfun, fun ssh_test_lib:failfun/2}]),
ConnectionRef =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
+ {user_dir, UserDir},
{user_interaction, false}]),
{ok, ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
success = ssh_connection:exec(ConnectionRef, ChannelId,
@@ -209,12 +230,14 @@ shell(suite) ->
shell(Config) when is_list(Config) ->
process_flag(trap_exit, true),
SystemDir = ?config(data_dir, Config),
- {_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
+ UserDir = ?config(priv_dir, Config),
+
+ {_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},{user_dir, UserDir},
{failfun, fun ssh_test_lib:failfun/2}]),
test_server:sleep(500),
IO = ssh_test_lib:start_io_server(),
- Shell = ssh_test_lib:start_shell(Port, IO),
+ Shell = ssh_test_lib:start_shell(Port, IO, UserDir),
receive
ErlShellStart ->
test_server:format("Erlang shell start: ~p~n", [ErlShellStart])
@@ -291,8 +314,9 @@ server_password_option(doc) ->
server_password_option(suite) ->
[];
server_password_option(Config) when is_list(Config) ->
- UserDir = ?config(data_dir, Config), % to make sure we don't use
- SysDir = ?config(data_dir, Config), % public-key-auth
+ UserDir = filename:join(?config(priv_dir, Config), nopubkey), % to make sure we don't use public-key-auth
+ file:make_dir(UserDir),
+ SysDir = ?config(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{password, "morot"}]),
@@ -321,8 +345,9 @@ server_userpassword_option(doc) ->
server_userpassword_option(suite) ->
[];
server_userpassword_option(Config) when is_list(Config) ->
- UserDir = ?config(data_dir, Config), % to make sure we don't use
- SysDir = ?config(data_dir, Config), % public-key-auth
+ UserDir = filename:join(?config(priv_dir, Config), nopubkey), % to make sure we don't use public-key-auth
+ file:make_dir(UserDir),
+ SysDir = ?config(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_passwords, [{"vego", "morot"}]}]),
@@ -361,10 +386,10 @@ known_hosts(doc) ->
known_hosts(suite) ->
[];
known_hosts(Config) when is_list(Config) ->
- SystemDir = ?config(data_dir, Config),
+ DataDir = ?config(data_dir, Config),
UserDir = ?config(priv_dir, Config),
-
- {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
+
+ {Pid, Host, Port} = ssh_test_lib:daemon([{user_dir, UserDir},{system_dir, DataDir},
{failfun, fun ssh_test_lib:failfun/2}]),
KnownHosts = filename:join(UserDir, "known_hosts"),