summaryrefslogtreecommitdiff
path: root/source4/torture/raw
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2012-03-07 13:53:24 +0100
committerMichael Adam <obnox@samba.org>2012-04-25 23:15:40 +0200
commite563e5a2be617f26c6046f82da3b03b856115bbc (patch)
tree75e70b0d138e54423b9c5c1db70ae39569095faf /source4/torture/raw
parent87c23995962807ed8800a52c80eefb9860a6f726 (diff)
downloadsamba-e563e5a2be617f26c6046f82da3b03b856115bbc.tar.gz
samba-e563e5a2be617f26c6046f82da3b03b856115bbc.tar.bz2
samba-e563e5a2be617f26c6046f82da3b03b856115bbc.zip
s4:torture: add a raw.session suite with a raw.session.reauth test
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source4/torture/raw')
-rw-r--r--source4/torture/raw/raw.c1
-rw-r--r--source4/torture/raw/session.c90
2 files changed, 91 insertions, 0 deletions
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index d75488bfa0..10a0e89194 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -56,6 +56,7 @@ NTSTATUS torture_raw_init(void)
torture_suite_add_suite(suite, torture_raw_write(suite));
torture_suite_add_suite(suite, torture_raw_lock(suite));
torture_suite_add_1smb_test(suite, "context", torture_raw_context);
+ torture_suite_add_suite(suite, torture_raw_session(suite));
torture_suite_add_suite(suite, torture_raw_rename(suite));
torture_suite_add_1smb_test(suite, "seek", torture_raw_seek);
torture_suite_add_1smb_test(suite, "eas", torture_raw_eas);
diff --git a/source4/torture/raw/session.c b/source4/torture/raw/session.c
new file mode 100644
index 0000000000..5c454c6e9e
--- /dev/null
+++ b/source4/torture/raw/session.c
@@ -0,0 +1,90 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for session setup operations
+ Copyright (C) Gregor Beck 2012
+
+ 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 "torture.h"
+#include "smb_cli.h"
+#include "torture/raw/proto.h"
+#include "smb_composite/smb_composite.h"
+#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
+#include "torture/util.h"
+
+
+static bool test_session_reauth(struct torture_context *tctx,
+ struct smbcli_state *cli)
+{
+ NTSTATUS status;
+ struct smb_composite_sesssetup io;
+ int fnum, num;
+ const int dlen = 255;
+ char *data;
+ char fname[256];
+ char buf[dlen+1];
+ bool ok = true;
+
+ data = generate_random_str(tctx, dlen);
+ snprintf(fname, sizeof(fname), "raw_session_reconnect_%.8s.dat", data);
+
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_NONE,
+ NTCREATEX_DISP_OPEN_IF,
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE,
+ 0);
+ torture_assert_ntstatus_ok_goto(tctx, smbcli_nt_error(cli->tree), ok,
+ done, "create file");
+ torture_assert_goto(tctx, fnum > 0, ok, done, "create file");
+
+ num = smbcli_smbwrite(cli->tree, fnum, data, 0, dlen);
+ torture_assert_int_equal_goto(tctx, num, dlen, ok, done, "write file");
+
+ ZERO_STRUCT(io);
+ io.in.sesskey = cli->transport->negotiate.sesskey;
+ io.in.capabilities = cli->transport->negotiate.capabilities;
+ io.in.credentials = cmdline_credentials;
+ io.in.workgroup = lpcfg_workgroup(tctx->lp_ctx);
+ io.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx);
+ status = smb_composite_sesssetup(cli->session, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ok, done, "setup2");
+
+ num = smbcli_read(cli->tree, fnum, &buf, 0, dlen);
+ torture_assert_int_equal_goto(tctx, num, dlen, ok, done, "read file");
+ torture_assert_str_equal_goto(tctx, buf, data, ok, done, "read file");
+
+done:
+ talloc_free(data);
+
+ if (fnum > 0) {
+ status = smbcli_close(cli->tree, fnum);
+ torture_assert_ntstatus_ok(tctx, status, "close");
+ }
+ return ok;
+}
+
+struct torture_suite *torture_raw_session(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "session");
+ suite->description = talloc_strdup(suite, "RAW-SESSION tests");
+
+ torture_suite_add_1smb_test(suite, "reauth", test_session_reauth);
+
+ return suite;
+}