LCOV - code coverage report
Current view: top level - source4/torture/rap - rpc.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 5 29 17.2 %
Date: 2024-06-13 04:01:37 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for RAP / DCERPC consistency
       4             :    Copyright (C) Guenther Deschner 2010
       5             : 
       6             :    This program is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU General Public License as published by
       8             :    the Free Software Foundation; either version 3 of the License, or
       9             :    (at your option) any later version.
      10             : 
      11             :    This program is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU General Public License
      17             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18             : */
      19             : 
      20             : #include "includes.h"
      21             : #include "libcli/libcli.h"
      22             : #include "torture/smbtorture.h"
      23             : #include "torture/util.h"
      24             : #include "libcli/rap/rap.h"
      25             : #include "torture/rap/proto.h"
      26             : #include "param/param.h"
      27             : #include "torture/rpc/torture_rpc.h"
      28             : #include "librpc/gen_ndr/ndr_srvsvc_c.h"
      29             : 
      30           0 : static bool test_rpc_netservergetinfo(struct torture_context *tctx,
      31             :                                       struct smbcli_state *cli)
      32             : {
      33             :         struct rap_WserverGetInfo r;
      34             :         struct dcerpc_pipe *p;
      35             :         struct dcerpc_binding_handle *b;
      36             :         struct srvsvc_NetSrvGetInfo s;
      37             :         union srvsvc_NetSrvInfo info;
      38             : 
      39             :         const char *server_name;
      40             : 
      41           0 :         torture_assert_ntstatus_ok(tctx,
      42             :                 torture_rpc_connection(tctx, &p, &ndr_table_srvsvc),
      43             :                 "failed to open srvsvc");
      44             : 
      45           0 :         b = p->binding_handle;
      46             : 
      47           0 :         s.in.server_unc = NULL;
      48           0 :         s.in.level = 101;
      49           0 :         s.out.info = &info;
      50             : 
      51           0 :         torture_assert_ntstatus_ok(tctx,
      52             :                 dcerpc_srvsvc_NetSrvGetInfo_r(b, tctx, &s),
      53             :                 "srvsvc_NetSrvGetInfo level 101 failed");
      54           0 :         torture_assert_werr_ok(tctx, s.out.result,
      55             :                 "srvsvc_NetSrvGetInfo level 101 failed");
      56             : 
      57           0 :         r.in.bufsize = 0xffff;
      58           0 :         r.in.level = 0;
      59             : 
      60           0 :         torture_assert_ntstatus_ok(tctx,
      61             :                 smbcli_rap_netservergetinfo(cli->tree, tctx, &r),
      62             :                 "rap_netservergetinfo level 0 failed");
      63           0 :         torture_assert_int_equal(tctx, r.out.status, 0,
      64             :                 "rap_netservergetinfo level 0 failed");
      65             : 
      66           0 :         server_name = talloc_strndup(tctx, info.info101->server_name, 16);
      67             : 
      68           0 :         torture_assert_str_equal(tctx, (const char *)r.out.info.info0.name, server_name, "server name");
      69             : 
      70           0 :         r.in.level = 1;
      71             : 
      72           0 :         torture_assert_ntstatus_ok(tctx,
      73             :                 smbcli_rap_netservergetinfo(cli->tree, tctx, &r),
      74             :                 "rap_netservergetinfo level 1 failed");
      75           0 :         torture_assert_int_equal(tctx, r.out.status, 0,
      76             :                 "rap_netservergetinfo level 1 failed");
      77             : 
      78           0 :         torture_assert_str_equal(tctx, (const char *)r.out.info.info1.name, server_name, "server name");
      79           0 :         torture_assert_int_equal(tctx, r.out.info.info1.version_major, info.info101->version_major, "version major");
      80           0 :         torture_assert_int_equal(tctx, r.out.info.info1.version_minor, info.info101->version_minor, "version minor");
      81           0 :         torture_assert_int_equal(tctx, r.out.info.info1.servertype, info.info101->server_type, "server_type");
      82           0 :         torture_assert_str_equal(tctx, r.out.info.info1.comment, info.info101->comment, "comment");
      83             : 
      84           0 :         talloc_free(p);
      85             : 
      86           0 :         return true;
      87             : }
      88             : 
      89         964 : struct torture_suite *torture_rap_rpc(TALLOC_CTX *mem_ctx)
      90             : {
      91         964 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "rpc");
      92             : 
      93         964 :         torture_suite_add_1smb_test(suite, "netservergetinfo",
      94             :                                     test_rpc_netservergetinfo);
      95             : 
      96         964 :         suite->description = talloc_strdup(suite,
      97             :                                            "RAP / DCERPC consistency tests");
      98             : 
      99         964 :         return suite;
     100             : }

Generated by: LCOV version 1.13