2 Unix SMB/CIFS implementation.
3 test suite for spoolss ndr operations
5 Copyright (C) Jelmer Vernooij 2007
6 Copyright (C) Guenther Deschner 2013
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "torture/ndr/ndr.h"
24 #include "librpc/gen_ndr/ndr_winspool.h"
25 #include "torture/ndr/proto.h"
27 static const uint8_t registerforremotenotifications_req_data
[] = {
28 0x00, 0x00, 0x00, 0x00, 0x6e, 0x61, 0x4c, 0x7b, 0xc1, 0x46, 0xde, 0x4b,
29 0x81, 0x29, 0xcb, 0xa4, 0xd2, 0xf4, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00,
30 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x65, 0x00,
45 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00, 0x4e, 0x00, 0x6f, 0x00,
46 0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x79, 0x00, 0x46, 0x00, 0x69, 0x00,
47 0x6c, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x46, 0x00,
48 0x6c, 0x00, 0x61, 0x00, 0x67, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00,
49 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
51 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00,
52 0x74, 0x00, 0x65, 0x00, 0x4e, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x69, 0x00,
53 0x66, 0x00, 0x79, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x74, 0x00,
54 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x4f, 0x00, 0x70, 0x00, 0x74, 0x00,
55 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x52, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00,
59 0x4e, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x79, 0x00,
60 0x46, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00,
61 0x20, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x72, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x65, 0x00,
65 0x6d, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x65, 0x00, 0x4e, 0x00, 0x6f, 0x00,
66 0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x79, 0x00, 0x46, 0x00, 0x69, 0x00,
67 0x6c, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x4e, 0x00,
68 0x6f, 0x00, 0x74, 0x00, 0x69, 0x00, 0x66, 0x00, 0x79, 0x00, 0x4f, 0x00,
69 0x70, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x73, 0x00,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
75 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
77 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00,
79 0x06, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
80 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
81 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x0b, 0x00,
82 0x0d, 0x00, 0x0f, 0x00, 0x10, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00,
83 0x16, 0x00, 0x17, 0x00
86 static bool registerforremotenotifications_req_check(struct torture_context
*tctx
,
87 struct winspool_SyncRegisterForRemoteNotifications
*r
)
89 struct winspool_PrintNamedProperty
*p
= r
->in
.pNotifyFilter
->propertiesCollection
;
90 struct spoolss_NotifyOption
*o
;
93 torture_assert(tctx
, r
->in
.pNotifyFilter
, "pNotifyFilter NULL");
95 torture_assert_int_equal(tctx
, r
->in
.pNotifyFilter
->numberOfProperties
, 4, "numberOfProperties");
97 torture_assert_str_equal(tctx
, p
[0].propertyName
, "RemoteNotifyFilter Flags", "propertyName");
98 torture_assert_int_equal(tctx
, p
[0].propertyValue
.PropertyType
, winspool_PropertyTypeInt32
, "PropertyType");
99 torture_assert_int_equal(tctx
, p
[0].propertyValue
.value
.propertyInt32
, 255, "propertyInt32");
101 torture_assert_str_equal(tctx
, p
[1].propertyName
, "RemoteNotifyFilter Options", "propertyName");
102 torture_assert_int_equal(tctx
, p
[1].propertyValue
.PropertyType
, winspool_PropertyTypeInt32
, "PropertyType");
103 torture_assert_int_equal(tctx
, p
[1].propertyValue
.value
.propertyInt32
, 0, "propertyInt32");
105 torture_assert_str_equal(tctx
, p
[2].propertyName
, "RemoteNotifyFilter Color", "propertyName");
106 torture_assert_int_equal(tctx
, p
[2].propertyValue
.PropertyType
, winspool_PropertyTypeInt32
, "PropertyType");
107 torture_assert_int_equal(tctx
, p
[2].propertyValue
.value
.propertyInt32
, 0, "propertyInt32");
109 torture_assert_str_equal(tctx
, p
[3].propertyName
, "RemoteNotifyFilter NotifyOptions", "propertyName");
110 torture_assert_int_equal(tctx
, p
[3].propertyValue
.PropertyType
, winspool_PropertyTypeNotificationOptions
, "PropertyType");
112 o
= p
[3].propertyValue
.value
.propertyOptionsContainer
.pOptions
;
114 torture_assert_int_equal(tctx
, o
->version
, 2, "version");
115 torture_assert_int_equal(tctx
, o
->flags
, 0, "flags");
116 torture_assert_int_equal(tctx
, o
->count
, 2, "count");
118 torture_assert_int_equal(tctx
, o
->types
[0].type
, PRINTER_NOTIFY_TYPE
, "type");
119 torture_assert_int_equal(tctx
, o
->types
[0].u1
, 0, "u1");
120 torture_assert_int_equal(tctx
, o
->types
[0].u2
, 0, "u2");
121 torture_assert_int_equal(tctx
, o
->types
[0].u3
, 0, "u3");
122 torture_assert_int_equal(tctx
, o
->types
[0].count
, 10, "count");
124 torture_assert_int_equal(tctx
, o
->types
[0].fields
[0].field
, PRINTER_NOTIFY_FIELD_SERVER_NAME
, "field");
125 torture_assert_int_equal(tctx
, o
->types
[0].fields
[1].field
, PRINTER_NOTIFY_FIELD_PRINTER_NAME
, "field");
126 torture_assert_int_equal(tctx
, o
->types
[0].fields
[2].field
, PRINTER_NOTIFY_FIELD_SHARE_NAME
, "field");
127 torture_assert_int_equal(tctx
, o
->types
[0].fields
[3].field
, PRINTER_NOTIFY_FIELD_PORT_NAME
, "field");
128 torture_assert_int_equal(tctx
, o
->types
[0].fields
[4].field
, PRINTER_NOTIFY_FIELD_DRIVER_NAME
, "field");
129 torture_assert_int_equal(tctx
, o
->types
[0].fields
[5].field
, PRINTER_NOTIFY_FIELD_COMMENT
, "field");
130 torture_assert_int_equal(tctx
, o
->types
[0].fields
[6].field
, PRINTER_NOTIFY_FIELD_LOCATION
, "field");
131 torture_assert_int_equal(tctx
, o
->types
[0].fields
[7].field
, PRINTER_NOTIFY_FIELD_ATTRIBUTES
, "field");
132 torture_assert_int_equal(tctx
, o
->types
[0].fields
[8].field
, PRINTER_NOTIFY_FIELD_STATUS
, "field");
133 torture_assert_int_equal(tctx
, o
->types
[0].fields
[9].field
, PRINTER_NOTIFY_FIELD_CJOBS
, "field");
135 torture_assert_int_equal(tctx
, o
->types
[1].type
, JOB_NOTIFY_TYPE
, "type");
136 torture_assert_int_equal(tctx
, o
->types
[1].u1
, 0, "u1");
137 torture_assert_int_equal(tctx
, o
->types
[1].u2
, 0, "u2");
138 torture_assert_int_equal(tctx
, o
->types
[1].u3
, 0, "u3");
139 torture_assert_int_equal(tctx
, o
->types
[1].count
, 16, "count");
141 torture_assert_int_equal(tctx
, o
->types
[1].fields
[0].field
, JOB_NOTIFY_FIELD_PRINTER_NAME
, "field");
142 torture_assert_int_equal(tctx
, o
->types
[1].fields
[1].field
, JOB_NOTIFY_FIELD_MACHINE_NAME
, "field");
143 torture_assert_int_equal(tctx
, o
->types
[1].fields
[2].field
, JOB_NOTIFY_FIELD_PORT_NAME
, "field");
144 torture_assert_int_equal(tctx
, o
->types
[1].fields
[3].field
, JOB_NOTIFY_FIELD_USER_NAME
, "field");
145 torture_assert_int_equal(tctx
, o
->types
[1].fields
[4].field
, JOB_NOTIFY_FIELD_NOTIFY_NAME
, "field");
146 torture_assert_int_equal(tctx
, o
->types
[1].fields
[5].field
, JOB_NOTIFY_FIELD_DRIVER_NAME
, "field");
147 torture_assert_int_equal(tctx
, o
->types
[1].fields
[6].field
, JOB_NOTIFY_FIELD_STATUS
, "field");
148 torture_assert_int_equal(tctx
, o
->types
[1].fields
[7].field
, JOB_NOTIFY_FIELD_STATUS_STRING
, "field");
149 torture_assert_int_equal(tctx
, o
->types
[1].fields
[8].field
, JOB_NOTIFY_FIELD_DOCUMENT
, "field");
150 torture_assert_int_equal(tctx
, o
->types
[1].fields
[9].field
, JOB_NOTIFY_FIELD_POSITION
, "field");
151 torture_assert_int_equal(tctx
, o
->types
[1].fields
[10].field
, JOB_NOTIFY_FIELD_SUBMITTED
, "field");
152 torture_assert_int_equal(tctx
, o
->types
[1].fields
[11].field
, JOB_NOTIFY_FIELD_TIME
, "field");
153 torture_assert_int_equal(tctx
, o
->types
[1].fields
[12].field
, JOB_NOTIFY_FIELD_TOTAL_PAGES
, "field");
154 torture_assert_int_equal(tctx
, o
->types
[1].fields
[13].field
, JOB_NOTIFY_FIELD_PAGES_PRINTED
, "field");
155 torture_assert_int_equal(tctx
, o
->types
[1].fields
[14].field
, JOB_NOTIFY_FIELD_TOTAL_BYTES
, "field");
156 torture_assert_int_equal(tctx
, o
->types
[1].fields
[15].field
, JOB_NOTIFY_FIELD_BYTES_PRINTED
, "field");
161 struct torture_suite
*ndr_winspool_suite(TALLOC_CTX
*ctx
)
163 struct torture_suite
*suite
= torture_suite_create(ctx
, "winspool");
165 torture_suite_add_ndr_pull_fn_test_flags(suite
,
166 winspool_SyncRegisterForRemoteNotifications
,
167 registerforremotenotifications_req_data
,
170 registerforremotenotifications_req_check
);