s4-smbtorture: extend netr_LogonControl test in RPC-NETLOGON.
authorGünther Deschner <gd@samba.org>
Wed, 14 Oct 2009 09:58:21 +0000 (11:58 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 16 Oct 2009 12:54:58 +0000 (14:54 +0200)
Guenther

source4/torture/rpc/netlogon.c

index 6a753ed41233679a257bb6b55a4cef99e11d63fc..f57c47b115404eb8297f52dd735a373bf8eb3122 100644 (file)
@@ -1567,6 +1567,49 @@ static bool test_GetDcName(struct torture_context *tctx,
        return true;
 }
 
+static const char *function_code_str(TALLOC_CTX *mem_ctx,
+                                    enum netr_LogonControlCode function_code)
+{
+       switch (function_code) {
+       case NETLOGON_CONTROL_QUERY:
+               return "NETLOGON_CONTROL_QUERY";
+       case NETLOGON_CONTROL_REPLICATE:
+               return "NETLOGON_CONTROL_REPLICATE";
+       case NETLOGON_CONTROL_SYNCHRONIZE:
+               return "NETLOGON_CONTROL_SYNCHRONIZE";
+       case NETLOGON_CONTROL_PDC_REPLICATE:
+               return "NETLOGON_CONTROL_PDC_REPLICATE";
+       case NETLOGON_CONTROL_REDISCOVER:
+               return "NETLOGON_CONTROL_REDISCOVER";
+       case NETLOGON_CONTROL_TC_QUERY:
+               return "NETLOGON_CONTROL_TC_QUERY";
+       case NETLOGON_CONTROL_TRANSPORT_NOTIFY:
+               return "NETLOGON_CONTROL_TRANSPORT_NOTIFY";
+       case NETLOGON_CONTROL_FIND_USER:
+               return "NETLOGON_CONTROL_FIND_USER";
+       case NETLOGON_CONTROL_CHANGE_PASSWORD:
+               return "NETLOGON_CONTROL_CHANGE_PASSWORD";
+       case NETLOGON_CONTROL_TC_VERIFY:
+               return "NETLOGON_CONTROL_TC_VERIFY";
+       case NETLOGON_CONTROL_FORCE_DNS_REG:
+               return "NETLOGON_CONTROL_FORCE_DNS_REG";
+       case NETLOGON_CONTROL_QUERY_DNS_REG:
+               return "NETLOGON_CONTROL_QUERY_DNS_REG";
+       case NETLOGON_CONTROL_BACKUP_CHANGE_LOG:
+               return "NETLOGON_CONTROL_BACKUP_CHANGE_LOG";
+       case NETLOGON_CONTROL_TRUNCATE_LOG:
+               return "NETLOGON_CONTROL_TRUNCATE_LOG";
+       case NETLOGON_CONTROL_SET_DBFLAG:
+               return "NETLOGON_CONTROL_SET_DBFLAG";
+       case NETLOGON_CONTROL_BREAKPOINT:
+               return "NETLOGON_CONTROL_BREAKPOINT";
+       default:
+               return talloc_asprintf(mem_ctx, "unknown function code: %d",
+                                      function_code);
+       }
+}
+
+
 /*
   try a netlogon LogonControl 
 */
@@ -1576,19 +1619,82 @@ static bool test_LogonControl(struct torture_context *tctx,
        NTSTATUS status;
        struct netr_LogonControl r;
        union netr_CONTROL_QUERY_INFORMATION query;
-       int i;
+       int i,f;
+       uint32_t function_codes[] = {
+               NETLOGON_CONTROL_QUERY,
+               NETLOGON_CONTROL_REPLICATE,
+               NETLOGON_CONTROL_SYNCHRONIZE,
+               NETLOGON_CONTROL_PDC_REPLICATE,
+               NETLOGON_CONTROL_REDISCOVER,
+               NETLOGON_CONTROL_TC_QUERY,
+               NETLOGON_CONTROL_TRANSPORT_NOTIFY,
+               NETLOGON_CONTROL_FIND_USER,
+               NETLOGON_CONTROL_CHANGE_PASSWORD,
+               NETLOGON_CONTROL_TC_VERIFY,
+               NETLOGON_CONTROL_FORCE_DNS_REG,
+               NETLOGON_CONTROL_QUERY_DNS_REG,
+               NETLOGON_CONTROL_BACKUP_CHANGE_LOG,
+               NETLOGON_CONTROL_TRUNCATE_LOG,
+               NETLOGON_CONTROL_SET_DBFLAG,
+               NETLOGON_CONTROL_BREAKPOINT
+       };
 
        r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
        r.in.function_code = 1;
        r.out.query = &query;
 
-       for (i=1;i<4;i++) {
+       for (f=0;f<ARRAY_SIZE(function_codes); f++) {
+       for (i=1;i<5;i++) {
+
+               r.in.function_code = function_codes[f];
                r.in.level = i;
 
-               torture_comment(tctx, "Testing LogonControl level %d\n", i);
+               torture_comment(tctx, "Testing LogonControl function code %s (%d) level %d\n",
+                               function_code_str(tctx, r.in.function_code), r.in.function_code, r.in.level);
 
                status = dcerpc_netr_LogonControl(p, tctx, &r);
                torture_assert_ntstatus_ok(tctx, status, "LogonControl");
+
+               switch (r.in.level) {
+               case 1:
+                       switch (r.in.function_code) {
+                       case NETLOGON_CONTROL_REPLICATE:
+                       case NETLOGON_CONTROL_SYNCHRONIZE:
+                       case NETLOGON_CONTROL_PDC_REPLICATE:
+                       case NETLOGON_CONTROL_BACKUP_CHANGE_LOG:
+                       case NETLOGON_CONTROL_TRUNCATE_LOG:
+                       case NETLOGON_CONTROL_BREAKPOINT:
+                               torture_assert_werr_equal(tctx, r.out.result, WERR_ACCESS_DENIED,
+                                       "LogonControl returned unexpected error code");
+                               break;
+                       case NETLOGON_CONTROL_REDISCOVER:
+                       case NETLOGON_CONTROL_TC_QUERY:
+                       case NETLOGON_CONTROL_TRANSPORT_NOTIFY:
+                       case NETLOGON_CONTROL_FIND_USER:
+                       case NETLOGON_CONTROL_CHANGE_PASSWORD:
+                       case NETLOGON_CONTROL_TC_VERIFY:
+                       case NETLOGON_CONTROL_FORCE_DNS_REG:
+                       case NETLOGON_CONTROL_QUERY_DNS_REG:
+                       case NETLOGON_CONTROL_SET_DBFLAG:
+                               torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
+                                       "LogonControl returned unexpected error code");
+                               break;
+                       default:
+                               torture_assert_werr_ok(tctx, r.out.result,
+                                       "LogonControl returned unexpected result");
+                               break;
+                       }
+                       break;
+               case 2:
+                       torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED,
+                               "LogonControl returned unexpected error code");
+                       break;
+               default:
+                       torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL,
+                               "LogonControl returned unexpected error code");
+                       break;
+               }
+       }
        }
 
        return true;