r2728: Break arg parsing stuff out of samr.py into a standalone program.
authorTim Potter <tpot@samba.org>
Tue, 28 Sep 2004 12:49:05 +0000 (12:49 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:27 +0000 (12:59 -0500)
source/scripting/swig/torture/pytorture [new file with mode: 0755]
source/scripting/swig/torture/samr.py

diff --git a/source/scripting/swig/torture/pytorture b/source/scripting/swig/torture/pytorture
new file mode 100755 (executable)
index 0000000..89ecfba
--- /dev/null
@@ -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)
index 07bbaf3a93eed74a1b5d6a13cabba6d0483c0f51..ba650dfe75978357239433b559c15909a55ba51a 100755 (executable)
@@ -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)