LCOV - code coverage report
Current view: top level - source4/torture/rpc - browser.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 60 60 100.0 %
Date: 2021-09-23 10:06:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    test suite for browser rpc operations
       5             : 
       6             :    Copyright (C) Stefan Metzmacher 2008
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "librpc/gen_ndr/ndr_browser_c.h"
      24             : #include "torture/rpc/torture_rpc.h"
      25             : 
      26           3 : bool test_BrowserrQueryOtherDomains(struct torture_context *tctx,
      27             :                                     struct dcerpc_pipe *p)
      28             : {
      29           3 :         struct dcerpc_binding_handle *b = p->binding_handle;
      30             :         struct BrowserrQueryOtherDomains r;
      31             :         struct BrowserrSrvInfo info;
      32             :         struct BrowserrSrvInfo100Ctr ctr100;
      33             :         struct srvsvc_NetSrvInfo100 entries100[1];
      34             :         struct BrowserrSrvInfo101Ctr ctr101;
      35             :         struct srvsvc_NetSrvInfo101 entries101[1];
      36             :         uint32_t total_entries;
      37             :         NTSTATUS status;
      38             : 
      39           3 :         torture_comment(tctx, "dcerpc_BrowserrQueryOtherDomains\n");
      40             : 
      41           3 :         ZERO_STRUCT(r);
      42           3 :         ZERO_STRUCT(info);
      43           3 :         ZERO_STRUCT(ctr100);
      44           3 :         ZERO_STRUCT(entries100);
      45           3 :         ZERO_STRUCT(ctr101);
      46           3 :         ZERO_STRUCT(entries101);
      47           3 :         total_entries = 0;
      48             : 
      49           3 :         r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
      50           3 :         r.in.info = &info;
      51           3 :         r.out.info = &info;
      52           3 :         r.out.total_entries = &total_entries;
      53             : 
      54           3 :         info.level = 100;
      55           3 :         info.info.info100 = &ctr100;
      56             : 
      57           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      58           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      59           3 :         torture_assert_werr_ok(tctx, r.out.result, "BrowserrQueryOtherDomains failed");
      60           3 :         torture_assert_int_equal(tctx, *r.out.total_entries, 0, "BrowserrQueryOtherDomains");
      61             : 
      62           3 :         info.info.info100 = &ctr100;
      63           3 :         ctr100.entries_read = ARRAY_SIZE(entries100);
      64           3 :         ctr100.entries = entries100;
      65             : 
      66           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      67           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      68           3 :         torture_assert_werr_ok(tctx, r.out.result, "BrowserrQueryOtherDomains failed");
      69           3 :         torture_assert_int_equal(tctx, *r.out.total_entries, 0, "BrowserrQueryOtherDomains");
      70             : 
      71           3 :         info.info.info100 = NULL;
      72           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      73           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      74           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_PARAMETER, r.out.result,
      75             :                                   "BrowserrQueryOtherDomains failed");
      76             : 
      77           3 :         info.level = 101;
      78           3 :         info.info.info101 = &ctr101;
      79             : 
      80           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      81           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      82           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_LEVEL, r.out.result,
      83             :                                   "BrowserrQueryOtherDomains");
      84             : 
      85           3 :         info.info.info101 = &ctr101;
      86           3 :         ctr101.entries_read = ARRAY_SIZE(entries101);
      87           3 :         ctr101.entries = entries101;
      88             : 
      89           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      90           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      91           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_LEVEL, r.out.result,
      92             :                                   "BrowserrQueryOtherDomains");
      93             : 
      94           3 :         info.info.info101 = NULL;
      95           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
      96           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
      97           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_LEVEL, r.out.result,
      98             :                                   "BrowserrQueryOtherDomains");
      99             : 
     100           3 :         info.level = 102;
     101           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
     102           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
     103           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_LEVEL, r.out.result,
     104             :                                   "BrowserrQueryOtherDomains");
     105             : 
     106           3 :         info.level = 0;
     107           3 :         status = dcerpc_BrowserrQueryOtherDomains_r(b, tctx, &r);
     108           3 :         torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
     109           3 :         torture_assert_werr_equal(tctx, WERR_INVALID_LEVEL, r.out.result,
     110             :                                   "BrowserrQueryOtherDomains");
     111             : 
     112           3 :         return true;
     113             : }
     114             : 
     115        2355 : struct torture_suite *torture_rpc_browser(TALLOC_CTX *mem_ctx)
     116             : {
     117        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "browser");
     118        2355 :         struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, "browser", &ndr_table_browser);
     119             : 
     120        2355 :         torture_rpc_tcase_add_test(tcase, "BrowserrQueryOtherDomains", test_BrowserrQueryOtherDomains);
     121             : 
     122        2355 :         return suite;
     123             : }
     124             : 

Generated by: LCOV version 1.13