LCOV - code coverage report
Current view: top level - source4/torture/libnet - groupman.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 23 40 57.5 %
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 libnet calls.
       4             : 
       5             :    Copyright (C) Rafal Szczesniak 2007
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "torture/rpc/torture_rpc.h"
      23             : #include "torture/libnet/grouptest.h"
      24             : #include "libnet/libnet.h"
      25             : #include "librpc/gen_ndr/ndr_samr_c.h"
      26             : #include "param/param.h"
      27             : #include "torture/libnet/proto.h"
      28             : 
      29             : 
      30           1 : static bool test_groupadd(struct torture_context *tctx,
      31             :                           struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
      32             :                           struct policy_handle *domain_handle,
      33             :                           const char *name)
      34             : {
      35           0 :         NTSTATUS status;
      36           1 :         bool ret = true;
      37           0 :         struct libnet_rpc_groupadd group;
      38             : 
      39           1 :         ZERO_STRUCT(group);
      40             : 
      41           1 :         group.in.domain_handle = *domain_handle;
      42           1 :         group.in.groupname     = name;
      43             : 
      44           1 :         printf("Testing libnet_rpc_groupadd\n");
      45             : 
      46           1 :         status = libnet_rpc_groupadd(tctx->ev, p->binding_handle,
      47             :                                      mem_ctx, &group);
      48           1 :         if (!NT_STATUS_IS_OK(status)) {
      49           0 :                 printf("Failed to call sync libnet_rpc_groupadd - %s\n", nt_errstr(status));
      50           0 :                 return false;
      51             :         }
      52             : 
      53           1 :         return ret;
      54             : }
      55             : 
      56             : 
      57           1 : bool torture_groupadd(struct torture_context *torture)
      58             : {
      59           0 :         NTSTATUS status;
      60           0 :         struct dcerpc_pipe *p;
      61           0 :         struct policy_handle h;
      62           0 :         struct lsa_String domain_name;
      63           0 :         struct dom_sid2 sid;
      64           1 :         const char *name = TEST_GROUPNAME;
      65           0 :         TALLOC_CTX *mem_ctx;
      66           1 :         bool ret = true;
      67           0 :         struct dcerpc_binding_handle *b;
      68             : 
      69           1 :         mem_ctx = talloc_init("test_groupadd");
      70             : 
      71           1 :         status = torture_rpc_connection(torture,
      72             :                                         &p,
      73             :                                         &ndr_table_samr);
      74             : 
      75           1 :         torture_assert_ntstatus_ok(torture, status, "RPC connection");
      76           1 :         b = p->binding_handle;
      77             : 
      78           1 :         domain_name.string = lpcfg_workgroup(torture->lp_ctx);
      79           1 :         if (!test_domain_open(torture, b, &domain_name, mem_ctx, &h, &sid)) {
      80           0 :                 ret = false;
      81           0 :                 goto done;
      82             :         }
      83             : 
      84           1 :         if (!test_groupadd(torture, p, mem_ctx, &h, name)) {
      85           0 :                 ret = false;
      86           0 :                 goto done;
      87             :         }
      88             : 
      89           1 :         if (!test_group_cleanup(torture, b, mem_ctx, &h, name)) {
      90           0 :                 ret = false;
      91           0 :                 goto done;
      92             :         }
      93             : 
      94           1 : done:
      95           1 :         talloc_free(mem_ctx);
      96           1 :         return ret;
      97             : }

Generated by: LCOV version 1.14