mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
tests: Fix torture_server_x11().
This commit is contained in:
@@ -331,6 +331,11 @@ ssh_session torture_ssh_session(const char *host,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, "/tmp");
|
||||||
|
if (rc < 0) {
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
|
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@@ -397,9 +402,11 @@ failed:
|
|||||||
|
|
||||||
ssh_bind torture_ssh_bind(const char *addr,
|
ssh_bind torture_ssh_bind(const char *addr,
|
||||||
const unsigned int port,
|
const unsigned int port,
|
||||||
|
enum ssh_keytypes_e key_type,
|
||||||
const char *private_key_file) {
|
const char *private_key_file) {
|
||||||
int rc;
|
int rc;
|
||||||
ssh_bind sshbind = NULL;
|
ssh_bind sshbind = NULL;
|
||||||
|
enum ssh_bind_options_e opts = -1;
|
||||||
|
|
||||||
sshbind = ssh_bind_new();
|
sshbind = ssh_bind_new();
|
||||||
if (sshbind == NULL) {
|
if (sshbind == NULL) {
|
||||||
@@ -416,8 +423,21 @@ ssh_bind torture_ssh_bind(const char *addr,
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY,
|
switch (key_type) {
|
||||||
private_key_file);
|
case SSH_KEYTYPE_DSS:
|
||||||
|
opts = SSH_BIND_OPTIONS_DSAKEY;
|
||||||
|
break;
|
||||||
|
case SSH_KEYTYPE_RSA:
|
||||||
|
opts = SSH_BIND_OPTIONS_RSAKEY;
|
||||||
|
break;
|
||||||
|
case SSH_KEYTYPE_ECDSA:
|
||||||
|
opts = SSH_BIND_OPTIONS_ECDSAKEY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ssh_bind_options_set(sshbind, opts, private_key_file);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ ssh_session torture_ssh_session(const char *host,
|
|||||||
|
|
||||||
ssh_bind torture_ssh_bind(const char *addr,
|
ssh_bind torture_ssh_bind(const char *addr,
|
||||||
const unsigned int port,
|
const unsigned int port,
|
||||||
|
enum ssh_keytypes_e key_type,
|
||||||
const char *private_key_file);
|
const char *private_key_file);
|
||||||
|
|
||||||
struct torture_sftp *torture_sftp_session(ssh_session session);
|
struct torture_sftp *torture_sftp_session(ssh_session session);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
struct hostkey_state {
|
struct hostkey_state {
|
||||||
const char *hostkey;
|
const char *hostkey;
|
||||||
char *hostkey_path;
|
char *hostkey_path;
|
||||||
|
enum ssh_keytypes_e key_type;
|
||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,7 +28,8 @@ static void setup(void **state) {
|
|||||||
assert_return_code(h->fd, errno);
|
assert_return_code(h->fd, errno);
|
||||||
close(h->fd);
|
close(h->fd);
|
||||||
|
|
||||||
h->hostkey = torture_get_testkey(SSH_KEYTYPE_ECDSA, 512, 0);
|
h->key_type = SSH_KEYTYPE_RSA;
|
||||||
|
h->hostkey = torture_get_testkey(h->key_type, 0, 0);
|
||||||
|
|
||||||
torture_write_file(h->hostkey_path, h->hostkey);
|
torture_write_file(h->hostkey_path, h->hostkey);
|
||||||
|
|
||||||
@@ -152,7 +154,10 @@ static void test_ssh_channel_request_x11(void **state) {
|
|||||||
ssh_callbacks_init(&server_cb);
|
ssh_callbacks_init(&server_cb);
|
||||||
|
|
||||||
/* Create server */
|
/* Create server */
|
||||||
sshbind = torture_ssh_bind("localhost", TEST_SERVER_PORT, h->hostkey_path);
|
sshbind = torture_ssh_bind("localhost",
|
||||||
|
TEST_SERVER_PORT,
|
||||||
|
h->key_type,
|
||||||
|
h->hostkey_path);
|
||||||
assert_non_null(sshbind);
|
assert_non_null(sshbind);
|
||||||
|
|
||||||
/* Get client to connect */
|
/* Get client to connect */
|
||||||
|
|||||||
Reference in New Issue
Block a user