LCOV - code coverage report
Current view: top level - source4/torture/rpc - oxidresolve.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 10 113 8.8 %
Date: 2021-09-23 10:06:22 Functions: 1 8 12.5 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for oxidresolve operations
       4             : 
       5             :    Copyright (C) Jelmer Vernooij 2004
       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 "librpc/gen_ndr/ndr_oxidresolver_c.h"
      23             : #include "librpc/gen_ndr/ndr_remact_c.h"
      24             : #include "librpc/gen_ndr/epmapper.h"
      25             : #include "torture/rpc/torture_rpc.h"
      26             : 
      27             : #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
      28             : 
      29             : const struct GUID IUnknown_uuid = {
      30             :         0x00000000,0x0000,0x0000,{0xc0,0x00},{0x00,0x00,0x00,0x00,0x00,0x46}
      31             : };
      32             : 
      33           0 : static bool test_RemoteActivation(struct torture_context *tctx,
      34             :                                  uint64_t *oxid, struct GUID *oid)
      35             : {
      36             :         struct RemoteActivation r;
      37             :         NTSTATUS status;
      38             :         struct GUID iids[2];
      39           0 :         uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
      40             :         struct dcerpc_pipe *p;
      41             :         struct dcerpc_binding_handle *b;
      42             :         struct ORPCTHAT that;
      43             :         struct DUALSTRINGARRAY *pdsaOxidBindings;
      44             :         uint32_t AuthnHint;
      45             :         struct COMVERSION ServerVersion;
      46             :         HRESULT hr;
      47             :         struct MInterfacePointer *ifaces;
      48             : 
      49           0 :         status = torture_rpc_connection(tctx, &p,
      50             :                                         &ndr_table_IRemoteActivation);
      51             : 
      52           0 :         if (!NT_STATUS_IS_OK(status)) {
      53           0 :                 return false;
      54             :         }
      55           0 :         b = p->binding_handle;
      56             : 
      57           0 :         ZERO_STRUCT(r);
      58             : 
      59           0 :         r.in.this_object.version.MajorVersion = 5;
      60           0 :         r.in.this_object.version.MinorVersion = 1;
      61           0 :         r.in.this_object.cid = GUID_random();
      62           0 :         GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
      63           0 :         r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
      64           0 :         r.in.num_protseqs = 3;
      65           0 :         r.in.protseq = protseq;
      66           0 :         r.in.Interfaces = 1;
      67           0 :         iids[0] = IUnknown_uuid;
      68           0 :         r.in.pIIDs = iids;
      69             : 
      70           0 :         r.out.that = &that;
      71           0 :         r.out.pOxid = oxid;
      72           0 :         r.out.pdsaOxidBindings = &pdsaOxidBindings;
      73           0 :         r.out.ipidRemUnknown = oid;
      74           0 :         r.out.AuthnHint = &AuthnHint;
      75           0 :         r.out.ServerVersion = &ServerVersion;
      76           0 :         r.out.hr = &hr;
      77           0 :         r.out.ifaces = &ifaces;
      78             : 
      79           0 :         status = dcerpc_RemoteActivation_r(b, tctx, &r);
      80           0 :         torture_assert_ntstatus_ok(tctx, status, "RemoteActivation failed");
      81           0 :         torture_assert_werr_ok(tctx, r.out.result, "RemoteActivation failed");
      82           0 :         torture_assert_hresult_ok(tctx, *r.out.hr, "RemoteActivation failed");
      83           0 :         torture_assert_hresult_ok(tctx, r.out.results[0], "RemoteActivation failed");
      84             : 
      85           0 :         return true;
      86             : }
      87             : 
      88           0 : static bool test_SimplePing(struct torture_context *tctx,
      89             :                            struct dcerpc_pipe *p)
      90             : {
      91             :         struct SimplePing r;
      92             :         NTSTATUS status;
      93             :         uint64_t setid;
      94           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
      95             : 
      96           0 :         r.in.SetId = &setid;
      97             : 
      98           0 :         status = dcerpc_SimplePing_r(b, tctx, &r);
      99           0 :         torture_assert_ntstatus_ok(tctx, status, "SimplePing");
     100           0 :         torture_assert_werr_ok(tctx, r.out.result, "SimplePing");
     101             : 
     102           0 :         return true;
     103             : }
     104             : 
     105           0 : static bool test_ComplexPing(struct torture_context *tctx,
     106             :                              struct dcerpc_pipe *p)
     107             : {
     108             :         struct ComplexPing r;
     109             :         NTSTATUS status;
     110             :         uint64_t setid;
     111             :         struct GUID oid;
     112             :         uint64_t oxid;
     113           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     114             : 
     115           0 :         if (!test_RemoteActivation(tctx, &oxid, &oid))
     116           0 :                 return false;
     117             : 
     118           0 :         setid = 0;
     119           0 :         ZERO_STRUCT(r.in);
     120             : 
     121           0 :         r.in.SequenceNum = 0;
     122           0 :         r.in.SetId = &setid;
     123           0 :         r.in.cAddToSet = 1;
     124           0 :         r.in.AddToSet = &oid;
     125             : 
     126           0 :         status = dcerpc_ComplexPing_r(b, tctx, &r);
     127           0 :         if(NT_STATUS_IS_ERR(status)) {
     128           0 :                 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
     129           0 :                 return 0;
     130             :         }
     131             : 
     132           0 :         if(!W_ERROR_IS_OK(r.out.result)) {
     133           0 :                 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
     134           0 :                 return 0;
     135             :         }
     136             : 
     137             : 
     138             : 
     139           0 :         return 1;
     140             : }
     141             : 
     142           0 : static bool test_ServerAlive(struct torture_context *tctx,
     143             :                             struct dcerpc_pipe *p)
     144             : {
     145             :         struct ServerAlive r;
     146             :         NTSTATUS status;
     147           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     148             : 
     149           0 :         status = dcerpc_ServerAlive_r(b, tctx, &r);
     150           0 :         torture_assert_ntstatus_ok(tctx, status, "ServerAlive");
     151           0 :         torture_assert_werr_ok(tctx, r.out.result, "ServerAlive");
     152             : 
     153           0 :         return true;
     154             : }
     155             : 
     156           0 : static bool test_ResolveOxid(struct torture_context *tctx,
     157             :                              struct dcerpc_pipe *p)
     158             : {
     159             :         struct ResolveOxid r;
     160             :         NTSTATUS status;
     161           0 :         uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
     162             :         uint64_t oxid;
     163             :         struct GUID oid;
     164           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     165             :         struct DUALSTRINGARRAY *ppdsaOxidBindings;
     166             :         struct GUID pipidRemUnknown;
     167             :         uint32_t pAuthnHint;
     168             : 
     169           0 :         if (!test_RemoteActivation(tctx, &oxid, &oid))
     170           0 :                 return false;
     171             : 
     172           0 :         r.in.pOxid = oxid;
     173           0 :         r.in.cRequestedProtseqs = 2;
     174           0 :         r.in.arRequestedProtseqs = protseq;
     175           0 :         r.out.ppdsaOxidBindings = &ppdsaOxidBindings;
     176           0 :         r.out.pipidRemUnknown = &pipidRemUnknown;
     177           0 :         r.out.pAuthnHint = &pAuthnHint;
     178             : 
     179           0 :         status = dcerpc_ResolveOxid_r(b, tctx, &r);
     180           0 :         torture_assert_ntstatus_ok(tctx, status, "ResolveOxid");
     181           0 :         torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid");
     182             : 
     183           0 :         return true;
     184             : }
     185             : 
     186           0 : static bool test_ResolveOxid2(struct torture_context *tctx,
     187             :                               struct dcerpc_pipe *p)
     188             : {
     189             :         struct ResolveOxid2 r;
     190             :         NTSTATUS status;
     191           0 :         uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
     192             :         uint64_t oxid;
     193             :         struct GUID oid;
     194           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     195             :         struct DUALSTRINGARRAY *pdsaOxidBindings;
     196             :         struct GUID ipidRemUnknown;
     197             :         uint32_t AuthnHint;
     198             :         struct COMVERSION ComVersion;
     199             : 
     200           0 :         if (!test_RemoteActivation(tctx, &oxid, &oid))
     201           0 :                 return false;
     202             : 
     203           0 :         r.in.pOxid = oxid;
     204           0 :         r.in.cRequestedProtseqs = 2;
     205           0 :         r.in.arRequestedProtseqs = protseq;
     206           0 :         r.out.pdsaOxidBindings = &pdsaOxidBindings;
     207           0 :         r.out.ipidRemUnknown = &ipidRemUnknown;
     208           0 :         r.out.AuthnHint = &AuthnHint;
     209           0 :         r.out.ComVersion = &ComVersion;
     210             : 
     211           0 :         status = dcerpc_ResolveOxid2_r(b, tctx, &r);
     212           0 :         torture_assert_ntstatus_ok(tctx, status, "ResolveOxid2");
     213             : 
     214           0 :         torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid2");
     215             : 
     216           0 :         torture_comment(tctx, "Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion);
     217             : 
     218           0 :         return true;
     219             : }
     220             : 
     221           0 : static bool test_ServerAlive2(struct torture_context *tctx,
     222             :                              struct dcerpc_pipe *p)
     223             : {
     224             :         struct ServerAlive2 r;
     225             :         NTSTATUS status;
     226           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     227             :         struct COMINFO info;
     228             :         struct DUALSTRINGARRAY *dualstring;
     229             :         uint8_t pReserved;
     230             : 
     231           0 :         r.out.info = &info;
     232           0 :         r.out.dualstring = &dualstring;
     233           0 :         r.out.pReserved = &pReserved;
     234             : 
     235           0 :         status = dcerpc_ServerAlive2_r(b, tctx, &r);
     236           0 :         torture_assert_ntstatus_ok(tctx, status, "ServerAlive2");
     237           0 :         torture_assert_werr_ok(tctx, r.out.result, "ServerAlive2");
     238             : 
     239           0 :         return true;
     240             : }
     241             : 
     242        2355 : struct torture_suite *torture_rpc_oxidresolve(TALLOC_CTX *mem_ctx)
     243             : {
     244        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "oxidresolve");
     245             :         struct torture_rpc_tcase *tcase;
     246             : 
     247        2355 :         tcase = torture_suite_add_rpc_iface_tcase(suite, "oxidresolver",
     248             :                                           &ndr_table_IOXIDResolver);
     249             : 
     250        2355 :         torture_rpc_tcase_add_test(tcase, "ServerAlive", test_ServerAlive);
     251             : 
     252        2355 :         torture_rpc_tcase_add_test(tcase, "ServerAlive2", test_ServerAlive2);
     253             : 
     254        2355 :         torture_rpc_tcase_add_test(tcase, "ComplexPing", test_ComplexPing);
     255             : 
     256        2355 :         torture_rpc_tcase_add_test(tcase, "SimplePing", test_SimplePing);
     257             : 
     258        2355 :         torture_rpc_tcase_add_test(tcase, "ResolveOxid", test_ResolveOxid);
     259             : 
     260        2355 :         torture_rpc_tcase_add_test(tcase, "ResolveOxid2", test_ResolveOxid2);
     261             : 
     262        2355 :         return suite;
     263             : }

Generated by: LCOV version 1.13