LCOV - code coverage report
Current view: top level - source4/torture/ndr - atsvc.c (source / functions) Hit Total Coverage
Test: coverage report for master 98b443d9 Lines: 58 65 89.2 %
Date: 2024-05-31 13:13:24 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for atsvc ndr operations
       4             : 
       5             :    Copyright (C) Jelmer Vernooij 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/ndr/ndr.h"
      23             : #include "librpc/gen_ndr/ndr_atsvc.h"
      24             : #include "torture/ndr/proto.h"
      25             : 
      26             : static const uint8_t jobenum_in_data[] = {
      27             :   0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      28             :   0x09, 0x00, 0x00, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x32, 0x00,
      29             :   0x4b, 0x00, 0x44, 0x00, 0x43, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
      30             :   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
      31             :   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      32             : };
      33             : 
      34           2 : static bool jobenum_in_check(struct torture_context *tctx, 
      35             :                                                          struct atsvc_JobEnum *r)
      36             : {
      37           2 :         torture_assert(tctx, r->in.servername != NULL, "servername ptr");
      38           2 :         torture_assert_str_equal(tctx, r->in.servername, "WIN2KDC1", "servername");
      39           2 :         torture_assert_int_equal(tctx, r->in.ctr->entries_read, 0, "ctr entries read");
      40           2 :         torture_assert(tctx, r->in.ctr->first_entry == NULL, "ctr entries first_entry");
      41           2 :         torture_assert_int_equal(tctx, r->in.preferred_max_len, -1, "preferred max len");
      42           2 :         torture_assert(tctx, r->in.resume_handle != NULL, "resume handle ptr");
      43           2 :         torture_assert_int_equal(tctx, *r->in.resume_handle, 0, "resume handle");
      44           0 :         return true;
      45             : }
      46             : 
      47             : static const uint8_t jobenum_out_data[] = {
      48             :   0x07, 0x00, 0x00, 0x00, 0x28, 0x14, 0x0a, 0x00, 0x07, 0x00, 0x00, 0x00,
      49             :   0x01, 0x00, 0x00, 0x00, 0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00,
      50             :   0x02, 0x13, 0x00, 0x00, 0x40, 0x18, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x00,
      51             :   0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00,
      52             :   0x30, 0x18, 0x0a, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xe4, 0x0a, 0x05,
      53             :   0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0x20, 0x18, 0x0a, 0x00,
      54             :   0x04, 0x00, 0x00, 0x00, 0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00,
      55             :   0x02, 0x13, 0x00, 0x00, 0x10, 0x18, 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00,
      56             :   0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00,
      57             :   0x00, 0x18, 0x0a, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc0, 0xe4, 0x0a, 0x05,
      58             :   0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0xf0, 0x17, 0x0a, 0x00,
      59             :   0x07, 0x00, 0x00, 0x00, 0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00,
      60             :   0x02, 0x13, 0x00, 0x00, 0xe0, 0x17, 0x0a, 0x00, 0x08, 0x00, 0x00, 0x00,
      61             :   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00,
      62             :   0x6f, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00,
      63             :   0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
      64             :   0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00,
      65             :   0x65, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      66             :   0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x2e, 0x00,
      67             :   0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
      68             :   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00,
      69             :   0x6f, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00,
      70             :   0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
      71             :   0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00,
      72             :   0x65, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      73             :   0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x2e, 0x00,
      74             :   0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
      75             :   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00,
      76             :   0x6f, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00,
      77             :   0x07, 0x00, 0x00, 0x00, 0xac, 0x34, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
      78             :   0x00, 0x00, 0x00, 0x00
      79             : };
      80             : 
      81           2 : static bool jobenum_out_check(struct torture_context *tctx, 
      82             :                                                          struct atsvc_JobEnum *r)
      83             : {
      84           2 :         torture_assert_int_equal(tctx, r->out.ctr->entries_read, 7, "entries read");
      85           2 :         torture_assert(tctx, r->out.ctr->first_entry != NULL, "first entry");
      86           2 :         torture_assert_int_equal(tctx, r->out.ctr->first_entry[0].job_id, 1, "job id");
      87           2 :         torture_assert_int_equal(tctx, r->out.ctr->first_entry[0].job_time, 84600000, "job time");
      88           2 :         torture_assert_int_equal(tctx, r->out.ctr->first_entry[0].days_of_week, 0x2, "days of week");
      89           2 :         torture_assert_int_equal(tctx, r->out.ctr->first_entry[0].flags, 0x13, "flags");
      90           2 :         torture_assert_str_equal(tctx, r->out.ctr->first_entry[0].command, "foo.exe", "command");
      91           2 :         torture_assert(tctx, r->out.total_entries != NULL, "total entries ptr");
      92           2 :         torture_assert_int_equal(tctx, *r->out.total_entries, 7, "total entries");
      93           2 :         torture_assert(tctx, r->out.resume_handle, "resume handle ptr");
      94           2 :         torture_assert_int_equal(tctx, *r->out.resume_handle, 0, "resume handle");
      95           2 :         torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
      96             : 
      97           0 :         return true;
      98             : }
      99             : 
     100             : static const uint8_t jobadd_in_data[] = {
     101             :   0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     102             :   0x09, 0x00, 0x00, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x32, 0x00,
     103             :   0x4b, 0x00, 0x44, 0x00, 0x43, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
     104             :   0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x00, 0x00,
     105             :   0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     106             :   0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x2e, 0x00,
     107             :   0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00
     108             : };
     109             : 
     110           2 : static bool jobadd_in_check(struct torture_context *tctx, 
     111             :                                                          struct atsvc_JobAdd *r)
     112             : {
     113           2 :         torture_assert_str_equal(tctx, r->in.servername, "WIN2KDC1", "servername");
     114           2 :         torture_assert_int_equal(tctx, r->in.job_info->job_time, 84600000, "time");
     115           2 :         torture_assert_int_equal(tctx, r->in.job_info->days_of_month, 0, "days of month");
     116           2 :         torture_assert_int_equal(tctx, r->in.job_info->days_of_week, 0x2, "days of week");
     117           2 :         torture_assert_int_equal(tctx, r->in.job_info->flags, 17, "flags");
     118           2 :         torture_assert_str_equal(tctx, r->in.job_info->command, "foo.exe", "command");
     119             : 
     120           0 :         return true;
     121             : }
     122             : 
     123             : static const uint8_t jobadd_out_data[] = {
     124             :   0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     125             : };
     126             : 
     127           2 : static bool jobadd_out_check(struct torture_context *tctx, 
     128             :                                                          struct atsvc_JobAdd *r)
     129             : {
     130           2 :         torture_assert_int_equal(tctx, *r->out.job_id, 14, "job id");
     131           2 :         torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
     132           0 :         return true;
     133             : }
     134             : 
     135             : static const uint8_t jobdel_in_data[] = {
     136             :   0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     137             :   0x09, 0x00, 0x00, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x32, 0x00,
     138             :   0x4b, 0x00, 0x44, 0x00, 0x43, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
     139             :   0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00
     140             : };
     141             : 
     142           2 : static bool jobdel_in_check(struct torture_context *tctx, 
     143             :                                                          struct atsvc_JobDel *r)
     144             : {
     145           2 :         torture_assert_str_equal(tctx, r->in.servername, "WIN2KDC1", "servername");
     146           2 :         torture_assert_int_equal(tctx, r->in.min_job_id, 14, "min job id");
     147           2 :         torture_assert_int_equal(tctx, r->in.max_job_id, 14, "max job id");
     148           0 :         return true;
     149             : }
     150             : 
     151             : static const uint8_t jobdel_out_data[] = {
     152             :   0xde, 0x0e, 0x00, 0x00
     153             : };
     154             : 
     155           2 : static bool jobdel_out_check(struct torture_context *tctx, 
     156             :                                                          struct atsvc_JobDel *r)
     157             : {
     158             :         /* FIXME: Check for unknown code 0x00000ede */
     159           2 :         return true;
     160             : }
     161             : 
     162             : static const uint8_t jobgetinfo_in_data[] = {
     163             :   0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     164             :   0x09, 0x00, 0x00, 0x00, 0x57, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x32, 0x00,
     165             :   0x4b, 0x00, 0x44, 0x00, 0x43, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
     166             :   0x01, 0x00, 0x00, 0x00
     167             : };
     168             : 
     169           2 : static bool jobgetinfo_in_check(struct torture_context *tctx, 
     170             :                                                                 struct atsvc_JobGetInfo *r)
     171             : {
     172           2 :         torture_assert_str_equal(tctx, r->in.servername, "WIN2KDC1", "servername");
     173           2 :         torture_assert_int_equal(tctx, r->in.job_id, 1, "job id");
     174           0 :         return true;
     175             : }
     176             : 
     177             : static const uint8_t jobgetinfo_out_data[] = {
     178             :   0x88, 0xe2, 0x09, 0x00, 0xc0, 0xe4, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00,
     179             :   0x02, 0x13, 0x09, 0x00, 0x98, 0xe2, 0x09, 0x00, 0x08, 0x00, 0x00, 0x00,
     180             :   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, 0x00, 0x6f, 0x00,
     181             :   0x6f, 0x00, 0x2e, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00,
     182             :   0x00, 0x00, 0x00, 0x00
     183             : };
     184             : 
     185           2 : static bool jobgetinfo_out_check(struct torture_context *tctx, 
     186             :                                                                 struct atsvc_JobGetInfo *r)
     187             : {
     188           2 :         torture_assert(tctx, *r->out.job_info != NULL, "job info");
     189           2 :         torture_assert_int_equal(tctx, (*r->out.job_info)->job_time, 84600000, "time");
     190           2 :         torture_assert_int_equal(tctx, (*r->out.job_info)->days_of_month, 0, "days of month");
     191           2 :         torture_assert_int_equal(tctx, (*r->out.job_info)->days_of_week, 0x2, "days of week");
     192           2 :         torture_assert_int_equal(tctx, (*r->out.job_info)->flags, 0x13, "flags");
     193           2 :         torture_assert_str_equal(tctx, (*r->out.job_info)->command, "foo.exe", "command");
     194           0 :         return true;
     195             : }
     196             : 
     197        2338 : struct torture_suite *ndr_atsvc_suite(TALLOC_CTX *ctx)
     198             : {
     199        2338 :         struct torture_suite *suite = torture_suite_create(ctx, "atsvc");
     200             : 
     201        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobEnum, jobenum_in_data, NDR_IN, jobenum_in_check );
     202        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobEnum, jobenum_out_data, NDR_OUT, jobenum_out_check );
     203             : 
     204        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobAdd, jobadd_in_data, NDR_IN, jobadd_in_check );
     205        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobAdd, jobadd_out_data, NDR_OUT, jobadd_out_check );
     206             : 
     207        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobDel, jobdel_in_data, NDR_IN, jobdel_in_check );
     208        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobDel, jobdel_out_data, NDR_OUT, jobdel_out_check );
     209             : 
     210        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobGetInfo, jobgetinfo_in_data, NDR_IN, jobgetinfo_in_check );
     211        2338 :         torture_suite_add_ndr_pull_fn_test(suite, atsvc_JobGetInfo, jobgetinfo_out_data, NDR_OUT, jobgetinfo_out_check );
     212             : 
     213        2338 :         return suite;
     214             : }
     215             : 

Generated by: LCOV version 1.14