summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-14 21:37:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:48:17 -0500
commitbd7df755f326e9c601439c0aa727961c4a4f4518 (patch)
tree52d810aee2ac76f4dbdcb2329265a4dae00d40fb /source4/torture
parentd090fddd1439c2c7e5115960b510f12ea8937876 (diff)
downloadsamba-bd7df755f326e9c601439c0aa727961c4a4f4518.tar.gz
samba-bd7df755f326e9c601439c0aa727961c4a4f4518.tar.bz2
samba-bd7df755f326e9c601439c0aa727961c4a4f4518.zip
r21350: Add more tests for the NDR layer of winreg. I actually discovered a pidl bug,
so there are still two tests commented out. (This used to be commit b7f6ec5c1cf6f782991b0f4f05283d6da2c2dfe8)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/ndr/winreg.c264
1 files changed, 261 insertions, 3 deletions
diff --git a/source4/torture/ndr/winreg.c b/source4/torture/ndr/winreg.c
index e5088ab045..8b47a08aac 100644
--- a/source4/torture/ndr/winreg.c
+++ b/source4/torture/ndr/winreg.c
@@ -25,12 +25,12 @@
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/security/security.h"
-static const uint8_t winreg_closekey_data[] = {
+static const uint8_t closekey_in_data[] = {
0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48,
0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
};
-static bool winreg_closekey_check(struct torture_context *tctx,
+static bool closekey_in_check(struct torture_context *tctx,
struct winreg_CloseKey *ck)
{
torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
@@ -38,11 +38,269 @@ static bool winreg_closekey_check(struct torture_context *tctx,
return true;
}
+const static uint8_t closekey_out_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static bool closekey_out_check(struct torture_context *tctx,
+ struct winreg_CloseKey *ck)
+{
+ torture_assert_int_equal(tctx, ck->out.handle->handle_type, 0, "handle type");
+ torture_assert_werr_ok(tctx, ck->out.result, "return code");
+ return true;
+}
+
+static const uint8_t OpenHKLM_In[] = {
+ 0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
+};
+
+static bool openhklm_in_check(struct torture_context *tctx,
+ struct winreg_OpenHKLM *r)
+{
+ torture_assert(tctx, r->in.system_name != NULL, "system name pointer");
+ torture_assert_int_equal(tctx, *r->in.system_name, 34016, "system name");
+ torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
+ return true;
+}
+
+static const uint8_t openhklm_out_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
+ 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00
+};
+
+static bool openhklm_out_check(struct torture_context *tctx,
+ struct winreg_OpenHKLM *r)
+{
+ torture_assert(tctx, r->out.handle != NULL, "handle pointer");
+ torture_assert_int_equal(tctx, r->out.handle->handle_type, 0, "handle_type");
+ torture_assert_werr_ok(tctx, r->out.result, "return code");
+ return true;
+}
+
+static const uint8_t createkey_in_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
+ 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
+ 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+static bool createkey_in_check(struct torture_context *tctx,
+ struct winreg_CreateKey *r)
+{
+ torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
+ torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
+ torture_assert_int_equal(tctx, r->in.options, 0, "option");
+ torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
+ torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
+ torture_assert(tctx, r->in.action_taken == NULL, "action_taken");
+
+ return true;
+}
+
+static const uint8_t createkey_out_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x57, 0x00, 0x00, 0x00
+};
+
+static bool createkey_out_check(struct torture_context *tctx,
+ struct winreg_CreateKey *r)
+{
+ torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
+ torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
+ torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM,
+ "return code");
+
+ return true;
+}
+
+static const uint8_t enumvalue_in_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
+ 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static bool enumvalue_in_check(struct torture_context *tctx,
+ struct winreg_EnumValue *r)
+{
+ torture_assert_int_equal(tctx, r->in.enum_index, 5, "enum index");
+ torture_assert(tctx, r->in.type != NULL, "type pointer");
+ torture_assert_int_equal(tctx, *r->in.type, 0, "type");
+ torture_assert_int_equal(tctx, *r->in.size, 65535, "size");
+ torture_assert_int_equal(tctx, *r->in.length, 0, "length");
+ torture_assert_int_equal(tctx, r->in.name->size, 512, "name size");
+ torture_assert_int_equal(tctx, r->in.name->length, 0, "name length");
+
+ return true;
+}
+
+static const uint8_t enumvalue_out_data[] = {
+ 0x12, 0x00, 0x00, 0x02, 0x28, 0x91, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
+ 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xd8, 0x8c, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xe0, 0x00, 0x0c, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x63, 0x00,
+ 0x75, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x73, 0x00,
+ 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x53, 0x00,
+ 0x65, 0x00, 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00,
+ 0x73, 0x00, 0x5c, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6d, 0x00, 0x69, 0x00,
+ 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00,
+ 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf0, 0x8c, 0x07, 0x00,
+ 0x4c, 0x00, 0x00, 0x00, 0xf8, 0x8c, 0x07, 0x00, 0x4c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+static bool enumvalue_out_check(struct torture_context *tctx,
+ struct winreg_EnumValue *r)
+{
+ torture_assert_int_equal(tctx, r->out.name->size, 512, "name size");
+ torture_assert_int_equal(tctx, r->out.name->length, 18, "name length");
+ torture_assert_str_equal(tctx, r->out.name->name, "HOMEPATH", "name");
+ torture_assert_int_equal(tctx, *r->out.type, 1, "type");
+ torture_assert_int_equal(tctx, *r->out.size, 76, "size");
+ torture_assert_int_equal(tctx, *r->out.length, 76, "length");
+ torture_assert_werr_ok(tctx, r->out.result, "return code");
+
+ return true;
+}
+
+static const uint8_t queryvalue_in_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
+ 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x12, 0x00, 0x12, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00,
+ 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+static bool queryvalue_in_check(struct torture_context *tctx,
+ struct winreg_QueryValue *r)
+{
+ torture_assert_str_equal(tctx, r->in.value_name.name, "HOMEPATH", "name");
+ torture_assert_int_equal(tctx, *r->in.type, 0, "type");
+ torture_assert_int_equal(tctx, *r->in.size, 4095, "size");
+ torture_assert_int_equal(tctx, *r->in.length, 0, "length");
+ torture_assert(tctx, r->in.data == NULL, "data pointer");
+
+ return true;
+}
+
+static const uint8_t queryvalue_out_data[] = {
+ 0xd8, 0xf5, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe4, 0xf5, 0x0b, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xec, 0xf5, 0x0b, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static bool queryvalue_out_check(struct torture_context *tctx,
+ struct winreg_QueryValue *r)
+{
+ torture_assert_werr_ok(tctx, r->out.result, "return code");
+ torture_assert_int_equal(tctx, *r->out.type, 1, "type");
+ torture_assert(tctx, r->out.data == NULL, "data pointer");
+ torture_assert_int_equal(tctx, *r->out.size, 76, "size");
+ torture_assert_int_equal(tctx, *r->out.length, 0, "length");
+
+ return true;
+}
+
+static const uint8_t querymultiplevalues_in_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
+ 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x12, 0x00, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
+ 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00
+};
+
+static bool querymultiplevalues_in_check(struct torture_context *tctx,
+ struct winreg_QueryMultipleValues *r)
+{
+ torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
+ torture_assert_str_equal(tctx, r->in.values[0].name->name, "HOMEPATH",
+ "name");
+
+ torture_assert_int_equal(tctx, r->in.values[0].type, 0, "type");
+ torture_assert_int_equal(tctx, r->in.values[0].offset, 0, "offset");
+ torture_assert_int_equal(tctx, r->in.values[0].length, 0, "length");
+ torture_assert_int_equal(tctx, *r->in.buffer_size, 76, "buffer size");
+
+ return true;
+}
+
+static const uint8_t querymultiplevalues_out_data[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xd8, 0x8c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x38, 0x87, 0x07, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00,
+ 0x54, 0x00, 0x48, 0x00, 0xc8, 0x95, 0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x4d, 0x45, 0x4d, 0xc8, 0x95, 0x08, 0x00,
+ 0x50, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x07, 0x00,
+ 0x00, 0x01, 0x0c, 0x00, 0x50, 0x95, 0x08, 0x00, 0x48, 0x96, 0x08, 0x00,
+ 0xdc, 0x00, 0x00, 0x00, 0xc0, 0x83, 0x00, 0x01, 0x0d, 0xf0, 0xff, 0xff,
+ 0x4c, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
+};
+
+static bool querymultiplevalues_out_check(struct torture_context *tctx,
+ struct winreg_QueryMultipleValues *r)
+{
+ torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH",
+ "name");
+
+ torture_assert_int_equal(tctx, r->out.values[0].type, 0, "type");
+ torture_assert_int_equal(tctx, r->out.values[0].offset, 0, "offset");
+ torture_assert_int_equal(tctx, r->out.values[0].length, 0, "length");
+ /* FIXME: r->out.buffer */
+ torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size");
+ torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA,
+ "return code");
+
+ return true;
+}
+
struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
{
struct torture_suite *suite = torture_suite_create(ctx, "winreg");
- torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, winreg_closekey_data, NDR_IN, winreg_closekey_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_IN, closekey_out_check );
+
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
+
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
+
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
+
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
+
+ /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_out_data, NDR_OUT, querymultiplevalues_out_check );*/
return suite;
}
+