diff options
author | Andreas Schneider <asn@samba.org> | 2018-08-27 15:59:59 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2018-08-29 21:28:41 +0200 |
commit | 7a7d95fc2c2f65f5c1268229595a523627eac96c (patch) | |
tree | 7c2f6d38e8221e2ff4a027abb8b6bf29f929f5b1 /source4 | |
parent | 30ee1d3dad611610adfbb60669d723adcaad0db5 (diff) | |
download | samba-7a7d95fc2c2f65f5c1268229595a523627eac96c.tar.gz |
s4:torture: Add a test for listing shares
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Aug 29 21:28:41 CEST 2018 on sn-devel-144
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/selftest/tests.py | 6 | ||||
-rw-r--r-- | source4/torture/libsmbclient/libsmbclient.c | 57 |
2 files changed, 62 insertions, 1 deletions
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index b0584928c3a..eb85fecbcc6 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -327,7 +327,11 @@ for t in base + raw + smb2 + netapi: libsmbclient = smbtorture4_testsuites("libsmbclient.") for t in libsmbclient: - libsmbclient_testargs = ["--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER/tmp", + url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp" + if t == "libsmbclient.list_shares": + url = "smb://$USERNAME:$PASSWORD@$SERVER" + + libsmbclient_testargs = ["--option=torture:smburl=" + url, "--option=torture:replace_smbconf=%s/testdata/samba3/smb_new.conf" % srcdir()] plansmbtorture4testsuite(t, "ad_dc", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + libsmbclient_testargs) diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c index b8fab225d90..fb27ddd0326 100644 --- a/source4/torture/libsmbclient/libsmbclient.c +++ b/source4/torture/libsmbclient/libsmbclient.c @@ -522,6 +522,62 @@ done: return ok; } +static bool torture_libsmbclient_list_shares(struct torture_context *tctx) +{ + const char *smburl = torture_setting_string(tctx, "smburl", NULL); + struct smbc_dirent *dirent = NULL; + SMBCCTX *ctx = NULL; + int dhandle = -1; + bool ipc_share_found = false; + bool ok = true; + + if (smburl == NULL) { + torture_fail(tctx, + "option --option=torture:smburl=" + "smb://user:password@server missing\n"); + } + + ok = torture_libsmbclient_init_context(tctx, &ctx); + torture_assert_goto(tctx, + ok, + ok, + out, + "Failed to init context"); + smbc_set_context(ctx); + + torture_comment(tctx, "Listing: %s\n", smburl); + dhandle = smbc_opendir(smburl); + torture_assert_int_not_equal_goto(tctx, + dhandle, + -1, + ok, + out, + "Failed to open smburl"); + + while((dirent = smbc_readdir(dhandle)) != NULL) { + torture_comment(tctx, "DIR: %s\n", dirent->name); + torture_assert_not_null_goto(tctx, + dirent->name, + ok, + out, + "Failed to read name"); + + if (strequal(dirent->name, "IPC$")) { + ipc_share_found = true; + } + } + + torture_assert_goto(tctx, + ipc_share_found, + ok, + out, + "Failed to list IPC$ share"); + +out: + smbc_closedir(dhandle); + return ok; +} + NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) { struct torture_suite *suite; @@ -534,6 +590,7 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) torture_suite_add_simple_test(suite, "setConfiguration", torture_libsmbclient_setConfiguration); torture_suite_add_simple_test(suite, "options", torture_libsmbclient_options); torture_suite_add_simple_test(suite, "opendir", torture_libsmbclient_opendir); + torture_suite_add_simple_test(suite, "list_shares", torture_libsmbclient_list_shares); torture_suite_add_simple_test(suite, "readdirplus", torture_libsmbclient_readdirplus); |