LCOV - code coverage report
Current view: top level - source4/torture/rap - printing.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 14 288 4.9 %
Date: 2024-04-21 15:09:00 Functions: 1 25 4.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for SMB printing operations
       4             : 
       5             :    Copyright (C) Guenther Deschner 2010
       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 "libcli/raw/libcliraw.h"
      23             : #include "libcli/libcli.h"
      24             : #include "torture/torture.h"
      25             : #include "torture/util.h"
      26             : #include "system/filesys.h"
      27             : 
      28             : #include "torture/smbtorture.h"
      29             : #include "torture/util.h"
      30             : #include "libcli/rap/rap.h"
      31             : #include "torture/rap/proto.h"
      32             : #include "param/param.h"
      33             : 
      34             : /* TODO:
      35             : 
      36             :  printing half the file,
      37             :  finding job
      38             :  delete job
      39             :  try writing 2nd half
      40             : 
      41             :  SMBsplretq
      42             : 
      43             : */
      44             : 
      45             : #define TORTURE_PRINT_FILE "torture_print_file"
      46             : 
      47           0 : static bool print_printjob(struct torture_context *tctx,
      48             :                            struct smbcli_tree *tree)
      49             : {
      50           0 :         int fnum;
      51           0 :         DATA_BLOB data;
      52           0 :         ssize_t size_written;
      53           0 :         const char *str;
      54             : 
      55           0 :         torture_comment(tctx, "creating printjob %s\n", TORTURE_PRINT_FILE);
      56             : 
      57           0 :         fnum = smbcli_open(tree, TORTURE_PRINT_FILE, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
      58           0 :         if (fnum == -1) {
      59           0 :                 torture_fail(tctx, "failed to open file");
      60             :         }
      61             : 
      62           0 :         str = talloc_asprintf(tctx, "TortureTestPage: %d\nData\n",0);
      63             : 
      64           0 :         data = data_blob_string_const(str);
      65             : 
      66           0 :         size_written = smbcli_write(tree, fnum, 0, data.data, 0, data.length);
      67           0 :         if (size_written != data.length) {
      68           0 :                 torture_fail(tctx, "failed to write file");
      69             :         }
      70             : 
      71           0 :         torture_assert_ntstatus_ok(tctx,
      72             :                 smbcli_close(tree, fnum),
      73             :                 "failed to close file");
      74             : 
      75           0 :         return true;
      76             : }
      77             : 
      78           0 : static bool test_raw_print(struct torture_context *tctx,
      79             :                            struct smbcli_state *cli)
      80             : {
      81           0 :         return print_printjob(tctx, cli->tree);
      82             : }
      83             : 
      84           0 : static bool test_netprintqenum(struct torture_context *tctx,
      85             :                                struct smbcli_state *cli)
      86             : {
      87           0 :         struct rap_NetPrintQEnum r;
      88           0 :         int i, q;
      89           0 :         uint16_t levels[] = { 0, 1, 2, 3, 4, 5 };
      90             : 
      91           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
      92             : 
      93           0 :                 r.in.level = levels[i];
      94           0 :                 r.in.bufsize = 8192;
      95             : 
      96           0 :                 torture_comment(tctx,
      97           0 :                         "Testing rap_NetPrintQEnum level %d\n", r.in.level);
      98             : 
      99           0 :                 torture_assert_ntstatus_ok(tctx,
     100             :                         smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     101             :                         "smbcli_rap_netprintqenum failed");
     102           0 :                 torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     103             :                         "failed to enum printq");
     104             : 
     105           0 :                 for (q=0; q<r.out.count; q++) {
     106           0 :                         switch (r.in.level) {
     107           0 :                         case 0:
     108           0 :                                 printf("%s\n", r.out.info[q].info0.PrintQName);
     109           0 :                                 break;
     110             :                         }
     111             :                 }
     112             :         }
     113             : 
     114           0 :         return true;
     115             : }
     116             : 
     117           0 : static bool test_netprintqgetinfo(struct torture_context *tctx,
     118             :                                   struct smbcli_state *cli)
     119             : {
     120           0 :         struct rap_NetPrintQGetInfo r;
     121           0 :         struct rap_NetPrintQEnum r_enum;
     122           0 :         int i, p;
     123           0 :         uint16_t levels[] = { 0, 1, 2, 3, 4, 5 };
     124             : 
     125           0 :         r.in.level = 0;
     126           0 :         r.in.bufsize = 0;
     127           0 :         r.in.PrintQueueName = "";
     128             : 
     129           0 :         torture_assert_ntstatus_ok(tctx,
     130             :                 smbcli_rap_netprintqgetinfo(cli->tree, tctx, &r),
     131             :                 "smbcli_rap_netprintqgetinfo failed");
     132           0 :         torture_assert_werr_equal(tctx,
     133             :                                   W_ERROR(r.out.status),
     134             :                                   WERR_INVALID_PARAMETER,
     135             :                                   "smbcli_rap_netprintqgetinfo failed");
     136             : 
     137           0 :         r_enum.in.level = 5;
     138           0 :         r_enum.in.bufsize = 8192;
     139             : 
     140           0 :         torture_assert_ntstatus_ok(tctx,
     141             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r_enum),
     142             :                 "failed to enum printq");
     143           0 :         torture_assert_werr_ok(tctx, W_ERROR(r_enum.out.status),
     144             :                 "failed to enum printq");
     145             : 
     146           0 :         for (p=0; p < r_enum.out.count; p++) {
     147             : 
     148           0 :                 for (i=0; i < ARRAY_SIZE(levels); i++) {
     149             : 
     150           0 :                         r.in.level = levels[i];
     151           0 :                         r.in.bufsize = 8192;
     152           0 :                         r.in.PrintQueueName = r_enum.out.info[p].info5.PrintQueueName;
     153             : 
     154           0 :                         torture_comment(tctx, "Testing rap_NetPrintQGetInfo(%s) level %d\n",
     155           0 :                                 r.in.PrintQueueName, r.in.level);
     156             : 
     157           0 :                         torture_assert_ntstatus_ok(tctx,
     158             :                                 smbcli_rap_netprintqgetinfo(cli->tree, tctx, &r),
     159             :                                 "smbcli_rap_netprintqgetinfo failed");
     160           0 :                         torture_assert_werr_ok(tctx,
     161             :                                 W_ERROR(r.out.status),
     162             :                                 "smbcli_rap_netprintqgetinfo failed");
     163             : 
     164           0 :                         switch (r.in.level) {
     165           0 :                         case 0:
     166           0 :                                 printf("%s\n", r.out.info.info0.PrintQName);
     167           0 :                                 break;
     168             :                         }
     169             :                 }
     170             :         }
     171             : 
     172           0 :         return true;
     173             : }
     174             : 
     175           0 : static bool test_netprintjob_pause(struct torture_context *tctx,
     176             :                                    struct smbcli_state *cli,
     177             :                                    uint16_t job_id)
     178             : {
     179           0 :         struct rap_NetPrintJobPause r;
     180             : 
     181           0 :         r.in.JobID = job_id;
     182             : 
     183           0 :         torture_comment(tctx, "Testing rap_NetPrintJobPause(%d)\n", r.in.JobID);
     184             : 
     185           0 :         torture_assert_ntstatus_ok(tctx,
     186             :                 smbcli_rap_netprintjobpause(cli->tree, tctx, &r),
     187             :                 "smbcli_rap_netprintjobpause failed");
     188             : 
     189           0 :         return true;
     190             : }
     191             : 
     192           0 : static bool test_netprintjob_continue(struct torture_context *tctx,
     193             :                                       struct smbcli_state *cli,
     194             :                                       uint16_t job_id)
     195             : {
     196           0 :         struct rap_NetPrintJobContinue r;
     197             : 
     198           0 :         r.in.JobID = job_id;
     199             : 
     200           0 :         torture_comment(tctx, "Testing rap_NetPrintJobContinue(%d)\n", r.in.JobID);
     201             : 
     202           0 :         torture_assert_ntstatus_ok(tctx,
     203             :                 smbcli_rap_netprintjobcontinue(cli->tree, tctx, &r),
     204             :                 "smbcli_rap_netprintjobcontinue failed");
     205             : 
     206           0 :         return true;
     207             : }
     208             : 
     209           0 : static bool test_netprintjob_delete(struct torture_context *tctx,
     210             :                                     struct smbcli_state *cli,
     211             :                                     uint16_t job_id)
     212             : {
     213           0 :         struct rap_NetPrintJobDelete r;
     214             : 
     215           0 :         r.in.JobID = job_id;
     216             : 
     217           0 :         torture_comment(tctx, "Testing rap_NetPrintJobDelete(%d)\n", r.in.JobID);
     218             : 
     219           0 :         torture_assert_ntstatus_ok(tctx,
     220             :                 smbcli_rap_netprintjobdelete(cli->tree, tctx, &r),
     221             :                 "smbcli_rap_netprintjobdelete failed");
     222             : 
     223           0 :         return true;
     224             : }
     225             : 
     226           0 : static bool test_netprintjob(struct torture_context *tctx,
     227             :                              struct smbcli_state *cli)
     228             : {
     229           0 :         uint16_t job_id = 400;
     230             : 
     231           0 :         torture_assert(tctx,
     232             :                 test_netprintjob_pause(tctx, cli, job_id),
     233             :                 "failed to pause job");
     234           0 :         torture_assert(tctx,
     235             :                 test_netprintjob_continue(tctx, cli, job_id),
     236             :                 "failed to continue job");
     237           0 :         torture_assert(tctx,
     238             :                 test_netprintjob_delete(tctx, cli, job_id),
     239             :                 "failed to delete job");
     240             : 
     241           0 :         return true;
     242             : }
     243             : 
     244           0 : static bool test_netprintq_pause(struct torture_context *tctx,
     245             :                                  struct smbcli_state *cli,
     246             :                                  const char *PrintQueueName)
     247             : {
     248           0 :         struct rap_NetPrintQueuePause r;
     249             : 
     250           0 :         r.in.PrintQueueName = PrintQueueName;
     251             : 
     252           0 :         torture_comment(tctx, "Testing rap_NetPrintQueuePause(%s)\n", r.in.PrintQueueName);
     253             : 
     254           0 :         torture_assert_ntstatus_ok(tctx,
     255             :                 smbcli_rap_netprintqueuepause(cli->tree, tctx, &r),
     256             :                 "smbcli_rap_netprintqueuepause failed");
     257           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     258             :                 "smbcli_rap_netprintqueuepause failed");
     259             : 
     260           0 :         return true;
     261             : }
     262             : 
     263           0 : static bool test_netprintq_resume(struct torture_context *tctx,
     264             :                                   struct smbcli_state *cli,
     265             :                                   const char *PrintQueueName)
     266             : {
     267           0 :         struct rap_NetPrintQueueResume r;
     268             : 
     269           0 :         r.in.PrintQueueName = PrintQueueName;
     270             : 
     271           0 :         torture_comment(tctx, "Testing rap_NetPrintQueueResume(%s)\n", r.in.PrintQueueName);
     272             : 
     273           0 :         torture_assert_ntstatus_ok(tctx,
     274             :                 smbcli_rap_netprintqueueresume(cli->tree, tctx, &r),
     275             :                 "smbcli_rap_netprintqueueresume failed");
     276           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     277             :                 "smbcli_rap_netprintqueueresume failed");
     278             : 
     279           0 :         return true;
     280             : }
     281             : 
     282           0 : static bool test_netprintq(struct torture_context *tctx,
     283             :                            struct smbcli_state *cli)
     284             : {
     285           0 :         struct rap_NetPrintQEnum r;
     286           0 :         int i;
     287             : 
     288           0 :         r.in.level = 5;
     289           0 :         r.in.bufsize = 8192;
     290             : 
     291           0 :         torture_assert_ntstatus_ok(tctx,
     292             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     293             :                 "failed to enum printq");
     294           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     295             :                 "failed to enum printq");
     296             : 
     297           0 :         for (i=0; i < r.out.count; i++) {
     298             : 
     299           0 :                 const char *printqname = r.out.info[i].info5.PrintQueueName;
     300             : 
     301           0 :                 torture_assert(tctx,
     302             :                         test_netprintq_pause(tctx, cli, printqname),
     303             :                         "failed to pause print queue");
     304             : 
     305           0 :                 torture_assert(tctx,
     306             :                         test_netprintq_resume(tctx, cli, printqname),
     307             :                         "failed to resume print queue");
     308             :         }
     309             : 
     310           0 :         return true;
     311             : }
     312             : 
     313           0 : static bool test_netprintjobenum_args(struct torture_context *tctx,
     314             :                                       struct smbcli_state *cli,
     315             :                                       const char *PrintQueueName,
     316             :                                       uint16_t level,
     317             :                                       uint16_t *count_p,
     318             :                                       union rap_printj_info **info_p)
     319             : {
     320           0 :         struct rap_NetPrintJobEnum r;
     321             : 
     322           0 :         r.in.PrintQueueName = PrintQueueName;
     323           0 :         r.in.bufsize = 8192;
     324           0 :         r.in.level = level;
     325             : 
     326           0 :         torture_comment(tctx,
     327           0 :                 "Testing rap_NetPrintJobEnum(%s) level %d\n", r.in.PrintQueueName, r.in.level);
     328             : 
     329           0 :         torture_assert_ntstatus_ok(tctx,
     330             :                 smbcli_rap_netprintjobenum(cli->tree, tctx, &r),
     331             :                 "smbcli_rap_netprintjobenum failed");
     332             : 
     333           0 :         if (count_p) {
     334           0 :                 *count_p = r.out.count;
     335             :         }
     336           0 :         if (info_p) {
     337           0 :                 *info_p = r.out.info;
     338             :         }
     339             : 
     340           0 :         return true;
     341             : }
     342             : 
     343           0 : static bool test_netprintjobenum_one(struct torture_context *tctx,
     344             :                                      struct smbcli_state *cli,
     345             :                                      const char *PrintQueueName)
     346             : {
     347           0 :         struct rap_NetPrintJobEnum r;
     348           0 :         int i;
     349           0 :         uint16_t levels[] = { 0, 1, 2 };
     350             : 
     351           0 :         r.in.PrintQueueName = PrintQueueName;
     352           0 :         r.in.bufsize = 8192;
     353             : 
     354           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
     355             : 
     356           0 :                 r.in.level = levels[i];
     357             : 
     358           0 :                 torture_comment(tctx,
     359           0 :                         "Testing rap_NetPrintJobEnum(%s) level %d\n", r.in.PrintQueueName, r.in.level);
     360             : 
     361           0 :                 torture_assert_ntstatus_ok(tctx,
     362             :                         smbcli_rap_netprintjobenum(cli->tree, tctx, &r),
     363             :                         "smbcli_rap_netprintjobenum failed");
     364             :         }
     365             : 
     366           0 :         return true;
     367             : }
     368             : 
     369           0 : static bool test_netprintjobgetinfo_byid(struct torture_context *tctx,
     370             :                                          struct smbcli_state *cli,
     371             :                                          uint16_t JobID)
     372             : {
     373           0 :         struct rap_NetPrintJobGetInfo r;
     374           0 :         uint16_t levels[] = { 0, 1, 2 };
     375           0 :         int i;
     376             : 
     377           0 :         r.in.JobID = JobID;
     378           0 :         r.in.bufsize = 8192;
     379             : 
     380           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
     381             : 
     382           0 :                 r.in.level = levels[i];
     383             : 
     384           0 :                 torture_comment(tctx, "Testing rap_NetPrintJobGetInfo(%d) level %d\n", r.in.JobID, r.in.level);
     385             : 
     386           0 :                 torture_assert_ntstatus_ok(tctx,
     387             :                         smbcli_rap_netprintjobgetinfo(cli->tree, tctx, &r),
     388             :                         "smbcli_rap_netprintjobgetinfo failed");
     389             :         }
     390             : 
     391           0 :         return true;
     392             : }
     393             : 
     394           0 : static bool test_netprintjobsetinfo_byid(struct torture_context *tctx,
     395             :                                          struct smbcli_state *cli,
     396             :                                          uint16_t JobID)
     397             : {
     398           0 :         struct rap_NetPrintJobSetInfo r;
     399           0 :         uint16_t levels[] = { 0, 1, 2 };
     400           0 :         int i;
     401           0 :         const char *comment = "tortured by samba";
     402             : 
     403           0 :         r.in.JobID = JobID;
     404           0 :         r.in.bufsize = strlen(comment);
     405           0 :         r.in.ParamNum = RAP_PARAM_JOBCOMMENT;
     406           0 :         r.in.Param.string = comment;
     407             : 
     408           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
     409             : 
     410           0 :                 r.in.level = levels[i];
     411             : 
     412           0 :                 torture_comment(tctx, "Testing rap_NetPrintJobSetInfo(%d) level %d\n", r.in.JobID, r.in.level);
     413             : 
     414           0 :                 torture_assert_ntstatus_ok(tctx,
     415             :                         smbcli_rap_netprintjobsetinfo(cli->tree, tctx, &r),
     416             :                         "smbcli_rap_netprintjobsetinfo failed");
     417             :         }
     418             : 
     419           0 :         return true;
     420             : }
     421             : 
     422             : 
     423           0 : static bool test_netprintjobgetinfo_byqueue(struct torture_context *tctx,
     424             :                                             struct smbcli_state *cli,
     425             :                                             const char *PrintQueueName)
     426             : {
     427           0 :         struct rap_NetPrintJobEnum r;
     428           0 :         int i;
     429             : 
     430           0 :         r.in.PrintQueueName = PrintQueueName;
     431           0 :         r.in.bufsize = 8192;
     432           0 :         r.in.level = 0;
     433             : 
     434           0 :         torture_assert_ntstatus_ok(tctx,
     435             :                 smbcli_rap_netprintjobenum(cli->tree, tctx, &r),
     436             :                 "failed to enumerate jobs");
     437             : 
     438           0 :         for (i=0; i < r.out.count; i++) {
     439             : 
     440           0 :                 torture_assert(tctx,
     441             :                         test_netprintjobgetinfo_byid(tctx, cli, r.out.info[i].info0.JobID),
     442             :                         "failed to get job info");
     443             :         }
     444             : 
     445           0 :         return true;
     446             : }
     447             : 
     448           0 : static bool test_netprintjobsetinfo_byqueue(struct torture_context *tctx,
     449             :                                             struct smbcli_state *cli,
     450             :                                             const char *PrintQueueName)
     451             : {
     452           0 :         struct rap_NetPrintJobEnum r;
     453           0 :         int i;
     454             : 
     455           0 :         r.in.PrintQueueName = PrintQueueName;
     456           0 :         r.in.bufsize = 8192;
     457           0 :         r.in.level = 0;
     458             : 
     459           0 :         torture_assert_ntstatus_ok(tctx,
     460             :                 smbcli_rap_netprintjobenum(cli->tree, tctx, &r),
     461             :                 "failed to enumerate jobs");
     462             : 
     463           0 :         for (i=0; i < r.out.count; i++) {
     464             : 
     465           0 :                 torture_assert(tctx,
     466             :                         test_netprintjobsetinfo_byid(tctx, cli, r.out.info[i].info0.JobID),
     467             :                         "failed to set job info");
     468             :         }
     469             : 
     470           0 :         return true;
     471             : }
     472             : 
     473           0 : static bool test_netprintjobenum(struct torture_context *tctx,
     474             :                                  struct smbcli_state *cli)
     475             : {
     476           0 :         struct rap_NetPrintQEnum r;
     477           0 :         int i;
     478             : 
     479           0 :         r.in.level = 5;
     480           0 :         r.in.bufsize = 8192;
     481             : 
     482           0 :         torture_assert_ntstatus_ok(tctx,
     483             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     484             :                 "failed to enum printq");
     485           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     486             :                 "failed to enum printq");
     487             : 
     488           0 :         for (i=0; i < r.out.count; i++) {
     489             : 
     490           0 :                 const char *printqname = r.out.info[i].info5.PrintQueueName;
     491             : 
     492           0 :                 torture_assert(tctx,
     493             :                         test_netprintjobenum_one(tctx, cli, printqname),
     494             :                         "failed to enumerate printjobs on print queue");
     495             :         }
     496             : 
     497           0 :         return true;
     498             : }
     499             : 
     500           0 : static bool test_netprintjobgetinfo(struct torture_context *tctx,
     501             :                                     struct smbcli_state *cli)
     502             : {
     503           0 :         struct rap_NetPrintQEnum r;
     504           0 :         int i;
     505             : 
     506           0 :         r.in.level = 5;
     507           0 :         r.in.bufsize = 8192;
     508             : 
     509           0 :         torture_assert_ntstatus_ok(tctx,
     510             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     511             :                 "failed to enum printq");
     512           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     513             :                 "failed to enum printq");
     514             : 
     515           0 :         for (i=0; i < r.out.count; i++) {
     516             : 
     517           0 :                 const char *printqname = r.out.info[i].info5.PrintQueueName;
     518             : 
     519           0 :                 torture_assert(tctx,
     520             :                         test_netprintjobgetinfo_byqueue(tctx, cli, printqname),
     521             :                         "failed to enumerate printjobs on print queue");
     522             :         }
     523             : 
     524           0 :         return true;
     525             : }
     526             : 
     527           0 : static bool test_netprintjobsetinfo(struct torture_context *tctx,
     528             :                                     struct smbcli_state *cli)
     529             : {
     530           0 :         struct rap_NetPrintQEnum r;
     531           0 :         int i;
     532             : 
     533           0 :         r.in.level = 5;
     534           0 :         r.in.bufsize = 8192;
     535             : 
     536           0 :         torture_assert_ntstatus_ok(tctx,
     537             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     538             :                 "failed to enum printq");
     539           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     540             :                 "failed to enum printq");
     541             : 
     542           0 :         for (i=0; i < r.out.count; i++) {
     543             : 
     544           0 :                 const char *printqname = r.out.info[i].info5.PrintQueueName;
     545             : 
     546           0 :                 torture_assert(tctx,
     547             :                         test_netprintjobsetinfo_byqueue(tctx, cli, printqname),
     548             :                         "failed to set printjobs on print queue");
     549             :         }
     550             : 
     551           0 :         return true;
     552             : }
     553             : 
     554           0 : static bool test_netprintdestenum(struct torture_context *tctx,
     555             :                                   struct smbcli_state *cli)
     556             : {
     557           0 :         struct rap_NetPrintDestEnum r;
     558           0 :         int i;
     559           0 :         uint16_t levels[] = { 0, 1, 2, 3 };
     560             : 
     561           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
     562             : 
     563           0 :                 r.in.level = levels[i];
     564           0 :                 r.in.bufsize = 8192;
     565             : 
     566           0 :                 torture_comment(tctx,
     567           0 :                         "Testing rap_NetPrintDestEnum level %d\n", r.in.level);
     568             : 
     569           0 :                 torture_assert_ntstatus_ok(tctx,
     570             :                         smbcli_rap_netprintdestenum(cli->tree, tctx, &r),
     571             :                         "smbcli_rap_netprintdestenum failed");
     572             :         }
     573             : 
     574           0 :         return true;
     575             : }
     576             : 
     577           0 : static bool test_netprintdestgetinfo_bydest(struct torture_context *tctx,
     578             :                                             struct smbcli_state *cli,
     579             :                                             const char *PrintDestName)
     580             : {
     581           0 :         struct rap_NetPrintDestGetInfo r;
     582           0 :         int i;
     583           0 :         uint16_t levels[] = { 0, 1, 2, 3 };
     584             : 
     585           0 :         for (i=0; i < ARRAY_SIZE(levels); i++) {
     586             : 
     587           0 :                 r.in.PrintDestName = PrintDestName;
     588           0 :                 r.in.level = levels[i];
     589           0 :                 r.in.bufsize = 8192;
     590             : 
     591           0 :                 torture_comment(tctx,
     592           0 :                         "Testing rap_NetPrintDestGetInfo(%s) level %d\n", r.in.PrintDestName, r.in.level);
     593             : 
     594           0 :                 torture_assert_ntstatus_ok(tctx,
     595             :                         smbcli_rap_netprintdestgetinfo(cli->tree, tctx, &r),
     596             :                         "smbcli_rap_netprintdestgetinfo failed");
     597             :         }
     598             : 
     599           0 :         return true;
     600             : }
     601             : 
     602             : 
     603           0 : static bool test_netprintdestgetinfo(struct torture_context *tctx,
     604             :                                      struct smbcli_state *cli)
     605             : {
     606           0 :         struct rap_NetPrintDestEnum r;
     607           0 :         int i;
     608             : 
     609           0 :         r.in.level = 2;
     610           0 :         r.in.bufsize = 8192;
     611             : 
     612           0 :         torture_comment(tctx,
     613           0 :                 "Testing rap_NetPrintDestEnum level %d\n", r.in.level);
     614             : 
     615           0 :         torture_assert_ntstatus_ok(tctx,
     616             :                 smbcli_rap_netprintdestenum(cli->tree, tctx, &r),
     617             :                 "smbcli_rap_netprintdestenum failed");
     618             : 
     619           0 :         for (i=0; i < r.out.count; i++) {
     620             : 
     621           0 :                 torture_assert(tctx,
     622             :                         test_netprintdestgetinfo_bydest(tctx, cli, r.out.info[i].info2.PrinterName),
     623             :                         "failed to get printdest info");
     624             : 
     625             :         }
     626             : 
     627           0 :         return true;
     628             : }
     629             : 
     630           0 : static bool test_rap_print(struct torture_context *tctx,
     631             :                            struct smbcli_state *cli)
     632             : {
     633           0 :         struct rap_NetPrintQEnum r;
     634           0 :         int i;
     635             : 
     636           0 :         r.in.level = 5;
     637           0 :         r.in.bufsize = 8192;
     638             : 
     639           0 :         torture_assert_ntstatus_ok(tctx,
     640             :                 smbcli_rap_netprintqenum(cli->tree, tctx, &r),
     641             :                 "failed to enum printq");
     642           0 :         torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
     643             :                 "failed to enum printq");
     644             : 
     645           0 :         for (i=0; i < r.out.count; i++) {
     646             : 
     647           0 :                 const char *printqname = r.out.info[i].info5.PrintQueueName;
     648           0 :                 struct smbcli_tree *res_queue = NULL;
     649           0 :                 uint16_t num_jobs;
     650           0 :                 union rap_printj_info *job_info;
     651           0 :                 int j;
     652             : 
     653           0 :                 torture_assert(tctx,
     654             :                         test_netprintq_pause(tctx, cli, printqname),
     655             :                         "failed to set printjobs on print queue");
     656             : 
     657           0 :                 torture_assert_ntstatus_ok(tctx,
     658             :                         torture_second_tcon(tctx, cli->session, printqname, &res_queue),
     659             :                         "failed to open 2nd connection");
     660             : 
     661           0 :                 torture_assert(tctx,
     662             :                         print_printjob(tctx, res_queue),
     663             :                         "failed to print job on 2nd connection");
     664             : 
     665           0 :                 talloc_free(res_queue);
     666             : 
     667           0 :                 torture_assert(tctx,
     668             :                         test_netprintjobenum_args(tctx, cli, printqname, 1,
     669             :                         &num_jobs, &job_info),
     670             :                         "failed to enum printjobs on print queue");
     671             : 
     672           0 :                 for (j=0; j < num_jobs; j++) {
     673             : 
     674           0 :                         uint16_t job_id = job_info[j].info1.JobID;
     675             : 
     676           0 :                         torture_assert(tctx,
     677             :                                 test_netprintjobgetinfo_byid(tctx, cli, job_id),
     678             :                                 "failed to getinfo on new printjob");
     679             : 
     680           0 :                         torture_assert(tctx,
     681             :                                 test_netprintjob_delete(tctx, cli, job_id),
     682             :                                 "failed to delete job");
     683             :                 }
     684             : 
     685           0 :                 torture_assert(tctx,
     686             :                         test_netprintq_resume(tctx, cli, printqname),
     687             :                         "failed to resume print queue");
     688             : 
     689             :         }
     690             : 
     691           0 :         return true;
     692             : }
     693             : 
     694        2354 : struct torture_suite *torture_rap_printing(TALLOC_CTX *mem_ctx)
     695             : {
     696        2354 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "printing");
     697             : 
     698        2354 :         torture_suite_add_1smb_test(suite, "raw_print", test_raw_print);
     699        2354 :         torture_suite_add_1smb_test(suite, "rap_print", test_rap_print);
     700        2354 :         torture_suite_add_1smb_test(suite, "rap_printq_enum", test_netprintqenum);
     701        2354 :         torture_suite_add_1smb_test(suite, "rap_printq_getinfo", test_netprintqgetinfo);
     702        2354 :         torture_suite_add_1smb_test(suite, "rap_printq", test_netprintq);
     703        2354 :         torture_suite_add_1smb_test(suite, "rap_printjob_enum", test_netprintjobenum);
     704        2354 :         torture_suite_add_1smb_test(suite, "rap_printjob_getinfo", test_netprintjobgetinfo);
     705        2354 :         torture_suite_add_1smb_test(suite, "rap_printjob_setinfo", test_netprintjobsetinfo);
     706        2354 :         torture_suite_add_1smb_test(suite, "rap_printjob", test_netprintjob);
     707        2354 :         torture_suite_add_1smb_test(suite, "rap_printdest_enum", test_netprintdestenum);
     708        2354 :         torture_suite_add_1smb_test(suite, "rap_printdest_getinfo", test_netprintdestgetinfo);
     709             : 
     710        2354 :         return suite;
     711             : }

Generated by: LCOV version 1.14