s4:torture:vfs_fruit: file without AFP_AfpInfo
[kai/samba-autobuild/.git] / source4 / torture / vfs / fruit.c
index 07124769c88b905871d2f8a186a9f93f0fa59af4..764bbcb141d40a131aaf829779b0d84a4a791ca6 100644 (file)
@@ -2769,6 +2769,43 @@ static bool test_rename_dir_openfile(struct torture_context *torture,
        return ret;
 }
 
+static bool test_afpinfo_enoent(struct torture_context *tctx,
+                               struct smb2_tree *tree)
+{
+       bool ret = true;
+       NTSTATUS status;
+       struct smb2_create create;
+       struct smb2_handle h1;
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       const char *fname = BASEDIR "\\file";
+       const char *sname = BASEDIR "\\file" AFPINFO_STREAM_NAME;
+
+       torture_comment(tctx, "Opening file without AFP_AfpInfo\n");
+
+       smb2_deltree(tree, BASEDIR);
+       status = torture_smb2_testdir(tree, BASEDIR, &h1);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir");
+       smb2_util_close(tree, h1);
+       ret = torture_setup_file(mem_ctx, tree, fname, false);
+       torture_assert_goto(tctx, ret == true, ret, done, "torture_setup_file");
+
+       torture_comment(tctx, "Opening not existing AFP_AfpInfo\n");
+
+       ZERO_STRUCT(create);
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE; /* stat open */
+       create.in.fname = sname;
+
+       status = smb2_create(tree, mem_ctx, &create);
+       torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                          ret, done, "Got unexpected AFP_AfpInfo stream");
+
+done:
+       smb2_util_unlink(tree, fname);
+       smb2_util_rmdir(tree, BASEDIR);
+       return ret;
+}
+
 /*
  * Note: This test depends on "vfs objects = catia fruit streams_xattr".  For
  * some tests torture must be run on the host it tests and takes an additional
@@ -2794,6 +2831,7 @@ struct torture_suite *torture_vfs_fruit(void)
        torture_suite_add_1smb2_test(suite, "truncate resource fork to 0 bytes", test_rfork_truncate);
        torture_suite_add_1smb2_test(suite, "opening and creating resource fork", test_rfork_create);
        torture_suite_add_1smb2_test(suite, "rename_dir_openfile", test_rename_dir_openfile);
+       torture_suite_add_1smb2_test(suite, "File without AFP_AfpInfo", test_afpinfo_enoent);
 
        return suite;
 }