aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorLee Hambley <lee.hambley@gmail.com>2011-10-28 10:25:03 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-10-28 12:14:34 +0200
commit6bd95b50f535d07594f3659c67a1f5e501887641 (patch)
treecdbad12bf36f46152353596f516c162805576b28 /tests/unittests
parentd8d9755b7ddeb2aee944d086ef95589a37532fd1 (diff)
downloadlibssh-6bd95b50f535d07594f3659c67a1f5e501887641.tar.gz
libssh-6bd95b50f535d07594f3659c67a1f5e501887641.tar.xz
libssh-6bd95b50f535d07594f3659c67a1f5e501887641.zip
Implement ssh_options_get(ssh_session, enum ssh_options_e, char**).
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/torture_options.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index 23516944..059095a7 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -32,6 +32,20 @@ static void torture_options_set_host(void **state) {
assert_string_equal(session->username, "guru");
}
+static void torture_options_get_host(void **state) {
+ ssh_session session = *state;
+ int rc;
+ char* host = NULL;
+
+ rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
+ assert_true(rc == 0);
+ assert_string_equal(session->host, "localhost");
+
+ assert_false(ssh_options_get(session, SSH_OPTIONS_HOST, &host));
+
+ assert_string_equal(host, "localhost");
+}
+
static void torture_options_set_port(void **state) {
ssh_session session = *state;
int rc;
@@ -52,6 +66,16 @@ static void torture_options_set_port(void **state) {
assert_true(rc == -1);
}
+static void torture_options_get_user(void **state) {
+ ssh_session session = *state;
+ char* user = NULL;
+ int rc;
+ rc = ssh_options_set(session, SSH_OPTIONS_USER, "magicaltrevor");
+ assert_true(rc == 0);
+ rc = ssh_options_get(session, SSH_OPTIONS_USER, &user);
+ assert_string_equal(user, "magicaltrevor");
+}
+
static void torture_options_set_fd(void **state) {
ssh_session session = *state;
socket_t fd = 42;
@@ -117,14 +141,36 @@ static void torture_options_set_identity(void **state) {
assert_string_equal(session->identity->root->next->data, "identity1");
}
+static void torture_options_get_identity(void **state) {
+ ssh_session session = *state;
+ char *identity = NULL;
+ int rc;
+
+ rc = ssh_options_set(session, SSH_OPTIONS_ADD_IDENTITY, "identity1");
+ assert_true(rc == 0);
+ rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
+ assert_true(rc == 0);
+ assert_string_equal(identity, "identity1");
+
+ rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
+ assert_true(rc == 0);
+ assert_string_equal(session->identity->root->data, "identity2");
+ rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
+ assert_true(rc == 0);
+ assert_string_equal(identity, "identity2");
+}
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
unit_test_setup_teardown(torture_options_set_host, setup, teardown),
+ unit_test_setup_teardown(torture_options_get_host, setup, teardown),
unit_test_setup_teardown(torture_options_set_port, setup, teardown),
unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
unit_test_setup_teardown(torture_options_set_user, setup, teardown),
+ unit_test_setup_teardown(torture_options_get_user, setup, teardown),
unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
+ unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
};
ssh_init();