s4-lib-policy: fix type of enum
[Samba.git] / source4 / torture / smb2 / notify_disabled.c
bloba7bbebdad0c8fb5f4e0a0a5f4f8ab9243e1f942e
1 /*
2 Unix SMB/CIFS implementation.
4 SMB2 notify test suite
6 Copyright (C) Stefan Metzmacher 2006
7 Copyright (C) Andrew Tridgell 2009
8 Copyright (C) Ralph Boehme 2015
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "libcli/smb2/smb2.h"
26 #include "libcli/smb2/smb2_calls.h"
27 #include "../libcli/smb/smbXcli_base.h"
29 #include "torture/torture.h"
30 #include "torture/smb2/proto.h"
31 #include "librpc/gen_ndr/ndr_security.h"
32 #include "libcli/security/security.h"
33 #include "torture/util.h"
35 #include "system/filesys.h"
36 #include "auth/credentials/credentials.h"
37 #include "lib/cmdline/popt_common.h"
38 #include "librpc/gen_ndr/security.h"
40 #include "lib/events/events.h"
42 #include "libcli/raw/libcliraw.h"
43 #include "libcli/raw/raw_proto.h"
44 #include "libcli/libcli.h"
46 #define BASEDIR "test_notify_disabled"
49 basic testing of change notify on directories
51 static bool torture_smb2_notify_disabled(struct torture_context *torture,
52 struct smb2_tree *tree1)
54 bool ret = true;
55 NTSTATUS status;
56 union smb_notify notify;
57 union smb_open io;
58 struct smb2_handle h1;
59 struct smb2_request *req;
61 torture_comment(torture, "TESTING CHANGE NOTIFY DISABLED\n");
63 smb2_deltree(tree1, BASEDIR);
64 smb2_util_rmdir(tree1, BASEDIR);
66 get a handle on the directory
68 ZERO_STRUCT(io.smb2);
69 io.generic.level = RAW_OPEN_SMB2;
70 io.smb2.in.create_flags = 0;
71 io.smb2.in.desired_access = SEC_FILE_ALL;
72 io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
73 io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
74 io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
75 NTCREATEX_SHARE_ACCESS_WRITE;
76 io.smb2.in.alloc_size = 0;
77 io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
78 io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
79 io.smb2.in.security_flags = 0;
80 io.smb2.in.fname = BASEDIR;
82 status = smb2_create(tree1, torture, &(io.smb2));
83 torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_OK,
84 ret, done, "smb2_create");
85 h1 = io.smb2.out.file.handle;
87 ZERO_STRUCT(notify.smb2);
88 notify.smb2.level = RAW_NOTIFY_SMB2;
89 notify.smb2.in.buffer_size = 1000;
90 notify.smb2.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
91 notify.smb2.in.file.handle = h1;
92 notify.smb2.in.recursive = true;
94 req = smb2_notify_send(tree1, &(notify.smb2));
95 status = smb2_notify_recv(req, torture, &(notify.smb2));
96 torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_NOT_IMPLEMENTED,
97 ret, done, "smb2_notify_recv");
99 status = smb2_util_close(tree1, h1);
100 torture_assert_ntstatus_equal_goto(torture, status, NT_STATUS_OK,
101 ret, done, "smb2_create");
103 done:
104 smb2_deltree(tree1, BASEDIR);
105 return ret;
109 basic testing of SMB2 change notify
111 struct torture_suite *torture_smb2_notify_disabled_init(TALLOC_CTX *ctx)
113 struct torture_suite *suite = torture_suite_create(ctx,
114 "change_notify_disabled");
116 torture_suite_add_1smb2_test(suite, "notfiy_disabled", torture_smb2_notify_disabled);
117 suite->description = talloc_strdup(suite, "SMB2-CHANGE-NOTIFY-DISABLED tests");
119 return suite;