aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2015-12-08 11:52:09 +0100
committerHans Nilsson <[email protected]>2015-12-08 11:52:09 +0100
commit5fe8d649b1431d84d559e6c3730de25b54dbde31 (patch)
tree04b30751d0d847378b6cebfdbe84034edf613ff2
parentdbe8fe945aaf26809b288d33dd100ed83f6984e4 (diff)
parent7061105f5a8458486d43183a8b925c203b7a21fe (diff)
downloadotp-5fe8d649b1431d84d559e6c3730de25b54dbde31.tar.gz
otp-5fe8d649b1431d84d559e6c3730de25b54dbde31.tar.bz2
otp-5fe8d649b1431d84d559e6c3730de25b54dbde31.zip
Merge branch 'hans/ssh/cuddle_tests' into maint
* hans/ssh/cuddle_tests: ssh: add econnaborted as correct tcp disconnect reason in testcase ssh: add check for available ipv6 addr in test case ssh: Add testcase precondition
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl8
-rw-r--r--lib/ssh/test/ssh_protocol_SUITE.erl10
-rw-r--r--lib/ssh/test/ssh_test_lib.erl12
-rw-r--r--lib/ssh/test/ssh_to_openssh_SUITE.erl80
4 files changed, 67 insertions, 43 deletions
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index 85a6bac972..6c4c215b3d 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -311,6 +311,14 @@ init_per_testcase(TC, Config) when TC==shell_no_unicode ;
ct:log("file:native_name_encoding() = ~p,~nio:getopts() = ~p",
[file:native_name_encoding(),io:getopts()]),
wait_for_erlang_first_line([{io,IO}, {shell,Shell}, {sftpd, Sftpd} | Config]);
+
+init_per_testcase(inet6_option, Config) ->
+ case ssh_test_lib:has_inet6_address() of
+ true ->
+ init_per_testcase('__default__', Config);
+ false ->
+ {skip,"No ipv6 interface address"}
+ end;
init_per_testcase(_TestCase, Config) ->
ssh:start(),
Config.
diff --git a/lib/ssh/test/ssh_protocol_SUITE.erl b/lib/ssh/test/ssh_protocol_SUITE.erl
index 4639904061..5af60adfae 100644
--- a/lib/ssh/test/ssh_protocol_SUITE.erl
+++ b/lib/ssh/test/ssh_protocol_SUITE.erl
@@ -279,7 +279,9 @@ no_common_alg_server_disconnects(Config) ->
{send, ssh_msg_kexinit}, % with server unsupported 'ssh-dss' !
{match,
{'or',[#ssh_msg_disconnect{code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, _='_'},
- tcp_closed]},
+ tcp_closed,
+ {tcp_error,econnaborted}
+ ]},
receive_msg}
]
).
@@ -475,7 +477,8 @@ bad_packet_length(Config, LengthExcess) ->
%% Prohibit remote decoder starvation:
{send, #ssh_msg_service_request{name="ssh-userauth"}},
{match, {'or',[#ssh_msg_disconnect{_='_'},
- tcp_closed
+ tcp_closed,
+ {tcp_error,econnaborted}
]},
receive_msg}
], InitialState).
@@ -507,7 +510,8 @@ bad_service_name_length(Config, LengthExcess) ->
%% Prohibit remote decoder starvation:
{send, #ssh_msg_service_request{name="ssh-userauth"}},
{match, {'or',[#ssh_msg_disconnect{_='_'},
- tcp_closed
+ tcp_closed,
+ {tcp_error,econnaborted}
]},
receive_msg}
], InitialState).
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 424afc76fe..ed76f4f795 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -646,3 +646,15 @@ ssh_supports(Alg, SshDefaultAlg_tag) ->
{false,UnSup}
end
end.
+
+%%%----------------------------------------------------------------
+has_inet6_address() ->
+ try
+ [throw(6) || {ok,L} <- [inet:getifaddrs()],
+ {_,L1} <- L,
+ {addr,{_,_,_,_,_,_,_,_}} <- L1]
+ of
+ [] -> false
+ catch
+ throw:6 -> true
+ end.
diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl
index d1dfa2efdf..18690d8669 100644
--- a/lib/ssh/test/ssh_to_openssh_SUITE.erl
+++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl
@@ -96,19 +96,9 @@ end_per_group(_, Config) ->
init_per_testcase(erlang_server_openssh_client_public_key_dsa, Config) ->
- case ssh_test_lib:openssh_supports(sshc, public_key, 'ssh-dss') of
- true ->
- init_per_testcase('__default__',Config);
- false ->
- {skip,"openssh client does not support DSA"}
- end;
+ chk_key(sshc, 'ssh-dss', ".ssh/id_dsa", Config);
init_per_testcase(erlang_client_openssh_server_publickey_dsa, Config) ->
- case ssh_test_lib:openssh_supports(sshd, public_key, 'ssh-dss') of
- true ->
- init_per_testcase('__default__',Config);
- false ->
- {skip,"openssh client does not support DSA"}
- end;
+ chk_key(sshd, 'ssh-dss', ".ssh/id_dsa", Config);
init_per_testcase(_TestCase, Config) ->
ssh:start(),
Config.
@@ -117,6 +107,27 @@ end_per_testcase(_TestCase, _Config) ->
ssh:stop(),
ok.
+
+chk_key(Pgm, Name, File, Config) ->
+ case ssh_test_lib:openssh_supports(Pgm, public_key, Name) of
+ true ->
+ {skip,lists:concat(["openssh client does not support ",Name])};
+ false ->
+ {ok,[[Home]]} = init:get_argument(home),
+ KeyFile = filename:join(Home, File),
+ case file:read_file(KeyFile) of
+ {ok, Pem} ->
+ case public_key:pem_decode(Pem) of
+ [{_,_, not_encrypted}] ->
+ init_per_testcase('__default__',Config);
+ _ ->
+ {skip, {error, "Has pass phrase can not be used by automated test case"}}
+ end;
+ _ ->
+ {skip, lists:concat(["no ~/",File])}
+ end
+ end.
+
%%--------------------------------------------------------------------
%% Test Cases --------------------------------------------------------
%%--------------------------------------------------------------------
@@ -328,27 +339,16 @@ erlang_client_openssh_server_publickey_rsa(Config) when is_list(Config) ->
erlang_client_openssh_server_publickey_dsa() ->
[{doc, "Validate using dsa publickey."}].
erlang_client_openssh_server_publickey_dsa(Config) when is_list(Config) ->
- {ok,[[Home]]} = init:get_argument(home),
- KeyFile = filename:join(Home, ".ssh/id_dsa"),
- case file:read_file(KeyFile) of
- {ok, Pem} ->
- case public_key:pem_decode(Pem) of
- [{_,_, not_encrypted}] ->
- ConnectionRef =
- ssh_test_lib:connect(?SSH_DEFAULT_PORT,
- [{public_key_alg, ssh_dsa},
- {user_interaction, false},
- silently_accept_hosts]),
- {ok, Channel} =
- ssh_connection:session_channel(ConnectionRef, infinity),
- ok = ssh_connection:close(ConnectionRef, Channel),
- ok = ssh:close(ConnectionRef);
- _ ->
- {skip, {error, "Has pass phrase can not be used by automated test case"}}
- end;
- _ ->
- {skip, "no ~/.ssh/id_dsa"}
- end.
+ ConnectionRef =
+ ssh_test_lib:connect(?SSH_DEFAULT_PORT,
+ [{public_key_alg, ssh_dsa},
+ {user_interaction, false},
+ silently_accept_hosts]),
+ {ok, Channel} =
+ ssh_connection:session_channel(ConnectionRef, infinity),
+ ok = ssh_connection:close(ConnectionRef, Channel),
+ ok = ssh:close(ConnectionRef).
+
%%--------------------------------------------------------------------
erlang_server_openssh_client_public_key_dsa() ->
[{doc, "Validate using dsa publickey."}].
@@ -360,7 +360,7 @@ erlang_server_openssh_client_public_key_dsa(Config) when is_list(Config) ->
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{public_key_alg, ssh_dsa},
{failfun, fun ssh_test_lib:failfun/2}]),
-
+
ct:sleep(500),
Cmd = "ssh -p " ++ integer_to_list(Port) ++
@@ -369,12 +369,12 @@ erlang_server_openssh_client_public_key_dsa(Config) when is_list(Config) ->
SshPort = open_port({spawn, Cmd}, [binary]),
receive
- {SshPort,{data, <<"2\n">>}} ->
+ {SshPort,{data, <<"2\n">>}} ->
ok
after ?TIMEOUT ->
ct:fail("Did not receive answer")
end,
- ssh:stop_daemon(Pid).
+ ssh:stop_daemon(Pid).
%%--------------------------------------------------------------------
erlang_client_openssh_server_password() ->
@@ -384,10 +384,10 @@ erlang_client_openssh_server_password(Config) when is_list(Config) ->
UserDir = ?config(data_dir, Config),
{error, Reason0} =
ssh:connect(any, ?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
- {user, "foo"},
- {password, "morot"},
- {user_interaction, false},
- {user_dir, UserDir}]),
+ {user, "foo"},
+ {password, "morot"},
+ {user_interaction, false},
+ {user_dir, UserDir}]),
ct:log("Test of user foo that does not exist. "
"Error msg: ~p~n", [Reason0]),