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
;
42 data
= generate_random_str(tctx
, dlen
);
43 torture_assert(tctx
, (data
!= NULL
), "memory allocation failed");
44 snprintf(fname
, sizeof(fname
), "raw_session_reconnect_%.8s.dat", data
);
46 fnum
= smbcli_nt_create_full(cli
->tree
, fname
, 0,
48 FILE_ATTRIBUTE_NORMAL
,
49 NTCREATEX_SHARE_ACCESS_NONE
,
50 NTCREATEX_DISP_OPEN_IF
,
51 NTCREATEX_OPTIONS_DELETE_ON_CLOSE
,
53 torture_assert_ntstatus_ok_goto(tctx
, smbcli_nt_error(cli
->tree
), ok
,
55 torture_assert_goto(tctx
, fnum
> 0, ok
, done
, "create file");
57 num
= smbcli_smbwrite(cli
->tree
, fnum
, data
, 0, dlen
);
58 torture_assert_int_equal_goto(tctx
, num
, dlen
, ok
, done
, "write file");
61 io
.in
.sesskey
= cli
->transport
->negotiate
.sesskey
;
62 io
.in
.capabilities
= cli
->transport
->negotiate
.capabilities
;
63 io
.in
.credentials
= cmdline_credentials
;
64 io
.in
.workgroup
= lpcfg_workgroup(tctx
->lp_ctx
);
65 io
.in
.gensec_settings
= lpcfg_gensec_settings(tctx
, tctx
->lp_ctx
);
66 status
= smb_composite_sesssetup(cli
->session
, &io
);
67 torture_assert_ntstatus_ok_goto(tctx
, status
, ok
, done
, "setup2");
69 num
= smbcli_read(cli
->tree
, fnum
, &buf
, 0, dlen
);
70 torture_assert_int_equal_goto(tctx
, num
, dlen
, ok
, done
, "read file");
71 torture_assert_str_equal_goto(tctx
, buf
, data
, ok
, done
, "read file");
77 status
= smbcli_close(cli
->tree
, fnum
);
78 torture_assert_ntstatus_ok(tctx
, status
, "close");
83 struct torture_suite
*torture_raw_session(TALLOC_CTX
*mem_ctx
)
85 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "session");
86 suite
->description
= talloc_strdup(suite
, "RAW-SESSION tests");
88 torture_suite_add_1smb_test(suite
, "reauth", test_session_reauth
);