s4-test: Use ldb_msg_diff_ex() in torture/rpc/dssync.c test
[kamenim/samba.git] / source4 / torture / rpc / dssync.c
index 793ab14dbf044cf902225fccfb255475576aaf11..2efb9e7bb1511d793b11a0452fb535ac00b7ea8d 100644 (file)
@@ -30,8 +30,7 @@
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
 #include "dsdb/samdb/samdb.h"
-#include "lib/ldb_wrap.h"
-#include "torture/rpc/rpc.h"
+#include "torture/rpc/torture_rpc.h"
 #include "torture/drs/proto.h"
 #include "lib/tsocket/tsocket.h"
 #include "libcli/resolve/resolve.h"
@@ -209,9 +208,6 @@ static bool _test_DsBind(struct torture_context *tctx,
        status = dcerpc_drsuapi_DsBind_r(b->drs_handle, ctx, &b->req);
        if (!NT_STATUS_IS_OK(status)) {
                const char *errstr = nt_errstr(status);
-               if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-                       errstr = dcerpc_errstr(ctx, b->drs_pipe->last_fault_code);
-               }
                printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
                ret = false;
        } else if (!W_ERROR_IS_OK(b->req.out.result)) {
@@ -349,9 +345,6 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
        status = dcerpc_drsuapi_DsCrackNames_r(ctx->admin.drsuapi.drs_handle, ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
                const char *errstr = nt_errstr(status);
-               if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-                       errstr = dcerpc_errstr(ctx, ctx->admin.drsuapi.drs_pipe->last_fault_code);
-               }
                printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
                return false;
        } else if (!W_ERROR_IS_OK(r.out.result)) {
@@ -367,7 +360,7 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
        search.in.acct_control = -1;
        search.in.version               = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
        search.in.map_response = true;
-       status = cldap_netlogon(cldap, lp_iconv_convenience(tctx->lp_ctx), ctx, &search);
+       status = cldap_netlogon(cldap, ctx, &search);
        if (!NT_STATUS_IS_OK(status)) {
                const char *errstr = nt_errstr(status);
                ctx->site_name = talloc_asprintf(ctx, "%s", "Default-First-Site-Name");
@@ -413,7 +406,7 @@ static bool test_analyse_objects(struct torture_context *tctx,
                struct ldb_result *a_res;
                struct ldb_result *c_res;
                struct ldb_dn *schema_dn = ldb_get_schema_basedn(ldb);
-               ldap_schema = dsdb_new_schema(ctx, lp_iconv_convenience(tctx->lp_ctx));
+               ldap_schema = dsdb_new_schema(ctx);
                if (!ldap_schema) {
                        return false;
                }
@@ -582,8 +575,9 @@ static bool test_analyse_objects(struct torture_context *tctx,
                }
                
                
-               new_msg = ldb_msg_diff(ldb, drs_msg, ldap_msg);
-               talloc_steal(search_req, new_msg);
+               ret = ldb_msg_diff_ex(ldb, drs_msg, ldap_msg,
+                                     (TALLOC_CTX*)search_req, &new_msg);
+               torture_assert(tctx, ret == LDB_SUCCESS, "ldb_msg_diff_ex() has failed");
                if (new_msg->num_elements != 0) {
                        char *s;
                        struct ldb_ldif ldif;
@@ -592,7 +586,9 @@ static bool test_analyse_objects(struct torture_context *tctx,
                        s = ldb_ldif_write_string(ldb, new_msg, &ldif);
                        s = talloc_asprintf(tctx, "\n# Difference in between DRS and LDAP objects: \n%s\n", s);
 
-                       ldif.msg = ldb_msg_diff(ldb, ldap_msg, drs_msg);
+                       ret = ldb_msg_diff_ex(ldb, ldap_msg, drs_msg,
+                                             (TALLOC_CTX*)search_req, &ldif.msg);
+                       torture_assert(tctx, ret == LDB_SUCCESS, "ldb_msg_diff_ex() has failed");
                        s = talloc_asprintf_append(s,
                                                   "\n# Difference in between LDAP and DRS objects: \n%s\n",
                                                   ldb_ldif_write_string(ldb, new_msg, &ldif));
@@ -733,8 +729,7 @@ static bool test_analyse_objects(struct torture_context *tctx,
                                if (pull_fn) {
                                        /* Can't use '_all' because of PIDL bugs with relative pointers */
                                        ndr_err = ndr_pull_struct_blob(&plain_data, ptr,
-                                                                      lp_iconv_convenience(tctx->lp_ctx), ptr,
-                                                                      pull_fn);
+                                                                      ptr, pull_fn);
                                        if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                                                ndr_print_debug(print_fn, name, ptr);
                                        } else {
@@ -1023,12 +1018,8 @@ static bool test_FetchNT4Data(struct torture_context *tctx,
                        torture_skip(tctx, "DsGetNT4ChangeLog not supported by target server");
                } else if (!NT_STATUS_IS_OK(status)) {
                        const char *errstr = nt_errstr(status);
-                       if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-                               struct dcerpc_pipe *p = ctx->new_dc.drsuapi.drs_pipe;
-                               if (p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) {
-                                       torture_skip(tctx, "DsGetNT4ChangeLog not supported by target server");
-                               }
-                               errstr = dcerpc_errstr(ctx, p->last_fault_code);
+                       if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) {
+                               torture_skip(tctx, "DsGetNT4ChangeLog not supported by target server");
                        }
                        torture_fail(tctx,
                                     talloc_asprintf(tctx, "dcerpc_drsuapi_DsGetNT4ChangeLog failed - %s\n",