summaryrefslogtreecommitdiff
path: root/source4/scripting/swig/torture
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-10-25 12:54:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:42 -0500
commit974d048493c77c0bc2d7a99c1e16d0ee9643c5ab (patch)
treef3ac119b3ee0218eade6f97514427daf11f701d2 /source4/scripting/swig/torture
parentd8be7281005658067aac89c9d0022b15260d8e52 (diff)
downloadsamba-974d048493c77c0bc2d7a99c1e16d0ee9643c5ab.tar.gz
samba-974d048493c77c0bc2d7a99c1e16d0ee9643c5ab.tar.bz2
samba-974d048493c77c0bc2d7a99c1e16d0ee9643c5ab.zip
r3216: Add tests for OpenPrinterEx and ClosePrinter.
(This used to be commit b7ff5f0deded4bcf6695dac0683fd9d271d9c255)
Diffstat (limited to 'source4/scripting/swig/torture')
-rw-r--r--source4/scripting/swig/torture/spoolss.py71
1 files changed, 63 insertions, 8 deletions
diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py
index 8336a027df..a18b9c61a7 100644
--- a/source4/scripting/swig/torture/spoolss.py
+++ b/source4/scripting/swig/torture/spoolss.py
@@ -1,23 +1,78 @@
+import string
import dcerpc
+def test_OpenPrinterEx(pipe, printer):
+
+ print 'testing spoolss_OpenPrinterEx(%s)' % printer
+
+ r = {}
+ r['printername'] = '\\\\win2k3dc\\%s' % printer
+ r['datatype'] = None
+ r['devmode_ctr'] = {}
+ r['devmode_ctr']['size'] = 0
+ r['devmode_ctr']['devmode'] = None
+ r['access_mask'] = 0x02000000
+ r['level'] = 1
+ r['userlevel'] = {}
+ r['userlevel']['level1'] = {}
+ r['userlevel']['level1']['size'] = 0
+ r['userlevel']['level1']['client'] = None
+ r['userlevel']['level1']['user'] = None
+ r['userlevel']['level1']['build'] = 1381
+ r['userlevel']['level1']['major'] = 2
+ r['userlevel']['level1']['minor'] = 0
+ r['userlevel']['level1']['processor'] = 0
+
+ result = dcerpc.spoolss_OpenPrinterEx(pipe, r)
+
+ return result['handle']
+
+
+def test_ClosePrinter(pipe, handle):
+
+ r = {}
+ r['handle'] = handle
+
+ dcerpc.spoolss_ClosePrinter(pipe, r)
+
+
def test_EnumPrinters(pipe):
+ print 'testing spoolss_EnumPrinters'
+
+ printer_names = None
+
r = {}
r['flags'] = 0x02
r['server'] = None
- r['level'] = 1
- r['buffer'] = None
- r['buf_size'] = 0
- result = dcerpc.spoolss_EnumPrinters(pipe, r)
+ for level in [1, 2, 4, 5]:
- if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER:
- r['buffer'] = result['buf_size'] * '\x00'
- r['buf_size'] = result['buf_size']
+ r['level'] = level
+ r['buf_size'] = 0
+ r['buffer'] = None
result = dcerpc.spoolss_EnumPrinters(pipe, r)
- print dcerpc.unmarshall_spoolss_PrinterInfo_array(result['buffer'], r['level'], result['count'])
+ if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER:
+ r['buffer'] = result['buf_size'] * '\x00'
+ r['buf_size'] = result['buf_size']
+
+ result = dcerpc.spoolss_EnumPrinters(pipe, r)
+
+ printers = dcerpc.unmarshall_spoolss_PrinterInfo_array(
+ result['buffer'], r['level'], result['count'])
+
+ if printer_names is None:
+ printer_names = map(
+ lambda x: string.split(x['info1']['name'], ',')[0], printers)
+
+ for printer in printer_names:
+
+ handle = test_OpenPrinterEx(pipe, printer)
+
+ test_ClosePrinter(pipe, handle)
+
def runtests(binding, domain, username, password):