Example #1
0
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
"""Samba Python tests."""

import os
import ldb
import samba
import samba.auth
from samba import param
from samba.samdb import SamDB
import subprocess
import tempfile

samba.ensure_external_module("testtools", "testtools")

# Other modules import these two classes from here, for convenience:
from testtools.testcase import (
    TestCase as TesttoolsTestCase,
    TestSkipped,
)


class TestCase(TesttoolsTestCase):
    """A Samba test case."""
    def setUp(self):
        super(TestCase, self).setUp()
        test_debug_level = os.getenv("TEST_DEBUG_LEVEL")
        if test_debug_level is not None:
            test_debug_level = int(test_debug_level)
Example #2
0
# (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/>.


import optparse
import sys
sys.path.insert(0, "bin/python")
import samba
samba.ensure_external_module("testtools", "testtools")
samba.ensure_external_module("subunit", "subunit/python")

import samba.getopt as options
import base64

from ldb import LdbError, SCOPE_BASE
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_DELETE
from samba.dcerpc import security, misc, drsblobs
from samba.ndr import ndr_unpack, ndr_pack

from samba.auth import system_session
from samba import gensec, sd_utils
from samba.samdb import SamDB
from samba.credentials import Credentials
import subprocess

from samba.netcmd.main import cmd_sambatool

# We try to use the test infrastructure of Samba 4.3+, but if it
# doesn't work, we are probably in a back-ported patch and trying to
# run on 4.1 or something.
#
# Don't copy this horror into ordinary tests -- it is special for
# performance tests that want to apply to old versions.
try:
    from samba.tests.subunitrun import SubunitOptions, TestProgram
    ANCIENT_SAMBA = False
except ImportError:
    ANCIENT_SAMBA = True
    samba.ensure_external_module("testtools", "testtools")
    samba.ensure_external_module("subunit", "subunit/python")
    from subunit.run import SubunitTestRunner
    import unittest

parser = optparse.OptionParser(
    "ad_dc_provision_performance.py [options] <host>")
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
parser.add_option_group(options.VersionOptions(parser))

if not ANCIENT_SAMBA:
    subunitopts = SubunitOptions(parser)
    parser.add_option_group(subunitopts)

# use command line creds if available
Example #4
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""Samba Python tests."""

import os
import ldb
import samba
import samba.auth
from samba import param
from samba.samdb import SamDB
from samba import credentials
import subprocess
import tempfile

samba.ensure_external_module("mimeparse", "mimeparse")
samba.ensure_external_module("extras", "extras")
samba.ensure_external_module("testtools", "testtools")

# Other modules import these two classes from here, for convenience:
from testtools.testcase import (
    TestCase as TesttoolsTestCase,
    TestSkipped,
    )


class TestCase(TesttoolsTestCase):
    """A Samba test case."""

    def setUp(self):
        super(TestCase, self).setUp()
Example #5
0
# 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/>.
#
"""Source level Python tests."""

import errno
import os
import re
import warnings

import samba

samba.ensure_external_module("pep8", "pep8")
import pep8

from samba.tests import (
    TestCase, )


def get_python_source_files():
    """Iterate over all Python source files."""
    library_dir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..", "..", "samba"))
    assert os.path.isdir(library_dir), library_dir

    for root, dirs, files in os.walk(library_dir):
        for f in files:
            if f.endswith(".py"):
Example #6
0
# 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/>.
#

"""Source level Python tests."""

import errno
import os
import re
import warnings

import samba
samba.ensure_external_module("pep8", "pep8")
import pep8

from samba.tests import (
    TestCase,
    )



def get_python_source_files():
    """Iterate over all Python source files."""
    library_dir = os.path.join(os.path.dirname(__file__), "..", "..", "samba")

    for root, dirs, files in os.walk(library_dir):
        for f in files:
            if f.endswith(".py"):
Example #7
0
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# make sure the script dies immediately when hitting control-C,
# rather than raising KeyboardInterrupt. As we do all database
# operations using transactions, this is safe.
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

import optparse
import samba
import sys
import samba.tests
samba.ensure_external_module("subunit", "subunit/python")
import subunit.run

try:
   from subunit.run import TestProgram as BaseTestProgram
except ImportError:
   from unittest import TestProgram as BaseTestProgram


class SubunitOptions(optparse.OptionGroup):
    """Command line options for subunit test runners."""

    def __init__(self, parser):
        optparse.OptionGroup.__init__(self, parser, "Subunit Options")
        self.add_option('-l', '--list', dest='listtests', default=False,
                  help='List tests rather than running them.',
# 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/>.
#

# make sure the script dies immediately when hitting control-C,
# rather than raising KeyboardInterrupt. As we do all database
# operations using transactions, this is safe.
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

import optparse
import samba
import sys
samba.ensure_external_module("mimeparse", "mimeparse")
samba.ensure_external_module("extras", "extras")
samba.ensure_external_module("testtools", "testtools")
samba.ensure_external_module("subunit", "subunit/python")
import subunit.run

try:
    from subunit.run import TestProgram as BaseTestProgram
except ImportError:
    from unittest import TestProgram as BaseTestProgram


class SubunitOptions(optparse.OptionGroup):
    """Command line options for subunit test runners."""
    def __init__(self, parser):
        optparse.OptionGroup.__init__(self, parser, "Subunit Options")
Example #9
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""Samba Python tests."""

import os
import ldb
import samba
import samba.auth
from samba import param
from samba.samdb import SamDB
import subprocess
import tempfile

samba.ensure_external_module("testtools", "testtools")

# Other modules import these two classes from here, for convenience:
from testtools.testcase import (
    TestCase as TesttoolsTestCase,
    TestSkipped,
    )


class TestCase(TesttoolsTestCase):
    """A Samba test case."""

    def setUp(self):
        super(TestCase, self).setUp()
        test_debug_level = os.getenv("TEST_DEBUG_LEVEL")
        if test_debug_level is not None:
Example #10
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""Samba Python tests."""

import os
import ldb
import samba
import samba.auth
from samba import param
from samba.samdb import SamDB
import subprocess
import tempfile

samba.ensure_external_module("mimeparse", "mimeparse")
samba.ensure_external_module("extras", "extras")
samba.ensure_external_module("testtools", "testtools")

# Other modules import these two classes from here, for convenience:
from testtools.testcase import (
    TestCase as TesttoolsTestCase,
    TestSkipped,
    )


class TestCase(TesttoolsTestCase):
    """A Samba test case."""

    def setUp(self):
        super(TestCase, self).setUp()