s4:torture: make test_GetUserName() more strict
authorStefan Metzmacher <metze@samba.org>
Mon, 26 Nov 2018 10:06:44 +0000 (11:06 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 12 Jan 2019 02:13:31 +0000 (03:13 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/rpc/lsa.c

index 988d534..bc1e955 100644 (file)
@@ -4837,7 +4837,6 @@ static bool test_GetUserName(struct dcerpc_binding_handle *b,
                             struct torture_context *tctx)
 {
        struct lsa_GetUserName r;
-       bool ret = true;
        struct lsa_String *authority_name_p = NULL;
        struct lsa_String *account_name_p = NULL;
 
@@ -4850,11 +4849,11 @@ static bool test_GetUserName(struct dcerpc_binding_handle *b,
 
        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetUserName_r(b, tctx, &r),
                "GetUserName failed");
-
-       if (!NT_STATUS_IS_OK(r.out.result)) {
-               torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(r.out.result));
-               ret = false;
-       }
+       torture_assert_ntstatus_ok(tctx, r.out.result,
+               "GetUserName result failed");
+       torture_assert_not_null(tctx, r.out.account_name, "r.out.account_name");
+       torture_assert_not_null(tctx, *r.out.account_name, "*r.out.account_name");
+       torture_assert(tctx, r.out.authority_name == NULL, "r.out.authority_name");
 
        account_name_p = NULL;
        r.in.account_name       = &account_name_p;
@@ -4863,13 +4862,14 @@ static bool test_GetUserName(struct dcerpc_binding_handle *b,
 
        torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetUserName_r(b, tctx, &r),
                "GetUserName failed");
+       torture_assert_ntstatus_ok(tctx, r.out.result,
+               "GetUserName result failed");
+       torture_assert_not_null(tctx, r.out.account_name, "r.out.account_name");
+       torture_assert_not_null(tctx, *r.out.account_name, "*r.out.account_name");
+       torture_assert_not_null(tctx, r.out.authority_name, "r.out.authority_name");
+       torture_assert_not_null(tctx, *r.out.authority_name, "*r.out.authority_name");
 
-       if (!NT_STATUS_IS_OK(r.out.result)) {
-               torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(r.out.result));
-               ret = false;
-       }
-
-       return ret;
+       return true;
 }
 
 static bool test_GetUserName_fail(struct dcerpc_binding_handle *b,