~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to source4/torture/rpc/object_uuid.c

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   Unix SMB/CIFS implementation.
 
3
 
 
4
   test suite for behaviour of object uuids in rpc requests
 
5
 
 
6
   Copyright (C) Stefan Metzmacher 2008
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
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/>.
 
20
*/
 
21
 
 
22
#include "includes.h"
 
23
#include "torture/torture.h"
 
24
#include "librpc/gen_ndr/ndr_dssetup.h"
 
25
#include "librpc/gen_ndr/ndr_dssetup_c.h"
 
26
#include "librpc/gen_ndr/ndr_lsa.h"
 
27
#include "librpc/gen_ndr/ndr_lsa_c.h"
 
28
#include "torture/rpc/rpc.h"
 
29
 
 
30
/*
 
31
  this tests the send object uuids in the dcerpc request
 
32
*/
 
33
 
 
34
static bool test_random_uuid(struct torture_context *torture)
 
35
{
 
36
        NTSTATUS status;
 
37
        struct dcerpc_pipe *p1, *p2;
 
38
        struct rpc_request *req;
 
39
        struct GUID uuid;
 
40
        struct dssetup_DsRoleGetPrimaryDomainInformation r1;
 
41
        struct lsa_GetUserName r2;
 
42
        struct lsa_String *authority_name_p = NULL;
 
43
        struct lsa_String *account_name_p = NULL;
 
44
 
 
45
        torture_comment(torture, "RPC-OBJECTUUID-RANDOM\n");
 
46
 
 
47
        status = torture_rpc_connection(torture, &p1, &ndr_table_dssetup);
 
48
        torture_assert_ntstatus_ok(torture, status, "opening dsetup pipe1");
 
49
 
 
50
        status = torture_rpc_connection(torture, &p2, &ndr_table_lsarpc);
 
51
        torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1");
 
52
 
 
53
        uuid = GUID_random();
 
54
 
 
55
        r1.in.level = DS_ROLE_BASIC_INFORMATION;
 
56
        req = dcerpc_ndr_request_send(p1, &uuid,
 
57
                                      &ndr_table_dssetup,
 
58
                                      NDR_DSSETUP_DSROLEGETPRIMARYDOMAININFORMATION,
 
59
                                      torture, &r1);
 
60
        status = dcerpc_ndr_request_recv(req);
 
61
        torture_assert_ntstatus_ok(torture, status, "DsRoleGetPrimaryDomainInformation failed");
 
62
        torture_assert_werr_ok(torture, r1.out.result, "DsRoleGetPrimaryDomainInformation failed");
 
63
 
 
64
        uuid = GUID_random();
 
65
 
 
66
        r2.in.system_name = "\\";
 
67
        r2.in.account_name = &account_name_p;
 
68
        r2.in.authority_name = &authority_name_p;
 
69
        r2.out.account_name = &account_name_p;
 
70
        r2.out.authority_name = &authority_name_p;
 
71
 
 
72
        req = dcerpc_ndr_request_send(p2, &uuid,
 
73
                                      &ndr_table_lsarpc,
 
74
                                      NDR_LSA_GETUSERNAME,
 
75
                                      torture, &r2);
 
76
        status = dcerpc_ndr_request_recv(req);
 
77
        torture_assert_ntstatus_ok(torture, status, "lsaClose failed");
 
78
        torture_assert_ntstatus_ok(torture, r2.out.result, "lsaClose failed");
 
79
 
 
80
        return true;
 
81
}
 
82
 
 
83
struct torture_suite *torture_rpc_object_uuid(TALLOC_CTX *mem_ctx)
 
84
{
 
85
        struct torture_suite *suite;
 
86
        suite = torture_suite_create(mem_ctx, "OBJECTUUID");
 
87
        torture_suite_add_simple_test(suite, "random-uuid", test_random_uuid);
 
88
        return suite;
 
89
}