OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python2.7
/
dist-packages
/
samba
/
tests
/
samba_tool
Server IP: 10.0.0.4
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/03/2022 06:37:41 AM
rwxr-xr-x
📄
__init__.py
722 bytes
07/04/2017 10:05:25 AM
rw-r--r--
📄
__init__.pyc
154 bytes
02/03/2022 06:37:41 AM
rw-r--r--
📄
base.py
4.73 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
base.pyc
4.99 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
dnscmd.py
36.08 KB
11/02/2017 11:38:36 AM
rw-r--r--
📄
dnscmd.pyc
18.1 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
fsmo.py
2.05 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
fsmo.pyc
1.73 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
gpo.py
4.07 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
gpo.pyc
4.58 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
group.py
7.34 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
group.pyc
6.01 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
join.py
1.25 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
join.pyc
1.1 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
ntacl.py
6.3 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
ntacl.pyc
5.96 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
processes.py
1.64 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
processes.pyc
1.64 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
rodc.py
6.79 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
rodc.pyc
6.86 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
sites.py
5.66 KB
12/22/2017 08:40:58 PM
rw-r--r--
📄
sites.pyc
4.85 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
timecmd.py
1.9 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
timecmd.pyc
1.83 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
user.py
27.55 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
user.pyc
18.25 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
user_check_password_script.py
4.8 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
user_check_password_script.pyc
3.49 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
user_virtualCryptSHA.py
21.6 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
user_virtualCryptSHA.pyc
15.72 KB
02/03/2022 06:37:41 AM
rw-r--r--
📄
user_wdigest.py
15.65 KB
07/04/2017 10:05:25 AM
rw-r--r--
📄
user_wdigest.pyc
13.93 KB
02/03/2022 06:37:41 AM
rw-r--r--
Editing: base.py
Close
# Unix SMB/CIFS implementation. # Copyright (C) Sean Dague <sdague@linux.vnet.ibm.com> 2011 # # 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 <http://www.gnu.org/licenses/>. # This provides a wrapper around the cmd interface so that tests can # easily be built on top of it and have minimal code to run basic tests # of the commands. A list of the environmental variables can be found in # ~/selftest/selftest.pl # # These can all be accesses via os.environ["VARIBLENAME"] when needed import random import string from samba.auth import system_session from samba.samdb import SamDB from cStringIO import StringIO from samba.netcmd.main import cmd_sambatool import samba.tests class SambaToolCmdTest(samba.tests.BlackboxTestCase): def getSamDB(self, *argv): """a convenience function to get a samdb instance so that we can query it""" # We build a fake command to get the options created the same # way the command classes do it. It would be better if the command # classes had a way to more cleanly do this, but this lets us write # tests for now cmd = cmd_sambatool.subcommands["user"].subcommands["setexpiry"] parser, optiongroups = cmd._create_parser("user") opts, args = parser.parse_args(list(argv)) # Filter out options from option groups args = args[1:] kwargs = dict(opts.__dict__) for option_group in parser.option_groups: for option in option_group.option_list: if option.dest is not None: del kwargs[option.dest] kwargs.update(optiongroups) H = kwargs.get("H", None) sambaopts = kwargs.get("sambaopts", None) credopts = kwargs.get("credopts", None) lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), credentials=creds, lp=lp) return samdb def runcmd(self, name, *args): """run a single level command""" cmd = cmd_sambatool.subcommands[name] cmd.outf = StringIO() cmd.errf = StringIO() result = cmd._run("samba-tool %s" % name, *args) return (result, cmd.outf.getvalue(), cmd.errf.getvalue()) def runsubcmd(self, name, sub, *args): """run a command with sub commands""" # The reason we need this function separate from runcmd is # that the .outf StringIO assignment is overridden if we use # runcmd, so we can't capture stdout and stderr cmd = cmd_sambatool.subcommands[name].subcommands[sub] cmd.outf = StringIO() cmd.errf = StringIO() result = cmd._run("samba-tool %s %s" % (name, sub), *args) return (result, cmd.outf.getvalue(), cmd.errf.getvalue()) def assertCmdSuccess(self, exit, out, err, msg=""): self.assertIsNone(exit, msg="exit[%s] stdout[%s] stderr[%s]: %s" % ( exit, out, err, msg)) def assertCmdFail(self, val, msg=""): self.assertIsNotNone(val, msg) def assertMatch(self, base, string, msg=""): self.assertTrue(string in base, msg) def randomName(self, count=8): """Create a random name, cap letters and numbers, and always starting with a letter""" name = random.choice(string.ascii_uppercase) name += ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase+ string.digits) for x in range(count - 1)) return name def randomPass(self, count=16): name = random.choice(string.ascii_uppercase) name += random.choice(string.digits) name += random.choice(string.ascii_lowercase) name += ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase+ string.digits) for x in range(count - 3)) return name def randomXid(self): # pick some hopefully unused, high UID/GID range to avoid interference # from the system the test runs on xid = random.randint(4711000, 4799000) return xid def assertWithin(self, val1, val2, delta, msg=""): """Assert that val1 is within delta of val2, useful for time computations""" self.assertTrue(((val1 + delta) > val2) and ((val1 - delta) < val2), msg)