diff options
author | Fredrik Gustafsson <fredrik@erlang.org> | 2013-03-12 09:48:28 +0100 |
---|---|---|
committer | Fredrik Gustafsson <fredrik@erlang.org> | 2013-03-27 11:23:16 +0100 |
commit | 405a927dbb9cd64c8706066d5c81e670ec5e2ae7 (patch) | |
tree | f3f755a1e44c4d872a9f6a889e7d0b8aebeca584 /lib/common_test/src/unix_telnet.erl | |
parent | 9cb286490be37dbbc18a95758678028bc3778953 (diff) | |
download | otp-405a927dbb9cd64c8706066d5c81e670ec5e2ae7.tar.gz otp-405a927dbb9cd64c8706066d5c81e670ec5e2ae7.tar.bz2 otp-405a927dbb9cd64c8706066d5c81e670ec5e2ae7.zip |
Added testcases for ct_telnet and opportunity to connect to telnet without user and password.
Diffstat (limited to 'lib/common_test/src/unix_telnet.erl')
-rw-r--r-- | lib/common_test/src/unix_telnet.erl | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/common_test/src/unix_telnet.erl b/lib/common_test/src/unix_telnet.erl index 99ce92e9f1..71df2ab44e 100644 --- a/lib/common_test/src/unix_telnet.erl +++ b/lib/common_test/src/unix_telnet.erl @@ -94,11 +94,16 @@ connect(Ip,Port,Timeout,KeepAlive,Extra) -> {Username,Password} -> connect1(Ip,Port,Timeout,KeepAlive,Username,Password); Name -> - case get_username_and_password(Name) of - {ok,{Username,Password}} -> - connect1(Ip,Port,Timeout,KeepAlive,Username,Password); - Error -> - Error + case not_require_user_and_pass(Name) of + true -> + connect_without_username_and_pass(Ip,Port,Timeout,KeepAlive); + _ -> + case get_username_and_password(Name) of + {ok,{Username,Password}} -> + connect1(Ip,Port,Timeout,KeepAlive,Username,Password); + Error -> + Error + end end end. @@ -144,6 +149,27 @@ connect1(Ip,Port,Timeout,KeepAlive,Username,Password) -> end_log(), Result. +connect_without_username_and_pass(Ip,Port,Timeout,KeepAlive) -> + start_log("unix_telnet:connect"), + Result = + case ct_telnet_client:open(Ip,Port,Timeout,KeepAlive) of + {ok,Pid} -> + {ok, Pid}; + Error -> + cont_log("Could not open telnet connection\n~p\n",[Error]), + Error + end, + end_log(), + Result. + +not_require_user_and_pass(Name) -> + case ct:get_config({Name, not_require_user_and_pass}) of + undefined -> + false; + _ -> + true + end. + get_username_and_password(Name) -> case ct:get_config({Name,username}) of undefined -> |