tests: Add port option to torture_ssh_session

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Alan Dunn
2014-04-19 14:27:48 -05:00
committed by Andreas Schneider
parent 8db4520d89
commit f4154c503b
6 changed files with 12 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ static void setup(void **state)
user = getenv("TORTURE_USER");
password = getenv("TORTURE_PASSWORD");
session = torture_ssh_session(host, user, password);
session = torture_ssh_session(host, NULL, user, password);
assert_non_null(session);
*state = session;

View File

@@ -39,7 +39,7 @@ static void setup(void **state)
user = getenv("TORTURE_USER");
password = getenv("TORTURE_PASSWORD");
session = torture_ssh_session(host, user, password);
session = torture_ssh_session(host, NULL, user, password);
assert_false(session == NULL);
*state = session;

View File

@@ -18,7 +18,7 @@ static void setup(void **state) {
user = getenv("TORTURE_USER");
password = getenv("TORTURE_PASSWORD");
session = torture_ssh_session(host, user, password);
session = torture_ssh_session(host, NULL, user, password);
assert_false(session == NULL);
t = torture_sftp_session(session);
assert_false(t == NULL);

View File

@@ -20,7 +20,7 @@ static void setup(void **state) {
user = getenv("TORTURE_USER");
password = getenv("TORTURE_PASSWORD");
session = torture_ssh_session(host, user, password);
session = torture_ssh_session(host, NULL, user, password);
assert_false(session == NULL);
t = torture_sftp_session(session);
assert_false(t == NULL);

View File

@@ -315,6 +315,7 @@ int torture_isdir(const char *path) {
}
ssh_session torture_ssh_session(const char *host,
const unsigned int *port,
const char *user,
const char *password) {
ssh_session session;
@@ -334,6 +335,12 @@ ssh_session torture_ssh_session(const char *host,
goto failed;
}
if (port != NULL) {
if (ssh_options_set(session, SSH_OPTIONS_PORT, port) < 0) {
goto failed;
}
}
if (user != NULL) {
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
goto failed;

View File

@@ -62,6 +62,7 @@ int torture_isdir(const char *path);
int torture_libssh_verbosity(void);
ssh_session torture_ssh_session(const char *host,
const unsigned int *port,
const char *user,
const char *password);