torture/rpc-winreg: General fixes for a number of tests.
[samba.git] / source4 / torture / rpc / winreg.c
index 2ce1fa768cfb99c283a5851c1024673828c5b316..96b1fb21747229b814006aba8da0f239be12ae98 100644 (file)
 
 #define TEST_SID "S-1-5-21-1234567890-1234567890-1234567890-500"
 
-static void init_initshutdown_String(TALLOC_CTX *mem_ctx,
-                                    struct initshutdown_String *name,
-                                    const char *s)
+static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
 {
-       name->name = talloc(mem_ctx, struct initshutdown_String_sub);
-       name->name->name = s;
+       name->string = s;
 }
 
 static void init_winreg_String(struct winreg_String *name, const char *s)
@@ -155,8 +152,8 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p,
                                        SEC_ACE_FLAG_CONTAINER_INHERIT,
                                        NULL);
 
-       torture_assert_ntstatus_ok(tctx,
-               ndr_push_struct_blob(&sdblob, tctx, sd,
+       torture_assert_ndr_success(tctx,
+               ndr_push_struct_blob(&sdblob, tctx, NULL, sd,
                                     (ndr_push_flags_fn_t)ndr_push_security_descriptor),
                                     "Failed to push security_descriptor ?!\n");
 
@@ -220,8 +217,8 @@ static bool _test_GetKeySecurity(struct dcerpc_pipe *p,
 
        sd = talloc_zero(tctx, struct security_descriptor);
 
-       torture_assert_ntstatus_ok(tctx,
-               ndr_pull_struct_blob(&sdblob, tctx, sd,
+       torture_assert_ndr_success(tctx,
+               ndr_pull_struct_blob(&sdblob, tctx, NULL, sd,
                                     (ndr_pull_flags_fn_t)ndr_pull_security_descriptor),
                                     "pull_security_descriptor failed");
 
@@ -264,8 +261,8 @@ static bool _test_SetKeySecurity(struct dcerpc_pipe *p,
                NDR_PRINT_DEBUG(security_descriptor, sd);
        }
 
-       torture_assert_ntstatus_ok(tctx,
-               ndr_push_struct_blob(&sdblob, tctx, sd,
+       torture_assert_ndr_success(tctx,
+               ndr_push_struct_blob(&sdblob, tctx, NULL, sd,
                                     (ndr_push_flags_fn_t)ndr_push_security_descriptor),
                                     "push_security_descriptor failed");
 
@@ -1636,8 +1633,8 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx,
        uint16_t hostname = 0x0;
 
        r.in.hostname = &hostname;
-       r.in.message = talloc(tctx, struct initshutdown_String);
-       init_initshutdown_String(tctx, r.in.message, "spottyfood");
+       r.in.message = talloc(tctx, struct lsa_StringLarge);
+       init_lsa_StringLarge(r.in.message, "spottyfood");
        r.in.force_apps = 1;
        r.in.timeout = 30;
        r.in.reboot = 1;
@@ -1660,8 +1657,8 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx,
        uint16_t hostname = 0x0;
 
        r.in.hostname = &hostname;
-       r.in.message = talloc(tctx, struct initshutdown_String);
-       init_initshutdown_String(tctx, r.in.message, "spottyfood");
+       r.in.message = talloc(tctx, struct lsa_StringLarge);
+       init_lsa_StringLarge(r.in.message, "spottyfood");
        r.in.force_apps = 1;
        r.in.timeout = 30;
        r.in.reboot = 1;
@@ -1733,6 +1730,11 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
        test_Cleanup(p, tctx, &handle, TEST_KEY3);
        test_Cleanup(p, tctx, &handle, TEST_KEY_BASE);
 
+       if (!test_CreateKey(p, tctx, &handle, TEST_KEY_BASE, NULL)) {
+               torture_comment(tctx,
+                               "CreateKey (TEST_KEY_BASE) failed\n");
+       }
+
        if (!test_CreateKey(p, tctx, &handle, TEST_KEY1, NULL)) {
                torture_comment(tctx,
                                "CreateKey failed - not considering a failure\n");
@@ -1766,9 +1768,12 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
        }
 
        if (created && deleted &&
-           test_OpenKey(p, tctx, &handle, TEST_KEY1, &newhandle)) {
+           !_test_OpenKey(p, tctx, &handle, TEST_KEY1,
+                          SEC_FLAG_MAXIMUM_ALLOWED, &newhandle,
+                          WERR_BADFILE, NULL)) {
                torture_comment(tctx,
-                               "DeleteKey failed (OpenKey after Delete worked)\n");
+                               "DeleteKey failed (OpenKey after Delete "
+                               "did not return WERR_BADFILE)\n");
                ret = false;
        }
 
@@ -1791,7 +1796,7 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
                created4 = true;
        }
 
-       if (!created4 && !test_CloseKey(p, tctx, &newhandle)) {
+       if (created4 && !test_CloseKey(p, tctx, &newhandle)) {
                printf("CloseKey failed\n");
                ret = false;
        }
@@ -1806,7 +1811,7 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
        }
 
 
-       if (created && !test_DeleteKey(p, tctx, &handle, TEST_KEY2)) {
+       if (created2 && !test_DeleteKey(p, tctx, &handle, TEST_KEY2)) {
                printf("DeleteKey failed\n");
                ret = false;
        }
@@ -1844,10 +1849,10 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
                if(!test_key(p, tctx, &handle, MAX_DEPTH - 1)) {
                        ret = false;
                }
-       }
-
-       if (!test_key(p, tctx, &handle, 0)) {
-               ret = false;
+       } else {
+               if (!test_key(p, tctx, &handle, 0)) {
+                       ret = false;
+               }
        }
 
        test_Cleanup(p, tctx, &handle, TEST_KEY_BASE);