s4: allow python code to dump NTACL object as well
[Samba/ekacnet.git] / source4 / torture / rpc / initshutdown.c
blob22ba3f2812739d7f02c2374660c41d57a4a291cc
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for initshutdown operations
5 Copyright (C) Tim Potter 2003
6 Copyright (C) Jelmer Vernooij 2004-2005
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/>.
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_initshutdown_c.h"
24 #include "torture/rpc/rpc.h"
26 static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
28 name->string = s;
32 static bool test_Abort(struct torture_context *tctx,
33 struct dcerpc_pipe *p)
35 struct initshutdown_Abort r;
36 NTSTATUS status;
37 uint16_t server = 0x0;
39 r.in.server = &server;
41 status = dcerpc_initshutdown_Abort(p, tctx, &r);
43 torture_assert_ntstatus_ok(tctx, status,
44 "initshutdown_Abort failed");
46 torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Abort failed");
48 return true;
51 static bool test_Init(struct torture_context *tctx,
52 struct dcerpc_pipe *p)
54 struct initshutdown_Init r;
55 NTSTATUS status;
56 uint16_t hostname = 0x0;
58 r.in.hostname = &hostname;
59 r.in.message = talloc(tctx, struct lsa_StringLarge);
60 init_lsa_StringLarge(r.in.message, "spottyfood");
61 r.in.force_apps = 1;
62 r.in.timeout = 30;
63 r.in.do_reboot = 1;
65 status = dcerpc_initshutdown_Init(p, tctx, &r);
67 torture_assert_ntstatus_ok(tctx, status, "initshutdown_Init failed");
68 torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Init failed");
70 return test_Abort(tctx, p);
73 static bool test_InitEx(struct torture_context *tctx,
74 struct dcerpc_pipe *p)
76 struct initshutdown_InitEx r;
77 NTSTATUS status;
78 uint16_t hostname = 0x0;
80 r.in.hostname = &hostname;
81 r.in.message = talloc(tctx, struct lsa_StringLarge);
82 init_lsa_StringLarge(r.in.message, "spottyfood");
83 r.in.force_apps = 1;
84 r.in.timeout = 30;
85 r.in.do_reboot = 1;
86 r.in.reason = 0;
88 status = dcerpc_initshutdown_InitEx(p, tctx, &r);
90 torture_assert_ntstatus_ok(tctx, status, "initshutdown_InitEx failed");
92 torture_assert_werr_ok(tctx, r.out.result, "initshutdown_InitEx failed");
94 return test_Abort(tctx, p);
98 struct torture_suite *torture_rpc_initshutdown(TALLOC_CTX *mem_ctx)
100 struct torture_suite *suite = torture_suite_create(mem_ctx, "INITSHUTDOWN");
101 struct torture_rpc_tcase *tcase;
102 struct torture_test *test;
104 tcase = torture_suite_add_rpc_iface_tcase(suite, "initshutdown",
105 &ndr_table_initshutdown);
107 test = torture_rpc_tcase_add_test(tcase, "Init", test_Init);
108 test->dangerous = true;
109 test = torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx);
110 test->dangerous = true;
112 return suite;