summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2018-11-14 13:45:11 +0100
committerKarolin Seeger <kseeger@samba.org>2018-12-13 13:48:26 +0100
commit8c031cf05e52c1d5ade78d33db2e9f4ff21d17e7 (patch)
tree31b1475b0df437e9cd13c6290c640839990c1cf7 /source4/torture
parentb22e8f355bdb013dfdb46d2fdafaa0d8e57387b8 (diff)
downloadsamba-8c031cf05e52c1d5ade78d33db2e9f4ff21d17e7.tar.gz
s4:torture: add a test-suite for VSS
This test will not be run from the main torture test runner in selftest, as there we don't pass the required arguments 'twrp_file' and 'twrp_snapshot'. The test needs a carefully prepared environment with provisioned snapshot data, so the test will be started from a blackbox test script. That comes next. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 48ddb87a32ca44c2fcc5aac0cc28c5527dc7eade)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/smb2/create.c87
-rw-r--r--source4/torture/smb2/smb2.c1
2 files changed, 88 insertions, 0 deletions
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
index ead56eb5c40..68447935bd0 100644
--- a/source4/torture/smb2/create.c
+++ b/source4/torture/smb2/create.c
@@ -1733,6 +1733,82 @@ done:
return ret;
}
+static bool test_twrp_write(struct torture_context *tctx, struct smb2_tree *tree)
+{
+ struct smb2_create io;
+ struct smb2_handle h1 = {{0}};
+ NTSTATUS status;
+ bool ret = true;
+ char *p = NULL;
+ struct tm tm;
+ time_t t;
+ uint64_t nttime;
+ const char *file = NULL;
+ const char *snapshot = NULL;
+
+ file = torture_setting_string(tctx, "twrp_file", NULL);
+ if (file == NULL) {
+ torture_skip(tctx, "missing 'twrp_file' option\n");
+ }
+
+ snapshot = torture_setting_string(tctx, "twrp_snapshot", NULL);
+ if (snapshot == NULL) {
+ torture_skip(tctx, "missing 'twrp_snapshot' option\n");
+ }
+
+ torture_comment(tctx, "Testing timewarp (%s) (%s)\n", file, snapshot);
+
+ setenv("TZ", "GMT", 1);
+ p = strptime(snapshot, "@GMT-%Y.%m.%d-%H.%M.%S", &tm);
+ torture_assert_goto(tctx, p != NULL, ret, done, "strptime\n");
+ torture_assert_goto(tctx, *p == '\0', ret, done, "strptime\n");
+
+ t = mktime(&tm);
+ unix_to_nt_time(&nttime, t);
+
+ io = (struct smb2_create) {
+ .in.desired_access = SEC_FILE_READ_DATA,
+ .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+ .in.create_disposition = NTCREATEX_DISP_OPEN,
+ .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+ .in.fname = file,
+ .in.query_maximal_access = true,
+ .in.timewarp = nttime,
+ };
+
+ status = smb2_create(tree, tctx, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create\n");
+ smb2_util_close(tree, io.out.file.handle);
+
+ ret = io.out.maximal_access & (SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA);
+ torture_assert_goto(tctx, ret, ret, done, "Bad access\n");
+
+ io = (struct smb2_create) {
+ .in.desired_access = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA,
+ .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+ .in.create_disposition = NTCREATEX_DISP_OPEN,
+ .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+ .in.fname = file,
+ .in.timewarp = nttime,
+ };
+
+ status = smb2_create(tree, tctx, &io);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create\n");
+ h1 = io.out.file.handle;
+
+ status = smb2_util_write(tree, h1, "123", 0, 3);
+ torture_assert_ntstatus_equal_goto(tctx, status,
+ NT_STATUS_MEDIA_WRITE_PROTECTED,
+ ret, done, "smb2_create\n");
+
+ smb2_util_close(tree, h1);
+
+done:
+ return ret;
+}
+
/*
basic testing of SMB2 read
*/
@@ -1758,3 +1834,14 @@ struct torture_suite *torture_smb2_create_init(TALLOC_CTX *ctx)
return suite;
}
+
+struct torture_suite *torture_smb2_twrp_init(TALLOC_CTX *ctx)
+{
+ struct torture_suite *suite = torture_suite_create(ctx, "twrp");
+
+ torture_suite_add_1smb2_test(suite, "write", test_twrp_write);
+
+ suite->description = talloc_strdup(suite, "SMB2-TWRP tests");
+
+ return suite;
+}
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 6f9884e3c27..a835dc7c050 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -154,6 +154,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
torture_suite_add_suite(suite, torture_smb2_read_init(suite));
torture_suite_add_suite(suite, torture_smb2_aio_delay_init(suite));
torture_suite_add_suite(suite, torture_smb2_create_init(suite));
+ torture_suite_add_suite(suite, torture_smb2_twrp_init(suite));
torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
torture_suite_add_suite(suite, torture_smb2_notify_init(suite));
torture_suite_add_suite(suite, torture_smb2_notify_inotify_init(suite));