summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-04-30 16:40:14 +0200
committerStefan Metzmacher <metze@samba.org>2012-05-17 20:04:35 +0200
commit50e1861381f4f04d8c0430d6e32ec53d59118be9 (patch)
treedf981a7ebd724c84a5fde3cfd7674c2774de4748 /source4/torture
parent908b737a299a9493036e1d661f3742fb197d415f (diff)
downloadsamba-50e1861381f4f04d8c0430d6e32ec53d59118be9.tar.gz
samba-50e1861381f4f04d8c0430d6e32ec53d59118be9.tar.bz2
samba-50e1861381f4f04d8c0430d6e32ec53d59118be9.zip
s4:torture: add smb2.session.reconnect2 test
This uses just one transport connection and demonstrates the implicit logoff of the previous session. metze
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/smb2/session.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/source4/torture/smb2/session.c b/source4/torture/smb2/session.c
index 296c7251d6..516f1649bc 100644
--- a/source4/torture/smb2/session.c
+++ b/source4/torture/smb2/session.c
@@ -137,6 +137,69 @@ done:
return ret;
}
+/**
+ * basic test for doing a session reconnect on one connection
+ */
+bool test_session_reconnect2(struct torture_context *tctx, struct smb2_tree *tree)
+{
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ char fname[256];
+ struct smb2_handle _h1;
+ struct smb2_handle *h1 = NULL;
+ struct smb2_create io1;
+ uint64_t previous_session_id;
+ bool ret = true;
+ struct smb2_session *session2;
+ union smb_fileinfo qfinfo;
+
+ /* Add some random component to the file name. */
+ snprintf(fname, 256, "session_reconnect_%s.dat",
+ generate_random_str(tctx, 8));
+
+ smb2_util_unlink(tree, fname);
+
+ smb2_oplock_create_share(&io1, fname,
+ smb2_util_share_access(""),
+ smb2_util_oplock_level("b"));
+ io1.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
+
+ status = smb2_create(tree, mem_ctx, &io1);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ _h1 = io1.out.file.handle;
+ h1 = &_h1;
+ CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
+
+ /* disconnect, reconnect and then do durable reopen */
+ previous_session_id = smb2cli_session_current_id(tree->session->smbXcli);
+
+ torture_assert(tctx, torture_smb2_session_setup(tctx, tree->session->transport,
+ previous_session_id, tctx, &session2),
+ "session reconnect (on the same connection) failed");
+
+ /* try to access the file via the old handle */
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = _h1;
+ status = smb2_getinfo_file(tree, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
+ h1 = NULL;
+
+done:
+ if (h1 != NULL) {
+ smb2_util_close(tree, *h1);
+ }
+
+ talloc_free(tree);
+ talloc_free(session2);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
bool test_session_reauth1(struct torture_context *tctx, struct smb2_tree *tree)
{
NTSTATUS status;
@@ -734,6 +797,7 @@ struct torture_suite *torture_smb2_session_init(void)
torture_suite_create(talloc_autofree_context(), "session");
torture_suite_add_1smb2_test(suite, "reconnect1", test_session_reconnect1);
+ torture_suite_add_1smb2_test(suite, "reconnect2", test_session_reconnect2);
torture_suite_add_1smb2_test(suite, "reauth1", test_session_reauth1);
torture_suite_add_1smb2_test(suite, "reauth2", test_session_reauth2);
torture_suite_add_1smb2_test(suite, "reauth3", test_session_reauth3);