]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-smbtorture: add very basic RPC-NTSVCS test.
authorGünther Deschner <gd@samba.org>
Tue, 11 Nov 2008 11:36:07 +0000 (12:36 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 12 Nov 2008 09:19:53 +0000 (10:19 +0100)
Guenther

source4/selftest/skip
source4/torture/config.mk
source4/torture/rpc/ntsvcs.c [new file with mode: 0644]
source4/torture/rpc/rpc.c

index e3e2d2d52524aea660f326cdeb5032f8d2687a66..a3dfdbfbb7e449fc8c5d3554ba0492bee64e6541 100644 (file)
@@ -49,6 +49,7 @@ rpc.initshutdown                                      # Not provided by Samba 4
 rpc.svcctl                                                     # Not provided by Samba 4
 rpc.atsvc                                                      # Not provided by Samba 4
 rpc.frsapi                                                     # Not provided by Samba 4
+rpc.ntsvcs                                                     # Not provided by Samba 4
 ^samba4.base.samba3.*                                          # Samba3-specific test
 ^samba4.ntvfs.cifs.base.samba3.*                               # Samba3-specific test
 ^samba4.raw.samba3.*                                           # Samba3-specific test
index 8b12f36f952defc5854ed70028ac56ae4a587077..443cdda93668953f541521388d1a4ef935f8012e 100644 (file)
@@ -105,7 +105,7 @@ PRIVATE_DEPENDENCIES = \
                RPC_NDR_NETLOGON dcerpc_atsvc dcerpc_mgmt RPC_NDR_DRSUAPI \
                RPC_NDR_LSA RPC_NDR_EPMAPPER RPC_NDR_DFS RPC_NDR_FRSAPI RPC_NDR_SPOOLSS \
                RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_ROT RPC_NDR_DSSETUP \
-               RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER WB_HELPER LIBSAMBA-NET \
+               RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER RPC_NDR_NTSVCS WB_HELPER LIBSAMBA-NET \
                LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \
                dcerpc_server service process_model ntvfs SERVICE_SMB
 
@@ -116,7 +116,7 @@ torture_rpc_OBJ_FILES = $(addprefix $(torturesrcdir)/rpc/, \
                eventlog.o epmapper.o winreg.o initshutdown.o oxidresolve.o remact.o mgmt.o \
                scanner.o autoidl.o countcalls.o testjoin.o schannel.o netlogon.o remote_pac.o samlogon.o \
                samsync.o bind.o dssetup.o alter_context.o bench.o samba3rpc.o rpc.o async_bind.o \
-               handles.o frsapi.o object_uuid.o)
+               handles.o frsapi.o object_uuid.o ntsvcs.o)
 
 $(eval $(call proto_header_template,$(torturesrcdir)/rpc/proto.h,$(torture_rpc_OBJ_FILES:.o=.c)))
 
diff --git a/source4/torture/rpc/ntsvcs.c b/source4/torture/rpc/ntsvcs.c
new file mode 100644 (file)
index 0000000..10c1ce2
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+   Unix SMB/CIFS implementation.
+   test suite for rpc ntsvcs operations
+
+   Copyright (C) Guenther Deschner 2008
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "torture/torture.h"
+#include "torture/rpc/rpc.h"
+#include "librpc/gen_ndr/ndr_ntsvcs_c.h"
+#include "torture/util.h"
+#include "param/param.h"
+
+static bool test_PNP_GetVersion(struct torture_context *tctx,
+                               struct dcerpc_pipe *p)
+{
+       NTSTATUS status;
+       struct PNP_GetVersion r;
+       uint16_t version = 0;
+
+       r.out.version = &version;
+
+       status = dcerpc_PNP_GetVersion(p, tctx, &r);
+
+       torture_assert_ntstatus_ok(tctx, status, "PNP_GetVersion");
+       torture_assert_werr_ok(tctx, r.out.result, "PNP_GetVersion");
+       torture_assert_int_equal(tctx, version, 0x400, "invalid version");
+
+       return true;
+}
+
+static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
+                                      struct dcerpc_pipe *p)
+{
+       NTSTATUS status;
+       struct PNP_GetDeviceListSize r;
+       uint32_t size = 0;
+
+       r.in.devicename = NULL;
+       r.in.flags = 0;
+       r.out.size = &size;
+
+       status = dcerpc_PNP_GetDeviceListSize(p, tctx, &r);
+
+       torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceListSize");
+       torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceListSize");
+
+       return true;
+}
+
+static bool test_PNP_GetDeviceList(struct torture_context *tctx,
+                                  struct dcerpc_pipe *p)
+{
+       NTSTATUS status;
+       struct PNP_GetDeviceList r;
+       uint16_t *buffer = NULL;
+       uint32_t length = 0;
+
+       buffer = talloc_array(tctx, uint16_t, 0);
+
+       r.in.filter = NULL;
+       r.in.flags = 0;
+       r.in.length = &length;
+       r.out.length = &length;
+       r.out.buffer = buffer;
+
+       status = dcerpc_PNP_GetDeviceList(p, tctx, &r);
+       torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceList");
+
+       if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
+               struct PNP_GetDeviceListSize s;
+
+               s.in.devicename = NULL;
+               s.in.flags = 0;
+               s.out.size = &length;
+
+               status = dcerpc_PNP_GetDeviceListSize(p, tctx, &s);
+
+               torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceListSize");
+               torture_assert_werr_ok(tctx, s.out.result, "PNP_GetDeviceListSize");
+       }
+
+       buffer = talloc_array(tctx, uint16_t, length);
+
+       r.in.length = &length;
+       r.out.length = &length;
+       r.out.buffer = buffer;
+
+       status = dcerpc_PNP_GetDeviceList(p, tctx, &r);
+       torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceList");
+       torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceList");
+
+       return true;
+}
+
+
+struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
+{
+       struct torture_rpc_tcase *tcase;
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
+       struct torture_test *test;
+
+       tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
+                                                 &ndr_table_ntsvcs);
+
+       test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
+                                         test_PNP_GetDeviceList);
+       test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
+                                         test_PNP_GetDeviceListSize);
+       test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
+                                         test_PNP_GetVersion);
+
+       return suite;
+}
index 2fcf700c36bdc7b721b2d55d82bb2930198aef87..7fe5827ea12ff3183401be8981ecafc09512d929 100644 (file)
@@ -438,6 +438,7 @@ NTSTATUS torture_rpc_init(void)
        torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync);
        torture_suite_add_simple_test(suite, "BENCH-RPC", torture_bench_rpc);
        torture_suite_add_simple_test(suite, "ASYNCBIND", torture_async_bind);
+       torture_suite_add_suite(suite, torture_rpc_ntsvcs(suite));
 
        suite->description = talloc_strdup(suite, "DCE/RPC protocol and interface tests");