1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | Test DFS blobs.
|
---|
5 |
|
---|
6 | Copyright (C) Matthieu Patou <mat@matws.net> 2009-2010
|
---|
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/ndr/ndr.h"
|
---|
24 | #include "librpc/gen_ndr/ndr_dfsblobs.h"
|
---|
25 | #include "librpc/gen_ndr/dfsblobs.h"
|
---|
26 |
|
---|
27 | DATA_BLOB blob;
|
---|
28 | static const uint8_t dfs_get_ref_in[] = {
|
---|
29 | 0x03, 0x00, 0x5c, 0x00, 0x57, 0x00, 0x32, 0x00,
|
---|
30 | 0x4b, 0x00, 0x33, 0x00, 0x00, 0x00 };
|
---|
31 |
|
---|
32 | static const uint8_t dfs_get_ref_out[] = {
|
---|
33 | 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
34 | 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00,
|
---|
35 | 0x58, 0x02, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00,
|
---|
36 | 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
38 | 0x00, 0x00, 0x5c, 0x00, 0x6d, 0x00, 0x73, 0x00,
|
---|
39 | 0x77, 0x00, 0x32, 0x00, 0x6b, 0x00, 0x33, 0x00,
|
---|
40 | 0x2e, 0x00, 0x74, 0x00, 0x73, 0x00, 0x74, 0x00,
|
---|
41 | 0x00, 0x00, 0x5c, 0x00, 0x77, 0x00, 0x32, 0x00,
|
---|
42 | 0x6b, 0x00, 0x33, 0x00, 0x61, 0x00, 0x64, 0x00,
|
---|
43 | 0x76, 0x00, 0x7a, 0x00, 0x30, 0x00, 0x31, 0x00,
|
---|
44 | 0x2e, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x77, 0x00,
|
---|
45 | 0x32, 0x00, 0x6b, 0x00, 0x33, 0x00, 0x2e, 0x00,
|
---|
46 | 0x74, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00};
|
---|
47 |
|
---|
48 | static const uint8_t dfs_get_ref_out2[] = {
|
---|
49 | 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
---|
50 | 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00,
|
---|
51 | 0x58, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
|
---|
52 | 0x00, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00,
|
---|
53 | 0x02, 0x00, 0x58, 0x02, 0x00, 0x00, 0x22, 0x00,
|
---|
54 | 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x57, 0x00,
|
---|
55 | 0x32, 0x00, 0x4b, 0x00, 0x38, 0x00, 0x52, 0x00,
|
---|
56 | 0x32, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x77, 0x00,
|
---|
57 | 0x32, 0x00, 0x6b, 0x00, 0x38, 0x00, 0x72, 0x00,
|
---|
58 | 0x32, 0x00, 0x2e, 0x00, 0x6d, 0x00, 0x61, 0x00,
|
---|
59 | 0x74, 0x00, 0x77, 0x00, 0x73, 0x00, 0x2e, 0x00,
|
---|
60 | 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x00, 0x00
|
---|
61 | };
|
---|
62 | static bool dfs_referral_out_check(struct torture_context *tctx, struct dfs_referral_resp *r)
|
---|
63 | {
|
---|
64 | torture_assert_str_equal(tctx,
|
---|
65 | r->referral_entries[0].referral.v3.data.referrals.r2.special_name,
|
---|
66 | "\\msw2k3.tst", "Special name");
|
---|
67 | ndr_push_struct_blob(&blob, tctx, r, (ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
|
---|
68 | torture_assert_int_equal(tctx, blob.data[blob.length-2], 0, "expanded names not null terminated");
|
---|
69 | torture_assert_int_equal(tctx, blob.data[blob.length-1], 0, "expanded names not null terminated");
|
---|
70 | return true;
|
---|
71 | }
|
---|
72 |
|
---|
73 | struct torture_suite *ndr_dfsblob_suite(TALLOC_CTX *ctx)
|
---|
74 | {
|
---|
75 | struct torture_suite *suite = torture_suite_create(ctx, "dfsblob");
|
---|
76 |
|
---|
77 | torture_suite_add_ndr_pull_test(suite, dfs_GetDFSReferral_in, dfs_get_ref_in, NULL);
|
---|
78 |
|
---|
79 | torture_suite_add_ndr_pull_test(suite, dfs_referral_resp, dfs_get_ref_out2, NULL);
|
---|
80 |
|
---|
81 | torture_suite_add_ndr_pull_test(suite, dfs_referral_resp, dfs_get_ref_out,dfs_referral_out_check);
|
---|
82 |
|
---|
83 | return suite;
|
---|
84 | }
|
---|