LCOV - code coverage report
Current view: top level - source4/torture/rap - rpc.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 29 35 82.9 %
Date: 2024-04-21 15:09:00 Functions: 2 2 100.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           4 : static bool test_rpc_netservergetinfo(struct torture_context *tctx,
      31             :                                       struct smbcli_state *cli)
      32             : {
      33           0 :         struct rap_WserverGetInfo r;
      34           0 :         struct dcerpc_pipe *p;
      35           0 :         struct dcerpc_binding_handle *b;
      36           0 :         struct srvsvc_NetSrvGetInfo s;
      37           0 :         union srvsvc_NetSrvInfo info;
      38             : 
      39           0 :         const char *server_name;
      40             : 
      41           4 :         torture_assert_ntstatus_ok(tctx,
      42             :                 torture_rpc_connection(tctx, &p, &ndr_table_srvsvc),
      43             :                 "failed to open srvsvc");
      44             : 
      45           4 :         b = p->binding_handle;
      46             : 
      47           4 :         s.in.server_unc = NULL;
      48           4 :         s.in.level = 101;
      49           4 :         s.out.info = &info;
      50             : 
      51           4 :         torture_assert_ntstatus_ok(tctx,
      52             :                 dcerpc_srvsvc_NetSrvGetInfo_r(b, tctx, &s),
      53             :                 "srvsvc_NetSrvGetInfo level 101 failed");
      54           4 :         torture_assert_werr_ok(tctx, s.out.result,
      55             :                 "srvsvc_NetSrvGetInfo level 101 failed");
      56             : 
      57           4 :         r.in.bufsize = 0xffff;
      58           4 :         r.in.level = 0;
      59             : 
      60           4 :         torture_assert_ntstatus_ok(tctx,
      61             :                 smbcli_rap_netservergetinfo(cli->tree, tctx, &r),
      62             :                 "rap_netservergetinfo level 0 failed");
      63           4 :         torture_assert_int_equal(tctx, r.out.status, 0,
      64             :                 "rap_netservergetinfo level 0 failed");
      65             : 
      66           4 :         server_name = talloc_strndup(tctx, info.info101->server_name, 16);
      67             : 
      68           4 :         torture_assert_str_equal(tctx, (const char *)r.out.info.info0.name, server_name, "server name");
      69             : 
      70           4 :         r.in.level = 1;
      71             : 
      72           4 :         torture_assert_ntstatus_ok(tctx,
      73             :                 smbcli_rap_netservergetinfo(cli->tree, tctx, &r),
      74             :                 "rap_netservergetinfo level 1 failed");
      75           4 :         torture_assert_int_equal(tctx, r.out.status, 0,
      76             :                 "rap_netservergetinfo level 1 failed");
      77             : 
      78           4 :         torture_assert_str_equal(tctx, (const char *)r.out.info.info1.name, server_name, "server name");
      79           4 :         torture_assert_int_equal(tctx, r.out.info.info1.version_major, info.info101->version_major, "version major");
      80           4 :         torture_assert_int_equal(tctx, r.out.info.info1.version_minor, info.info101->version_minor, "version minor");
      81           4 :         torture_assert_int_equal(tctx, r.out.info.info1.servertype, info.info101->server_type, "server_type");
      82           4 :         torture_assert_str_equal(tctx, r.out.info.info1.comment, info.info101->comment, "comment");
      83             : 
      84           4 :         talloc_free(p);
      85             : 
      86           4 :         return true;
      87             : }
      88             : 
      89        2354 : struct torture_suite *torture_rap_rpc(TALLOC_CTX *mem_ctx)
      90             : {
      91        2354 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "rpc");
      92             : 
      93        2354 :         torture_suite_add_1smb_test(suite, "netservergetinfo",
      94             :                                     test_rpc_netservergetinfo);
      95             : 
      96        2354 :         suite->description = talloc_strdup(suite,
      97             :                                            "RAP / DCERPC consistency tests");
      98             : 
      99        2354 :         return suite;
     100             : }

Generated by: LCOV version 1.14