summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-28 12:49:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:27 -0500
commit83d0f6ffae928e8d8571216542cfb580accff028 (patch)
tree578d1cc87954fa1af16606631a99405f9c7c1397 /source4
parent169cf23812ab32e1b6b4ba5c27c53266e16a9f1e (diff)
downloadsamba-83d0f6ffae928e8d8571216542cfb580accff028.tar.gz
samba-83d0f6ffae928e8d8571216542cfb580accff028.tar.bz2
samba-83d0f6ffae928e8d8571216542cfb580accff028.zip
r2728: Break arg parsing stuff out of samr.py into a standalone program.
(This used to be commit 799b377badebf9a3f388b7d3fdc36484aa5e3376)
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/swig/torture/pytorture37
-rwxr-xr-xsource4/scripting/swig/torture/samr.py63
2 files changed, 53 insertions, 47 deletions
diff --git a/source4/scripting/swig/torture/pytorture b/source4/scripting/swig/torture/pytorture
new file mode 100755
index 0000000000..89ecfbabcf
--- /dev/null
+++ b/source4/scripting/swig/torture/pytorture
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+from optparse import OptionParser
+
+# Parse command line
+
+parser = OptionParser()
+
+parser.add_option("-b", "--binding", action="store", type="string",
+ dest="binding")
+
+parser.add_option("-d", "--domain", action="store", type="string",
+ dest="domain")
+
+parser.add_option("-u", "--username", action="store", type="string",
+ dest="username")
+
+parser.add_option("-p", "--password", action="store", type="string",
+ dest="password")
+
+(options, args) = parser.parse_args()
+
+if not options.binding:
+ parser.error('You must supply a binding string')
+
+if not options.username or not options.password or not options.domain:
+ parser.error('You must supply a domain, username and password')
+
+binding = options.binding
+domain = options.domain
+username = options.username
+password = options.password
+
+# Run tests
+
+import samr
+samr.runtests(binding, domain, username, password)
diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py
index 07bbaf3a93..ba650dfe75 100755
--- a/source4/scripting/swig/torture/samr.py
+++ b/source4/scripting/swig/torture/samr.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
-import sys, dcerpc
-from optparse import OptionParser
+import dcerpc
-def test_Connect(handle):
+def test_Connect(pipe):
print 'testing samr_Connect'
@@ -93,7 +92,7 @@ def test_QuerySecurity(pipe, handle):
dcerpc.samr_QuerySecurity(pipe, r)
-def test_GetDomPwInfo(pipe, domain):
+def test_GetDomPwInfo(pipe, handle, domain):
print 'testing samr_GetDomPwInfo'
@@ -830,23 +829,23 @@ def test_LookupDomain(pipe, connect_handle, domain):
result = dcerpc.samr_LookupDomain(pipe, r)
- test_GetDomPwInfo(pipe, domain)
+ test_GetDomPwInfo(pipe, connect_handle, domain)
- test_OpenDomain(pipe, handle, result['sid'])
+ test_OpenDomain(pipe, connect_handle, result['sid'])
def test_EnumDomains(pipe, connect_handle):
print 'testing samr_EnumDomains'
r = {}
- r['connect_handle'] = handle
+ r['connect_handle'] = connect_handle
r['resume_handle'] = 0
r['buf_size'] = -1
result = dcerpc.samr_EnumDomains(pipe, r)
for domain in result['sam']['entries']:
- test_LookupDomain(pipe, handle, domain['name']['name'])
+ test_LookupDomain(pipe, connect_handle, domain['name']['name'])
def test_LongInt(pipe):
@@ -858,48 +857,18 @@ def test_LongInt(pipe):
result = dcerpc.samr_Connect(pipe, r)
-# Parse command line
-
-parser = OptionParser()
-
-parser.add_option("-b", "--binding", action="store", type="string",
- dest="binding")
-
-parser.add_option("-d", "--domain", action="store", type="string",
- dest="domain")
-
-parser.add_option("-u", "--username", action="store", type="string",
- dest="username")
-
-parser.add_option("-p", "--password", action="store", type="string",
- dest="password")
-
-(options, args) = parser.parse_args()
-
-if not options.binding:
- parser.error('You must supply a binding string')
-
-if not options.username or not options.password or not options.domain:
- parser.error('You must supply a domain, username and password')
-
-
-binding = options.binding
-domain = options.domain
-username = options.username
-password = options.password
-
-print 'Connecting...'
+def runtests(binding, domain, username, password):
-pipe = dcerpc.pipe_connect(binding,
- dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
- domain, username, password)
+ print 'Testing SAMR pipe'
-test_LongInt(pipe)
+ pipe = dcerpc.pipe_connect(binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ domain, username, password)
-handle = test_Connect(pipe)
+ test_LongInt(pipe)
-test_QuerySecurity(pipe, handle)
+ handle = test_Connect(pipe)
-test_EnumDomains(pipe, handle)
+ test_QuerySecurity(pipe, handle)
-print 'Done'
+ test_EnumDomains(pipe, handle)