r15626: Modify the tests to fit them in current changes in libnet
authorRafal Szczesniak <mimir@samba.org>
Mon, 15 May 2006 21:50:53 +0000 (21:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:07:24 +0000 (14:07 -0500)
functions.

rafal
(This used to be commit 849e3eee9476100d629be318610369662a114dd0)

source4/torture/libnet/domain.c
source4/torture/libnet/libnet_rpc.c
source4/torture/libnet/libnet_user.c

index 79902d1e7cc6af9e14c4d0645b8809bd18f07c05..c3e965f137b6a503a9fcbefd77ec53161e4415d6 100644 (file)
 
 #include "includes.h"
 #include "torture/rpc/rpc.h"
+#include "lib/events/events.h"
 #include "libnet/libnet.h"
 #include "librpc/gen_ndr/ndr_samr_c.h"
 
-static BOOL test_domainopen(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx,
                            struct lsa_String *domname,
                            struct policy_handle *domain_handle)
 {
        NTSTATUS status;
-       struct libnet_rpc_domain_open io;
+       struct libnet_DomainOpen io;
        
        printf("opening domain\n");
        
        io.in.domain_name  = talloc_strdup(mem_ctx, domname->string);
        io.in.access_mask  = SEC_FLAG_MAXIMUM_ALLOWED;
 
-       status = libnet_rpc_domain_open(p, mem_ctx, &io);
+       status = libnet_DomainOpen(net_ctx, mem_ctx, &io);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Composite domain open failed - %s\n", nt_errstr(status));
                return False;
@@ -73,7 +74,8 @@ BOOL torture_domainopen(struct torture_context *torture)
 {
        NTSTATUS status;
        const char *binding;
-       struct dcerpc_pipe *p;
+       struct libnet_context *net_ctx;
+       struct event_context *evt_ctx;
        TALLOC_CTX *mem_ctx;
        BOOL ret = True;
        struct policy_handle h;
@@ -82,8 +84,11 @@ BOOL torture_domainopen(struct torture_context *torture)
        mem_ctx = talloc_init("test_domain_open");
        binding = lp_parm_string(-1, "torture", "binding");
 
+       evt_ctx = event_context_find(torture);
+       net_ctx = libnet_context_init(evt_ctx);
+
        status = torture_rpc_connection(mem_ctx, 
-                                       &p,
+                                       &net_ctx->samr_pipe,
                                        &dcerpc_table_samr);
        
        if (!NT_STATUS_IS_OK(status)) {
@@ -95,12 +100,12 @@ BOOL torture_domainopen(struct torture_context *torture)
        /*
         * Testing synchronous version
         */
-       if (!test_domainopen(p, mem_ctx, &name, &h)) {
+       if (!test_domainopen(net_ctx, mem_ctx, &name, &h)) {
                ret = False;
                goto done;
        }
 
-       if (!test_cleanup(p, mem_ctx, &h)) {
+       if (!test_cleanup(net_ctx->samr_pipe, mem_ctx, &h)) {
                ret = False;
                goto done;
        }
index b7d94813a631fee04d68fdbf9c33e37e51ed69fa..39023886adeba3d14cd309317f4c57b3aa681f48 100644 (file)
@@ -101,6 +101,36 @@ static BOOL test_samr_connect(struct libnet_context *ctx)
        return True;
 }
 
+
+static BOOL test_samr_dcinfo_connect(struct libnet_context *ctx)
+{
+       NTSTATUS status;
+       struct libnet_RpcConnect connect;
+       connect.level           = LIBNET_RPC_CONNECT_DC_INFO;
+       connect.in.binding      = lp_parm_string(-1, "torture", "binding");
+       connect.in.dcerpc_iface = &dcerpc_table_samr;
+       
+       status = libnet_RpcConnect(ctx, ctx, &connect);
+       
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("Couldn't connect to rpc service %s on %s: %s\n",
+                      connect.in.dcerpc_iface->name, connect.in.binding,
+                      nt_errstr(status));
+
+               return False;
+       }
+
+       printf("Domain Controller Info:\n");
+       printf("\tDomain Name:\t %s\n", connect.out.domain_name);
+       printf("\tDomain SID:\t %s\n", dom_sid_string(ctx, connect.out.domain_sid));
+       printf("\tRealm:\t\t %s\n", connect.out.realm);
+       printf("\tGUID:\t\t %s\n", GUID_string(ctx, connect.out.guid));
+
+       return True;
+}
+
+
+
 BOOL torture_rpc_connect(struct torture_context *torture)
 {
        struct libnet_context *ctx;
@@ -108,21 +138,27 @@ BOOL torture_rpc_connect(struct torture_context *torture)
        ctx = libnet_context_init(NULL);
        ctx->cred = cmdline_credentials;
 
-       printf("Testing connection to lsarpc interface\n");
+       printf("Testing connection to LSA interface\n");
        if (!test_lsa_connect(ctx)) {
-               printf("failed to connect lsarpc interface\n");
+               printf("failed to connect LSA interface\n");
                return False;
        }
 
-       printf("Testing connection with domain info to lsarpc interface\n");
+       printf("Testing connection with domain info to LSA interface\n");
        if (!test_lsa_dcinfo_connect(ctx)) {
-               printf("failed to connect lsarpc interface\n");
+               printf("failed to connect LSA interface\n");
                return False;
        }
 
        printf("Testing connection to SAMR service\n");
        if (!test_samr_connect(ctx)) {
-               printf("failed to connect samr interface\n");
+               printf("failed to connect SAMR interface\n");
+               return False;
+       }
+
+       printf("Testing connection with domain info to SAMR interface\n");
+       if (!test_samr_dcinfo_connect(ctx)) {
+               printf("failed to connect SAMR interface\n");
                return False;
        }
 
index f577f352d6862f74a260ce7c6a3bfc2ce2e19ab1..8eadc8da9f3d0a180475bff4b99232cd17aec37a 100644 (file)
@@ -117,7 +117,7 @@ BOOL torture_createuser(struct torture_context *torture)
                return False;
        }
 
-       if (!test_cleanup(ctx->pipe, mem_ctx, &ctx->domain_handle, TEST_USERNAME)) {
+       if (!test_cleanup(ctx->samr_pipe, mem_ctx, &ctx->domain.handle, TEST_USERNAME)) {
                printf("cleanup failed\n");
                return False;
        }