]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Convert samba3.raw.mkdir test to smb2
authorDavid Mulder <dmulder@suse.com>
Thu, 23 Jan 2020 14:26:53 +0000 (07:26 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 28 Apr 2020 19:46:32 +0000 (19:46 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 888abcaf8ffbec45fc47520bd3f544e3aa6f58f2)

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 28 19:46:32 UTC 2020 on sn-devel-184

selftest/skip
selftest/todo_smb2_tests_to_port.list
source3/selftest/tests.py
source4/torture/smb2/mkdir.c [new file with mode: 0644]
source4/torture/smb2/smb2.c
source4/torture/smb2/wscript_build

index 08862781946d9e5853f2ec50d59fb0ba9aee89d5..d13cf7cd18bd7af2e2061e3f1962e63d5bb6c3c1 100644 (file)
@@ -160,3 +160,4 @@ bench # don't run benchmarks in our selftest
 ^samba.tests.dcerpc.unix  # This contains a server-side getpwuid call which hangs the server when nss_winbindd is in use
 ^samba4.smb2.mangle.*\(ad_dc_ntvfs\)$ # Ignore ad_dc_ntvfs since this is a new test
 ^samba4.smb2.tcon.*\(ad_dc_ntvfs\)$ # Ignore ad_dc_ntvfs since this is a new test
+^samba4.smb2.mkdir.*\(ad_dc_ntvfs\)$ # Ignore ad_dc_ntvfs since this is a new test
index def79e16bff28f0a5a5681169764f6885bd1fe83..a9d7b8b48c5d8fced67861f5b4bb1195401c930a 100644 (file)
@@ -100,8 +100,6 @@ samba3.raw.composite(nt4_dc_smb1)
 samba3.raw.eas(ad_dc_smb1)
 samba3.raw.eas(nt4_dc_smb1)
 samba3.raw.lock(nt4_dc_smb1)
-samba3.raw.mkdir(ad_dc_smb1)
-samba3.raw.mkdir(nt4_dc_smb1)
 samba3.raw.notify(nt4_dc_smb1)
 samba3.raw.open(ad_dc_smb1)
 samba3.raw.open(nt4_dc_smb1)
index dafa93b5784578fb212cf8fac567493ed32f484a..45b8dca56c2574cc95d4072a6ba12af856bd51cf 100755 (executable)
@@ -826,7 +826,7 @@ for t in tests:
                   "raw.write",]) :
         plansmbtorture4testsuite(t, "nt4_dc_smb1", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc_smb1", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
-    elif t in ["base.mangle", "base.tcon"]:
+    elif t in ["base.mangle", "base.tcon", "raw.mkdir"]:
         plansmbtorture4testsuite(t, "nt4_dc_smb1_done", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc_smb1_done", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
     else:
diff --git a/source4/torture/smb2/mkdir.c b/source4/torture/smb2/mkdir.c
new file mode 100644 (file)
index 0000000..f797b5c
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+   Unix SMB/CIFS implementation.
+   RAW_MKDIR_* and RAW_RMDIR_* individual test suite
+   Copyright (C) Andrew Tridgell 2003
+   Copyright (C) David Mulder 2020
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/util.h"
+#include "torture/smb2/proto.h"
+#include "libcli/smb_composite/smb_composite.h"
+
+#define BASEDIR "mkdirtest"
+
+/*
+  test mkdir ops
+*/
+bool torture_smb2_mkdir(struct torture_context *tctx, struct smb2_tree *tree)
+{
+       struct smb2_handle h = {{0}};
+       const char *path = BASEDIR "\\mkdir.dir";
+       NTSTATUS status;
+       bool ret = true;
+
+       ret = smb2_util_setup_dir(tctx, tree, BASEDIR);
+       torture_assert(tctx, ret, "Failed to setup up test directory: " BASEDIR);
+
+       /*
+          basic mkdir
+       */
+       status = smb2_util_mkdir(tree, path);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "Incorrect status");
+
+       torture_comment(tctx, "Testing mkdir collision\n");
+
+       /* 2nd create */
+       status = smb2_util_mkdir(tree, path);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_NAME_COLLISION,
+                                          ret, done, "Incorrect status");
+
+       /* basic rmdir */
+       status = smb2_util_rmdir(tree, path);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "Incorrect status");
+
+       status = smb2_util_rmdir(tree, path);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                          ret, done, "Incorrect status");
+
+       torture_comment(tctx, "Testing mkdir collision with file\n");
+
+       /* name collision with a file */
+       smb2_create_complex_file(tctx, tree, path, &h);
+       smb2_util_close(tree, h);
+       status = smb2_util_mkdir(tree, path);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_NAME_COLLISION,
+                                          ret, done, "Incorrect status");
+
+       torture_comment(tctx, "Testing rmdir with file\n");
+
+       /* delete a file with rmdir */
+       status = smb2_util_rmdir(tree, path);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_NOT_A_DIRECTORY,
+                                          ret, done, "Incorrect status");
+
+       smb2_util_unlink(tree, path);
+
+       torture_comment(tctx, "Testing invalid dir\n");
+
+       /* create an invalid dir */
+       status = smb2_util_mkdir(tree, "..\\..\\..");
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_PATH_SYNTAX_BAD,
+                                          ret, done, "Incorrect status");
+
+       torture_comment(tctx, "Testing t2mkdir bad path\n");
+       status = smb2_util_mkdir(tree, BASEDIR "\\bad_path\\bad_path");
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_PATH_NOT_FOUND,
+                                          ret, done, "Incorrect status");
+
+done:
+       smb2_deltree(tree, BASEDIR);
+       return ret;
+}
index dffada3454edf65d8cc0d8e245aa4d66daa6191b..0754d107e2d8606760a14dae17e3706896a22cbc 100644 (file)
@@ -206,6 +206,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
        torture_suite_add_1smb2_test(suite, "maximum_allowed", torture_smb2_maximum_allowed);
        torture_suite_add_1smb2_test(suite, "mangle", torture_smb2_mangle);
        torture_suite_add_1smb2_test(suite, "tcon", run_tcon_test);
+       torture_suite_add_1smb2_test(suite, "mkdir", torture_smb2_mkdir);
 
        torture_suite_add_suite(suite, torture_smb2_charset(suite));
        suite->description = talloc_strdup(suite, "SMB2-specific tests");
index aa83ea342960f1c5ee270affd55f0ca50787cb2b..940de12aeb23ac63129a3cc40b8f09d76edb1a3b 100644 (file)
@@ -24,6 +24,7 @@ bld.SAMBA_MODULE('TORTURE_SMB2',
         mangle.c
         maxfid.c
         maxwrite.c
+        mkdir.c
         multichannel.c
         oplock_break_handler.c
         notify.c