From 1bcbc4afcf2f9984081652c1fbe50d329c86b3b5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 19:13:41 +0200 Subject: Allow command line options in the subunitrun script. (This used to be commit 524ec0796efebd48e7b5b2eb5fcc92ecc13c0071) --- source4/scripting/bin/subunitrun | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index 11ac426589..3730a15e1b 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -20,6 +20,26 @@ from subunit import SubunitTestRunner import sys from unittest import TestProgram +import optparse +import os +import param +import samba.getopt as options +import samba.tests + +parser = optparse.OptionParser("subunitrun [options] ") +credopts = options.CredentialsOptions(parser) +parser.add_option_group(credopts) +sambaopts = options.SambaOptions(parser) +parser.add_option_group(sambaopts) +parser.add_option_group(options.VersionOptions(parser)) + +args = parser.parse_args()[1] + +samba.tests.cmdline_loadparm = sambaopts.get_loadparm() +samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.cmdline_loadparm) + +import pdb +pdb.set_trace() runner = SubunitTestRunner() -TestProgram(module=None, argv=sys.argv, testRunner=runner) +program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner) -- cgit From 2cdfaedee203a726bddfb46fb10d9604de32a05f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 19:20:43 +0200 Subject: Make sure credentials are specified when running the Python winreg RPC tests. (This used to be commit 280339e3d126f5c72dc271051b72839fde0c5c9f) --- source4/scripting/bin/subunitrun | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index 3730a15e1b..fbbffde42c 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -38,8 +38,7 @@ args = parser.parse_args()[1] samba.tests.cmdline_loadparm = sambaopts.get_loadparm() samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.cmdline_loadparm) -import pdb -pdb.set_trace() +param.cvar.default_config = samba.tests.cmdline_loadparm runner = SubunitTestRunner() program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner) -- cgit From babdcc6135e6d3a91a9ddeae0555652026f09344 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 05:29:20 +0200 Subject: Use system python rather than smbpython. (This used to be commit d3df51cd01e53383dcc05923d248db03bc6f62e9) --- source4/scripting/bin/subunitrun | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index fbbffde42c..719a58d9e5 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -17,8 +17,10 @@ # along with this program. If not, see . # -from subunit import SubunitTestRunner import sys +sys.path.append("bin/python") + +from subunit import SubunitTestRunner from unittest import TestProgram import optparse import os -- cgit From 47d22189227c0dd6f2f370ade2cfb878eef0f240 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 05:45:49 +0200 Subject: Set sys.path for running inside source tree. (This used to be commit b507109bb676715f7d9616e13b0e19305e9c2559) --- source4/scripting/bin/minschema.py | 4 ++++ source4/scripting/bin/rpcclient | 4 ++++ source4/scripting/bin/samba3dump | 5 ++++- source4/scripting/bin/subunitrun | 4 +++- source4/scripting/bin/winreg.py | 4 ++++ 5 files changed, 19 insertions(+), 2 deletions(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py index fb9d7b05aa..6dd5b42aff 100755 --- a/source4/scripting/bin/minschema.py +++ b/source4/scripting/bin/minschema.py @@ -4,6 +4,10 @@ # import optparse + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba from samba import getopt as options import sys diff --git a/source4/scripting/bin/rpcclient b/source4/scripting/bin/rpcclient index 34efafdf73..aba4f9ddb3 100755 --- a/source4/scripting/bin/rpcclient +++ b/source4/scripting/bin/rpcclient @@ -1,6 +1,10 @@ #!/usr/bin/python import sys, os, string + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + from cmd import Cmd from optparse import OptionParser from pprint import pprint diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump index 8f56d423d8..d89667233f 100755 --- a/source4/scripting/bin/samba3dump +++ b/source4/scripting/bin/samba3dump @@ -7,7 +7,10 @@ import optparse import os, sys -sys.path.append(os.path.join(os.path.dirname(__file__), "../python")) + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import samba import samba.samba3 diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index 719a58d9e5..de11aba3cc 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -18,7 +18,9 @@ # import sys -sys.path.append("bin/python") + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") from subunit import SubunitTestRunner from unittest import TestProgram diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/bin/winreg.py index 1e39ee8f78..19d39e56ab 100755 --- a/source4/scripting/bin/winreg.py +++ b/source4/scripting/bin/winreg.py @@ -7,6 +7,10 @@ # import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + import winreg import optparse import samba.getopt as options -- cgit From 49706ab19bd3ffd6125639e6a7753b2350cf54e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 23:59:34 +0200 Subject: Move more modules inside of the samba package. (This used to be commit 9b39e99f48266a54ed0b8890c2efde218b4b118a) --- source4/scripting/bin/subunitrun | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index de11aba3cc..6f1086ad37 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -26,7 +26,7 @@ from subunit import SubunitTestRunner from unittest import TestProgram import optparse import os -import param +from samba import param import samba.getopt as options import samba.tests -- cgit From 7cfcec2e9d8ea5ad9619848f60c846e805fb15a2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 May 2008 02:44:42 +0200 Subject: Fix imports for minschema. (This used to be commit bda223a49e6bdeda68518cba27bc92df33784939) --- source4/scripting/bin/minschema.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py index 6dd5b42aff..111557126d 100755 --- a/source4/scripting/bin/minschema.py +++ b/source4/scripting/bin/minschema.py @@ -5,6 +5,8 @@ import optparse +import os, sys + # Find right directory when running from source tree sys.path.insert(0, "bin/python") -- cgit From 27005cb7a2182c50c8bf9e683de1bea2613a3078 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 22 May 2008 05:13:31 +0200 Subject: Convert samr test to python. (This used to be commit 88d473b202e82b462ef82ffdeb4f1710918ffda5) --- source4/scripting/bin/samr.py | 114 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 source4/scripting/bin/samr.py (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/samr.py b/source4/scripting/bin/samr.py new file mode 100755 index 0000000000..118cf759fe --- /dev/null +++ b/source4/scripting/bin/samr.py @@ -0,0 +1,114 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Unix SMB/CIFS implementation. +# Copyright © Jelmer Vernooij 2008 +# +# Based on samr.js © Andrew Tridgell +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import sys + +sys.path.insert(0, "bin/python") + +from samba.dcerpc import samr, security + +def FillUserInfo(samr, dom_handle, users, level): + """fill a user array with user information from samrQueryUserInfo""" + for i in range(len(users)): + user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx) + info = samr.QueryUserInfo(user_handle, level) + info.name = users[i].name + info.idx = users[i].idx + users[i] = info + samr.Close(user_handle) + +def toArray((handle, array, num_entries)): + ret = [] + for x in range(num_entries): + ret.append((array.entries[x].idx, array.entries[x].name)) + return ret + + +def test_Connect(samr): + """test the samr_Connect interface""" + print "Testing samr_Connect" + return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED) + +def test_LookupDomain(samr, handle, domain): + """test the samr_LookupDomain interface""" + print "Testing samr_LookupDomain" + return samr.LookupDomain(handle, domain) + +def test_OpenDomain(samr, handle, sid): + """test the samr_OpenDomain interface""" + print "Testing samr_OpenDomain" + return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid) + +def test_EnumDomainUsers(samr, dom_handle): + """test the samr_EnumDomainUsers interface""" + print "Testing samr_EnumDomainUsers" + users = toArray(samr.EnumDomainUsers(dom_handle, 0, 0, -1)) + print "Found %d users" % len(users) + for idx, user in users: + print "\t%s\t(%d)" % (user, idx) + +def test_EnumDomainGroups(samr, dom_handle): + """test the samr_EnumDomainGroups interface""" + print "Testing samr_EnumDomainGroups" + groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0, -1)) + print "Found %d groups" % len(groups) + for idx, group in groups: + print "\t" + group + "\t(" + idx + ")" + +def test_domain_ops(samr, dom_handle): + """test domain specific ops""" + test_EnumDomainUsers(samr, dom_handle) + test_EnumDomainGroups(samr, dom_handle) + +def test_EnumDomains(samr, handle): + """test the samr_EnumDomains interface""" + print "Testing samr_EnumDomains" + + domains = toArray(samr.EnumDomains(handle, 0, -1)) + print "Found %d domains" % len(domains) + for idx, domain in domains: + print "\t%s (%d)" % (domain, idx) + for idx, domain in domains: + print "Testing domain %s" % domain + sid = samr.LookupDomain(handle, domain) + dom_handle = test_OpenDomain(samr, handle, sid) + test_domain_ops(samr, dom_handle) + samr.Close(dom_handle) + +if len(sys.argv) != 2: + print "Usage: samr.js " + sys.exit(1) + +binding = sys.argv[1] + +print "Connecting to " + binding +try: + samr = samr.samr(binding) +except Exception, e: + print "Failed to connect to %s: %s" % (binding, e.message) + sys.exit(1) + +handle = test_Connect(samr) +test_EnumDomains(samr, handle) +samr.Close(handle) + +print "All OK" -- cgit From 5eed56d0ad5245a346ea564bc34e882828394611 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 May 2008 15:10:35 +0200 Subject: Fix bugs in samr python tests. (This used to be commit 09c6b106ac144820b8c072bda4dad3d8e2145ff0) --- source4/scripting/bin/samr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/scripting/bin') diff --git a/source4/scripting/bin/samr.py b/source4/scripting/bin/samr.py index 118cf759fe..e91b5bc312 100755 --- a/source4/scripting/bin/samr.py +++ b/source4/scripting/bin/samr.py @@ -24,7 +24,7 @@ import sys sys.path.insert(0, "bin/python") -from samba.dcerpc import samr, security +from samba.dcerpc import samr, security, lsa def FillUserInfo(samr, dom_handle, users, level): """fill a user array with user information from samrQueryUserInfo""" @@ -69,10 +69,10 @@ def test_EnumDomainUsers(samr, dom_handle): def test_EnumDomainGroups(samr, dom_handle): """test the samr_EnumDomainGroups interface""" print "Testing samr_EnumDomainGroups" - groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0, -1)) + groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0)) print "Found %d groups" % len(groups) for idx, group in groups: - print "\t" + group + "\t(" + idx + ")" + print "\t%s\t(%d)" % (group, idx) def test_domain_ops(samr, dom_handle): """test domain specific ops""" -- cgit