aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/ftp_SUITE.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2013-11-13 10:39:39 +0100
committerHans Nilsson <[email protected]>2013-11-19 14:39:34 +0100
commit9e1030ef6e80e101b0e572e3746ab84dde244a01 (patch)
tree1eb3e688cd813ba913965163156f02f7c63168bb /lib/inets/test/ftp_SUITE.erl
parent3d0277ef3839b1f17769151b889f4f83ef2586d2 (diff)
downloadotp-9e1030ef6e80e101b0e572e3746ab84dde244a01.tar.gz
otp-9e1030ef6e80e101b0e572e3746ab84dde244a01.tar.bz2
otp-9e1030ef6e80e101b0e572e3746ab84dde244a01.zip
ftps: working
Diffstat (limited to 'lib/inets/test/ftp_SUITE.erl')
-rw-r--r--lib/inets/test/ftp_SUITE.erl49
1 files changed, 33 insertions, 16 deletions
diff --git a/lib/inets/test/ftp_SUITE.erl b/lib/inets/test/ftp_SUITE.erl
index fcee2eddde..dea147fb56 100644
--- a/lib/inets/test/ftp_SUITE.erl
+++ b/lib/inets/test/ftp_SUITE.erl
@@ -32,15 +32,18 @@
-compile(export_all).
-define(FTP_USER, "anonymous").
--define(FTP_PASS, (fun({ok,__H}) -> "ftp_SUITE@" ++ __H;
- (_) -> "ftp_SUITE@localhost"
- end)(inet:gethostname())
+-define(FTP_PASS(Cmnt), (fun({ok,__H}) -> "ftp_SUITE_"++Cmnt++"@" ++ __H;
+ (_) -> "ftp_SUITE_"++Cmnt++"@localhost"
+ end)(inet:gethostname())
).
-define(BAD_HOST, "badhostname").
-define(BAD_USER, "baduser").
-define(BAD_DIR, "baddirectory").
+go() -> ct:run_test([{suite,"ftp_SUITE"}, {logdir,"LOG"}]).
+gos() -> ct:run_test([{suite,"ftp_SUITE"}, {group,ftps_passive}, {logdir,"LOG"}]).
+
%%--------------------------------------------------------------------
%% Common Test interface functions -----------------------------------
%%--------------------------------------------------------------------
@@ -112,14 +115,24 @@ ftp_tests()->
[{"vsftpd",
fun(__CONF__) ->
%% make_config_file(vsftpd, Conf),
- ConfFile = filename:join(?config(data_dir,__CONF__), "vsftpd.conf"),
+ DataDir = ?config(data_dir,__CONF__),
+ ConfFile = filename:join(DataDir, "vsftpd.conf"),
AnonRoot = ?config(priv_dir,__CONF__),
- Cmd = ["vsftpd \"",ConfFile,"\"",
+ Cmd = ["vsftpd "++filename:join(DataDir,"vsftpd.conf"),
" -oftpd_banner=erlang_otp_testing",
- " -oanon_root=\"",AnonRoot,"\""
+ " -oanon_root=\"",AnonRoot,"\"",
+ " -orsa_cert_file=\"",filename:join(DataDir,"cert.pem"),"\"",
+ " -orsa_private_key_file=\"",filename:join(DataDir,"key.pem"),"\""
],
- ct:log("~s",[Cmd]),
- case os:cmd(Cmd) of
+ Result = os:cmd(Cmd),
+ ct:log("Config file:~n~s~n~nServer start command:~n ~s~nResult:~n ~p",
+ [case file:read_file(ConfFile) of
+ {ok,X} -> X;
+ _ -> ""
+ end,
+ Cmd, Result
+ ]),
+ case Result of
[] -> {ok,'dont care'};
[Msg] -> {error,Msg}
end
@@ -154,7 +167,7 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
ps_ftpd(Config),
-%% stop_ftpd(Config),
+ stop_ftpd(Config),
ps_ftpd(Config),
ok.
@@ -171,19 +184,23 @@ init_per_testcase(Case, Config0) ->
catch
_:_-> ok
end,
+ TLS = [{tls,[{reuse_sessions,true}]}],
+ ACTIVE = [{mode,active}],
+ PASSIVE = [{mode,passive}],
+ ExtraOpts = [verbose],
Config =
case Group of
- ftp_active -> ftp__open(Config0, [{mode,active}]);
- ftps_active -> ftp__open(Config0, [{mode,active}]);
- ftp_passive -> ftp__open(Config0, [{mode,passive}]);
- ftps_passive -> ftp__open(Config0, [{mode,passive}])
+ ftp_active -> ftp__open(Config0, ACTIVE ++ExtraOpts);
+ ftps_active -> ftp__open(Config0, TLS++ ACTIVE ++ExtraOpts);
+ ftp_passive -> ftp__open(Config0, PASSIVE ++ExtraOpts);
+ ftps_passive -> ftp__open(Config0, TLS++PASSIVE ++ExtraOpts)
end,
case Case of
user -> Config;
bad_user -> Config;
_ ->
Pid = ?config(ftp,Config),
- ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS),
+ ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS(atom_to_list(Group)++"-"++atom_to_list(Case)) ),
ok = ftp:cd(Pid, ?config(priv_dir,Config)),
Config
end.
@@ -199,7 +216,7 @@ end_per_testcase(_Case, Config) -> ftp__close(Config).
user(doc) -> ["Open an ftp connection to a host, and logon as anonymous ftp, then logoff"];
user(Config) ->
Pid = ?config(ftp, Config),
- ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS), % logon
+ ok = ftp:user(Pid, ?FTP_USER, ?FTP_PASS("")),% logon
ok = ftp:close(Pid), % logoff
{error,eclosed} = ftp:pwd(Pid), % check logoff result
ok.
@@ -208,7 +225,7 @@ user(Config) ->
bad_user(doc) -> ["Open an ftp connection to a host, and logon with bad user."];
bad_user(Config) ->
Pid = ?config(ftp, Config),
- {error, euser} = ftp:user(Pid, ?BAD_USER, ?FTP_PASS),
+ {error, euser} = ftp:user(Pid, ?BAD_USER, ?FTP_PASS("")),
ok.
%%-------------------------------------------------------------------------