s4-smbtorture: fix RPC-LSA-LSALOOKUP test against w2k3 and w2k8.
authorGünther Deschner <gd@samba.org>
Tue, 20 Oct 2009 21:47:40 +0000 (23:47 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 20 Oct 2009 21:57:58 +0000 (23:57 +0200)
Make sure to split out lsa_LookupName NULL name test so that we can better track
results from bogus names and NULL names.

Guenther

source4/torture/rpc/lsa.c

index e4a6a8422c9f4f55e7473e63824d5807dc62b7e3..9cee4e2f0c9ec1528a3d9b2bb9cae7cd6546fbcc 100644 (file)
@@ -232,31 +232,19 @@ static bool test_LookupNames_bogus(struct dcerpc_pipe *p,
        struct lsa_LookupNames r;
        struct lsa_TransSidArray sids;
        struct lsa_RefDomainList *domains = NULL;
-       struct lsa_String *names;
+       struct lsa_String names[1];
        uint32_t count = 0;
        NTSTATUS status;
-       int i;
-
-       struct lsa_TranslatedName name[2];
-       struct lsa_TransNameArray tnames;
-
-       tnames.names = name;
-       tnames.count = 2;
-       name[0].name.string = "NT AUTHORITY\\BOGUS";
-       name[1].name.string = NULL;
 
-       torture_comment(tctx, "\nTesting LookupNames with bogus names\n");
+       torture_comment(tctx, "\nTesting LookupNames with bogus name\n");
 
        sids.count = 0;
        sids.sids = NULL;
 
-       names = talloc_array(tctx, struct lsa_String, tnames.count);
-       for (i=0;i<tnames.count;i++) {
-               init_lsa_String(&names[i], tnames.names[i].name.string);
-       }
+       init_lsa_String(&names[0], "NT AUTHORITY\\BOGUS");
 
        r.in.handle = handle;
-       r.in.num_names = tnames.count;
+       r.in.num_names = 1;
        r.in.names = names;
        r.in.sids = &sids;
        r.in.level = 1;
@@ -276,6 +264,48 @@ static bool test_LookupNames_bogus(struct dcerpc_pipe *p,
        return true;
 }
 
+static bool test_LookupNames_NULL(struct dcerpc_pipe *p,
+                                 struct torture_context *tctx,
+                                 struct policy_handle *handle)
+{
+       struct lsa_LookupNames r;
+       struct lsa_TransSidArray sids;
+       struct lsa_RefDomainList *domains = NULL;
+       struct lsa_String names[1];
+       uint32_t count = 0;
+
+       torture_comment(tctx, "\nTesting LookupNames with NULL name\n");
+
+       sids.count = 0;
+       sids.sids = NULL;
+
+       names[0].string = NULL;
+
+       r.in.handle = handle;
+       r.in.num_names = 1;
+       r.in.names = names;
+       r.in.sids = &sids;
+       r.in.level = 1;
+       r.in.count = &count;
+       r.out.count = &count;
+       r.out.sids = &sids;
+       r.out.domains = &domains;
+
+       /* nt4 returns NT_STATUS_NONE_MAPPED with sid_type
+        * SID_NAME_UNKNOWN, rid 0, and sid_index -1;
+        *
+        * w2k3/w2k8 return NT_STATUS_OK with sid_type
+        * SID_NAME_DOMAIN, rid -1 and sid_index 0 and BUILTIN domain
+        */
+
+       torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames(p, tctx, &r),
+               "LookupNames with NULL name failed");
+
+       torture_comment(tctx, "\n");
+
+       return true;
+}
+
 static bool test_LookupNames_wellknown(struct dcerpc_pipe *p,
                                       struct torture_context *tctx,
                                       struct policy_handle *handle)
@@ -2768,6 +2798,10 @@ static bool testcase_LookupNames(struct torture_context *tctx,
                ret = false;
        }
 
+       if (!test_LookupNames_NULL(p, tctx, handle)) {
+               ret = false;
+       }
+
        if (!test_LookupNames_bogus(p, tctx, handle)) {
                ret = false;
        }