2 Unix SMB/CIFS implementation.
3 test suite for session setup operations
4 Copyright (C) Gregor Beck 2012
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "torture/raw/proto.h"
24 #include "smb_composite/smb_composite.h"
25 #include "lib/cmdline/popt_common.h"
26 #include "param/param.h"
27 #include "torture/util.h"
30 static bool test_session_reauth(struct torture_context *tctx,
31 struct smbcli_state *cli)
34 struct smb_composite_sesssetup io;
41 uint16_t vuid1 = cli->session->vuid;
43 data = generate_random_str(tctx, dlen);
44 torture_assert(tctx, (data != NULL), "memory allocation failed");
45 snprintf(fname, sizeof(fname), "raw_session_reconnect_%.8s.dat", data);
47 fnum = smbcli_nt_create_full(cli->tree, fname, 0,
49 FILE_ATTRIBUTE_NORMAL,
50 NTCREATEX_SHARE_ACCESS_NONE,
51 NTCREATEX_DISP_OPEN_IF,
52 NTCREATEX_OPTIONS_DELETE_ON_CLOSE,
54 torture_assert_ntstatus_ok_goto(tctx, smbcli_nt_error(cli->tree), ok,
56 torture_assert_goto(tctx, fnum > 0, ok, done, "create file");
58 num = smbcli_smbwrite(cli->tree, fnum, data, 0, dlen);
59 torture_assert_int_equal_goto(tctx, num, dlen, ok, done, "write file");
62 io.in.sesskey = cli->transport->negotiate.sesskey;
63 io.in.capabilities = cli->transport->negotiate.capabilities;
64 io.in.credentials = cmdline_credentials;
65 io.in.workgroup = lpcfg_workgroup(tctx->lp_ctx);
66 io.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx);
67 status = smb_composite_sesssetup(cli->session, &io);
68 torture_assert_ntstatus_ok_goto(tctx, status, ok, done, "setup2");
69 torture_assert_int_equal_goto(tctx, io.out.vuid, vuid1, ok, done, "setup2");
71 num = smbcli_read(cli->tree, fnum, &buf, 0, dlen);
72 torture_assert_int_equal_goto(tctx, num, dlen, ok, done, "read file");
73 torture_assert_str_equal_goto(tctx, buf, data, ok, done, "read file");
79 status = smbcli_close(cli->tree, fnum);
80 torture_assert_ntstatus_ok(tctx, status, "close");
85 struct torture_suite *torture_raw_session(TALLOC_CTX *mem_ctx)
87 struct torture_suite *suite = torture_suite_create(mem_ctx, "session");
88 suite->description = talloc_strdup(suite, "RAW-SESSION tests");
90 torture_suite_add_1smb_test(suite, "reauth", test_session_reauth);