aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/torture_config.c
diff options
context:
space:
mode:
authorNoName115 <robert.kolcun@gmail.com>2017-10-25 14:20:52 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-12-21 11:43:14 +0100
commit99c5160cb5a1a169f86d334017efde4cef23ead8 (patch)
tree4e084e39083dbbd833f57370bd22ab5afb11fd9b /tests/unittests/torture_config.c
parent110da49504e52780195a6029bac6720129434f6c (diff)
downloadlibssh-99c5160cb5a1a169f86d334017efde4cef23ead8.tar.gz
libssh-99c5160cb5a1a169f86d334017efde4cef23ead8.tar.xz
libssh-99c5160cb5a1a169f86d334017efde4cef23ead8.zip
config: glob support for include with test
Signed-off-by: NoName115 <robert.kolcun@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/unittests/torture_config.c')
-rw-r--r--tests/unittests/torture_config.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c
index a0b40239..8ca097c7 100644
--- a/tests/unittests/torture_config.c
+++ b/tests/unittests/torture_config.c
@@ -10,6 +10,9 @@
#define LIBSSH_TESTCONFIG2 "libssh_testconfig2.tmp"
#define LIBSSH_TESTCONFIG3 "libssh_testconfig3.tmp"
#define LIBSSH_TESTCONFIG4 "libssh_testconfig4.tmp"
+#define LIBSSH_TESTCONFIG5 "libssh_testconfig5.tmp"
+#define LIBSSH_TESTCONFIG6 "libssh_testconfig6.tmp"
+#define LIBSSH_TESTCONFIGGLOB "libssh_testc*[36].tmp"
#define USERNAME "testuser"
#define PROXYCMD "ssh -q -W %h:%p gateway.example.com"
@@ -25,6 +28,8 @@ static int setup_config_files(void **state)
unlink(LIBSSH_TESTCONFIG2);
unlink(LIBSSH_TESTCONFIG3);
unlink(LIBSSH_TESTCONFIG4);
+ unlink(LIBSSH_TESTCONFIG5);
+ unlink(LIBSSH_TESTCONFIG6);
torture_write_file(LIBSSH_TESTCONFIG1,
"User "USERNAME"\nInclude "LIBSSH_TESTCONFIG2"\n\n");
@@ -40,6 +45,13 @@ static int setup_config_files(void **state)
torture_write_file(LIBSSH_TESTCONFIG4,
"Port 123\nPort 456\n");
+ /* Testing glob include */
+ torture_write_file(LIBSSH_TESTCONFIG5,
+ "User "USERNAME"\nInclude "LIBSSH_TESTCONFIGGLOB"\n\n");
+
+ torture_write_file(LIBSSH_TESTCONFIG6,
+ "ProxyCommand "PROXYCMD"\n\n");
+
session = ssh_new();
*state = session;
@@ -52,6 +64,8 @@ static int teardown(void **state)
unlink(LIBSSH_TESTCONFIG2);
unlink(LIBSSH_TESTCONFIG3);
unlink(LIBSSH_TESTCONFIG4);
+ unlink(LIBSSH_TESTCONFIG5);
+ unlink(LIBSSH_TESTCONFIG6);
ssh_free(*state);
@@ -105,6 +119,29 @@ static void torture_config_double_ports(void **state) {
assert_true(ret == 0);
}
+static void torture_config_glob(void **state) {
+ ssh_session session = *state;
+ int ret;
+ char *v;
+
+ ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG5);
+ assert_true(ret == 0);
+
+ /* Test the variable presence */
+
+ ret = ssh_options_get(session, SSH_OPTIONS_PROXYCOMMAND, &v);
+ assert_true(ret == 0);
+
+ assert_string_equal(v, PROXYCMD);
+ ssh_string_free_char(v);
+
+ ret = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &v);
+ assert_true(ret == 0);
+
+ assert_string_equal(v, ID_FILE);
+ ssh_string_free_char(v);
+}
+
int torture_run_tests(void) {
int rc;
struct CMUnitTest tests[] = {
@@ -114,6 +151,9 @@ int torture_run_tests(void) {
cmocka_unit_test_setup_teardown(torture_config_double_ports,
setup_config_files,
teardown),
+ cmocka_unit_test_setup_teardown(torture_config_glob,
+ setup_config_files,
+ teardown),
};