summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-10-31 04:41:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:06 -0500
commit0e082a5c9d3faf11dd7f8813d4777597819c41da (patch)
tree908ac4db49d40b8793b235b4745e16023992304c /source4/scripting
parent0b0673213be1226e72987fea25a90e2a385788af (diff)
downloadsamba-0e082a5c9d3faf11dd7f8813d4777597819c41da.tar.gz
samba-0e082a5c9d3faf11dd7f8813d4777597819c41da.tar.bz2
samba-0e082a5c9d3faf11dd7f8813d4777597819c41da.zip
r3403: Add test for operations on print server handle.
Add tests for EnumJobs, GetJob. Oops - forgot to EnumPrinters at level2. (This used to be commit 930d57964b69fda59f473914ac4633984f259c86)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/swig/torture/spoolss.py87
1 files changed, 72 insertions, 15 deletions
diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py
index 4c65669d8f..1b19bd8f1a 100644
--- a/source4/scripting/swig/torture/spoolss.py
+++ b/source4/scripting/swig/torture/spoolss.py
@@ -22,9 +22,13 @@ def test_OpenPrinterEx(pipe, printer):
print 'testing spoolss_OpenPrinterEx(%s)' % printer
+ printername = '\\\\%s' % dcerpc.dcerpc_server_name(pipe)
+
+ if printer is not None:
+ printername = printername + '\\%s' % printer
+
r = {}
- r['printername'] = '\\\\%s\\%s' % \
- (dcerpc.dcerpc_server_name(pipe), printer)
+ r['printername'] = printername
r['datatype'] = None
r['devmode_ctr'] = {}
r['devmode_ctr']['size'] = 0
@@ -190,6 +194,38 @@ def test_AddForm(pipe, handle):
test_DeleteForm(pipe, handle, formname)
+def test_EnumJobs(pipe, handle):
+
+ print 'testing spoolss_EnumJobs'
+
+ r = {}
+ r['handle'] = handle
+ r['firstjob'] = 0
+ r['numjobs'] = 0xffffffff
+ r['level'] = 1
+
+ result = ResizeBufferCall(dcerpc.spoolss_EnumJobs, pipe, r)
+
+ if result['buffer'] is None:
+ return
+
+ jobs = dcerpc.unmarshall_spoolss_JobInfo_array(
+ result['buffer'], r['level'], result['count'])
+
+ for job in jobs:
+
+ s = {}
+ s['handle'] = handle
+ s['job_id'] = job['info1']['job_id']
+ s['level'] = 1
+
+ result = ResizeBufferCall(dcerpc.spoolss_GetJob, pipe, s)
+
+ if result['info'] != job:
+ print 'EnumJobs: mismatch: %s != %s' % (result['info'], job)
+ sys.exit(1)
+
+
def test_EnumPrinters(pipe):
print 'testing spoolss_EnumPrinters'
@@ -200,35 +236,55 @@ def test_EnumPrinters(pipe):
r['flags'] = 0x02
r['server'] = None
- for level in [0, 1, 4, 5]:
+ for level in [0, 1, 2, 4, 5]:
print 'test_EnumPrinters(level = %d)' % level
r['level'] = level
- r['buf_size'] = 0
- r['buffer'] = None
- result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters,pipe, r)
+ result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters, pipe, r)
printers = dcerpc.unmarshall_spoolss_PrinterInfo_array(
result['buffer'], r['level'], result['count'])
- if level == 1:
- printer_names = map(
- lambda x: string.split(x['info1']['name'], ',')[0], printers)
+ if level == 2:
+ for p in printers:
- for printer in printer_names:
+ # A nice check is for the specversion in the
+ # devicemode. This has always been observed to be
+ # 1025.
- handle = test_OpenPrinterEx(pipe, printer)
+ if p['info2']['devmode']['specversion'] != 1025:
+ print 'test_EnumPrinters: specversion != 1025'
+ sys.exit(1)
- test_GetPrinter(pipe, handle)
+ r['level'] = 1
+ result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters, pipe, r)
+
+ for printer in dcerpc.unmarshall_spoolss_PrinterInfo_array(
+ result['buffer'], r['level'], result['count']):
- test_EnumForms(pipe, handle)
+ if string.find(printer['info1']['name'], '\\\\') == 0:
+ print 'Skipping remote printer %s' % printer['info1']['name']
+ continue
- test_AddForm(pipe, handle)
+ printername = string.split(printer['info1']['name'], ',')[0]
+
+ handle = test_OpenPrinterEx(pipe, printername)
+ test_GetPrinter(pipe, handle)
+ test_EnumForms(pipe, handle)
+ test_AddForm(pipe, handle)
+ test_EnumJobs(pipe, handle)
test_ClosePrinter(pipe, handle)
-
+
+
+def test_PrintServer(pipe):
+
+ handle = test_OpenPrinterEx(pipe, None)
+
+ test_ClosePrinter(pipe, handle)
+
def runtests(binding, domain, username, password):
@@ -239,3 +295,4 @@ def runtests(binding, domain, username, password):
domain, username, password)
test_EnumPrinters(pipe)
+ test_PrintServer(pipe)