Ejemplo n.º 1
0
def main(argv, prepare_args=prepare_argv, find_tests=find_tests):
    """CLI entry point to adapt a test run to parallel testing."""
    child_args = prepare_argv(argv)
    test_ids = find_tests(argv)
    # We could create a proxy object per test id if desired in future)
    def parallelise_tests(suite):
        test_ids = list(suite)[0]._test_ids
        count = concurrency()
        partitions = partition_tests(test_ids, count)
        return [ListTestCase(partition, child_args) for partition in partitions]
    suite = ConcurrentTestSuite(ListTestCase(test_ids, None), parallelise_tests)
    if '--subunit' in argv:
        runner = SubunitTestRunner(sys.stdout)
        result = runner.run(suite)
    else:
        stream = unicode_output_stream(sys.stdout)
        result = TextTestResult(stream)
        result.startTestRun()
        try:
            suite.run(result)
        finally:
            result.stopTestRun()
    if result.wasSuccessful():
        return 0
    return -1
Ejemplo n.º 2
0
def main(argv, prepare_args=prepare_argv, find_tests=find_tests):
    """CLI entry point to adapt a test run to parallel testing."""
    child_args = prepare_argv(argv)
    test_ids = find_tests(argv)

    # We could create a proxy object per test id if desired in future)
    def parallelise_tests(suite):
        test_ids = list(suite)[0]._test_ids
        count = concurrency()
        partitions = partition_tests(test_ids, count)
        return [
            ListTestCase(partition, child_args) for partition in partitions
        ]

    suite = ConcurrentTestSuite(ListTestCase(test_ids, None),
                                parallelise_tests)
    if '--subunit' in argv:
        runner = SubunitTestRunner(sys.stdout)
        result = runner.run(suite)
    else:
        stream = unicode_output_stream(sys.stdout)
        result = TextTestResult(stream)
        result.startTestRun()
        try:
            suite.run(result)
        finally:
            result.stopTestRun()
    if result.wasSuccessful():
        return 0
    return -1
Ejemplo n.º 3
0
 def test_includes_timing_output(self):
     io = BytesIO()
     runner = SubunitTestRunner(stream=io)
     test = PlaceHolder('name')
     runner.run(test)
     client = TimeCollectingTestResult()
     io.seek(0)
     subunit.TestProtocolServer(client).readFrom(io)
     self.assertTrue(len(client.time_called) > 0)
Ejemplo n.º 4
0
 def test_includes_timing_output(self):
     bytestream = io.BytesIO()
     runner = SubunitTestRunner(stream=bytestream)
     test = PlaceHolder('name')
     runner.run(test)
     bytestream.seek(0)
     eventstream = StreamResult()
     subunit.ByteStreamToStreamResult(bytestream).run(eventstream)
     timestamps = [event[-1] for event in eventstream._events
         if event is not None]
     self.assertNotEqual([], timestamps)
Ejemplo n.º 5
0
 def test_includes_timing_output(self):
     io = BytesIO()
     runner = SubunitTestRunner(stream=io)
     test = PlaceHolder('name')
     runner.run(test)
     io.seek(0)
     eventstream = StreamResult()
     subunit.ByteStreamToStreamResult(io).run(eventstream)
     timestamps = [event[-1] for event in eventstream._events
         if event is not None]
     self.assertNotEqual([], timestamps)
Ejemplo n.º 6
0
 def test_enumerates_tests_before_run(self):
     io = BytesIO()
     runner = SubunitTestRunner(stream=io)
     test1 = PlaceHolder('name1')
     test2 = PlaceHolder('name2')
     case = unittest.TestSuite([test1, test2])
     runner.run(case)
     io.seek(0)
     eventstream = StreamResult()
     subunit.ByteStreamToStreamResult(io).run(eventstream)
     self.assertEqual([
         ('status', 'name1', 'exists'),
         ('status', 'name2', 'exists'),
         ], [event[:3] for event in eventstream._events[:2]])
Ejemplo n.º 7
0
 def test_list_errors_if_errors_from_list_test(self):
     bytestream = io.BytesIO()
     runner = SubunitTestRunner(stream=bytestream)
     def list_test(test):
         return [], ['failed import']
     self.patch(run, 'list_test', list_test)
     exc = self.assertRaises(SystemExit, runner.list, None)
     self.assertEqual((2,), exc.args)
Ejemplo n.º 8
0
 def test_list_includes_loader_errors(self):
     bytestream = io.BytesIO()
     runner = SubunitTestRunner(stream=bytestream)
     def list_test(test):
         return [], []
     class Loader(object):
         errors = ['failed import']
     loader = Loader()
     self.patch(run, 'list_test', list_test)
     exc = self.assertRaises(SystemExit, runner.list, None, loader=loader)
     self.assertEqual((2,), exc.args)
Ejemplo n.º 9
0
 def test_enumerates_tests_before_run(self):
     io = BytesIO()
     runner = SubunitTestRunner(stream=io)
     test1 = PlaceHolder('name1')
     test2 = PlaceHolder('name2')
     case = unittest.TestSuite([test1, test2])
     runner.run(case)
     io.seek(0)
     eventstream = StreamResult()
     subunit.ByteStreamToStreamResult(io).run(eventstream)
     self.assertEqual([
         ('status', 'name1', 'exists'),
         ('status', 'name2', 'exists'),
     ], [event[:3] for event in eventstream._events[:2]])
Ejemplo n.º 10
0
        dn_tokengroups = []
        for sid in res[0]['tokenGroupsGlobalAndUniversal']:
            sid = ndr_unpack(samba.dcerpc.security.dom_sid, sid)
            res3 = self.admin_ldb.search(base="<SID=%s>" % sid,
                                         scope=ldb.SCOPE_BASE,
                                         attrs=[])
            tokenGroupsSet.add(res3[0].dn.get_casefold())

        if len(T.difference(tokenGroupsSet)):
            self.fail(msg="additional calculated: %s" %
                      T.difference(tokenGroupsSet))

        if len(tokenGroupsSet.difference(T)):
            self.fail(msg="additional tokenGroupsGlobalAndUniversal: %s" %
                      tokenGroupsSet.difference(T))


if not "://" in url:
    if os.path.isfile(url):
        url = "tdb://%s" % url
    else:
        url = "ldap://%s" % url

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(StaticTokenTest)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(DynamicTokenTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 11
0
                self.assertTrue("msDS-isRODC" in ldb_msg)


if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

ldb_options = []
if host.startswith("ldap://"):
    # user 'paged_search' module when connecting remotely
    ldb_options = ["modules:paged_searches"]

ldb = SamDB(host,
            credentials=creds,
            session_info=system_session(lp),
            lp=lp,
            options=ldb_options)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(SchemaTests)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(SchemaTests_msDS_IntId)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(SchemaTests_msDS_isRODC)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 12
0
        # So now delete the object and check that
        # we can see the object but deleted when admin
        # we just see the objectGUID when simple user
        delete_force(self.ldb_admin, ouname)

        res = self.ldb_simple.search(
            self.base_dn,
            expression="(objectClass=organizationalUnit)",
            controls=[control1])
        self.assertEqual(len(res), 1)
        guid2 = str(ndr_unpack(misc.GUID, res[0].get("objectGUID")[0]))
        self.assertEqual(guid2, guid)
        self.assertEqual(str(res[0].dn), "")


ldb = SamDB(ldapshost,
            credentials=creds,
            session_info=system_session(lp),
            lp=lp)

runner = SubunitTestRunner()
rc = 0
#
if not runner.run(unittest.makeSuite(SimpleDirsyncTests)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(ExtendedDirsyncTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 13
0
        self.delete_deleted(ldb, usr1)
        self.delete_deleted(ldb, usr2)
        self.delete_deleted(ldb, grp1)
        self.delete_deleted(ldb, sit1)
        self.delete_deleted(ldb, ss1)
        self.delete_deleted(ldb, srv1)
        self.delete_deleted(ldb, srv2)

        self.assertTrue("CN=Deleted Objects" in str(objDeleted1.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted2.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted3.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted4.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted5.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted6.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted7.dn))

if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(BasicDeleteTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 14
0
parser.add_option_group(sambaopts)
parser.add_option_group(options.VersionOptions(parser))

# use command line creds if available
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
opts, args = parser.parse_args()

if len(args) < 1:
    parser.print_usage()
    sys.exit(1)

host = args[0]

lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)

if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(MatchRulesTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
                     
Ejemplo n.º 15
0
        ctl[1] = "1"
        ctl[2] = "1"
        ctl[3] = "10000"
        control1 = str(":".join(ctl))

        # So now delete the object and check that
        # we can see the object but deleted when admin
        # we just see the objectGUID when simple user
        delete_force(self.ldb_admin, ouname)

        res = self.ldb_simple.search(self.base_dn,
                                    expression="(objectClass=organizationalUnit)",
                                    controls=[control1])
        self.assertEqual(len(res), 1)
        guid2 = str(ndr_unpack(misc.GUID,res[0].get("objectGUID")[0]))
        self.assertEqual(guid2, guid)
        self.assertEqual(str(res[0].dn), "")


ldb = SamDB(ldapshost, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0
#
if not runner.run(unittest.makeSuite(SimpleDirsyncTests)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(ExtendedDirsyncTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 16
0
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
parser.add_option_group(options.VersionOptions(parser))

# use command line creds if available
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
opts, args = parser.parse_args()

if len(args) < 1:
    parser.print_usage()
    sys.exit(1)

host = args[0]

lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)

if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(MatchRulesTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 17
0
        session = gensec_server.session_info()

        token = session.security_token
        pac_sids = []
        for s in token.sids:
            pac_sids.append(str(s))

        sidset1 = set(pac_sids)
        sidset2 = set(self.user_sids)
        if len(sidset1.difference(sidset2)):
            print("token sids don't match")
            print("difference : %s" % sidset1.difference(sidset2))
            self.fail(
                msg="calculated groups don't match against user PAC tokenGroups"
            )


if not "://" in url:
    if os.path.isfile(url):
        url = "tdb://%s" % url
    else:
        url = "ldap://%s" % url

samdb = SamDB(url, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(TokenTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 18
0
        # attribute
        m = Message()
        m.dn = Dn(ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        m["description"] = MessageElement("updated urgent attributes test description",
                                          FLAG_MOD_REPLACE, "description")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when deleting
        self.delete_force(self.ldb, "cn=user UrgAttr test,cn=users," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])


if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host


ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp,
            global_schema=False)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(UrgentReplicationTests)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 19
0
    def test_22_01_delete_all_groups(self):
        for i in range(self.state.n_groups):
            self.ldb.delete("cn=g%d,%s" % (i, self.ou_groups))
        self.state.n_groups = 0
        self.state.active_links = set()

    # XXX assert the state is as we think, using searches

    def test_23_01_delete_users_5900_after_groups(self):
        # we do not delete everything because it takes too long
        n = 4 * DELETE_BATCH_SIZE
        self._test_delete_many_users(n=n)

    test_24_02_join_after_partial_cleanup = _test_join


if "://" not in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host


if ANCIENT_SAMBA:
    runner = SubunitTestRunner()
    if not runner.run(unittest.makeSuite(UserTests)).wasSuccessful():
        sys.exit(1)
    sys.exit(0)
else:
    TestProgram(module=__name__, opts=subunitopts)
Ejemplo n.º 20
0
        res = self.ldb.search(self.user_sid_dn, scope=ldb.SCOPE_BASE, attrs=["tokenGroupsGlobalAndUniversal"])
        self.assertEquals(len(res), 1)

        dn_tokengroups = []
        for sid in res[0]['tokenGroupsGlobalAndUniversal']:
            sid = ndr_unpack(samba.dcerpc.security.dom_sid, sid)
            res3 = self.admin_ldb.search(base="<SID=%s>" % sid, scope=ldb.SCOPE_BASE,
                                         attrs=[])
            tokenGroupsSet.add(res3[0].dn.get_casefold())

        if len(T.difference(tokenGroupsSet)):
            self.fail(msg="additional calculated: %s" % T.difference(tokenGroupsSet))

        if len(tokenGroupsSet.difference(T)):
            self.fail(msg="additional tokenGroupsGlobalAndUniversal: %s" % tokenGroupsSet.difference(T))

if not "://" in url:
    if os.path.isfile(url):
        url = "tdb://%s" % url
    else:
        url = "ldap://%s" % url

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(StaticTokenTest)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(DynamicTokenTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 21
0
        self.add_computer_ldap(computername,
                               others={"userAccountControl": [str(UF_WORKSTATION_TRUST_ACCOUNT)]},
                               samdb=self.admin_samdb)
        res = self.admin_samdb.search("%s" % self.base_dn,
                                      expression="(&(objectClass=computer)(samAccountName=%s$))" % computername,
                                      scope=SCOPE_SUBTREE,
                                      attrs=[""])


        m = ldb.Message()
        m.dn = ldb.Dn(self.admin_samdb, "<SID=%s-%d>" % (str(self.domain_sid),
                                                         security.DOMAIN_RID_ADMINS))
        m["member"]= ldb.MessageElement(
            [str(res[0].dn)], ldb.FLAG_MOD_ADD,
            "member")
        self.admin_samdb.modify(m)

        m = ldb.Message()
        m.dn = res[0].dn
        m["primaryGroupID"]= ldb.MessageElement(
            [str(security.DOMAIN_RID_ADMINS)], ldb.FLAG_MOD_REPLACE,
            "primaryGroupID")
        self.admin_samdb.modify(m)


runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(UserAccountControlTests)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 22
0
    def run(self, **kwargs):
        """Run the test suite.

        It allows running any unittest.TestSuite and getting its
        execution status.

        By default, it runs the suite defined as instance attribute.
        It can be overriden by passing name as arg. It must
        conform with TestLoader.loadTestsFromName().

        It sets the following attributes required to push the results
        to DB:

            * result,
            * start_time,
            * stop_time,
            * details.

        Args:
            kwargs: Arbitrary keyword arguments.

        Return:
            TestCase.EX_OK if any TestSuite has been run
            TestCase.EX_RUN_ERROR otherwise.
        """
        try:
            name = kwargs["name"]
            try:
                self.suite = unittest.TestLoader().loadTestsFromName(name)
            except ImportError:
                self.__logger.error("Can not import %s", name)
                return testcase.TestCase.EX_RUN_ERROR
        except KeyError:
            pass
        try:
            assert self.suite
            self.start_time = time.time()
            if not os.path.isdir(self.res_dir):
                os.makedirs(self.res_dir)
            stream = BytesIO()
            result = SubunitTestRunner(stream=stream,
                                       verbosity=2).run(self.suite).decorated
            self.generate_stats(stream)
            self.generate_xunit(stream)
            with open(f'{self.res_dir}/subunit_stream', 'wb') as subfd:
                stream.seek(0)
                shutil.copyfileobj(stream, subfd)
            self.generate_html(f'{self.res_dir}/subunit_stream')
            self.stop_time = time.time()
            self.details = {
                "testsRun": result.testsRun,
                "failures": len(result.failures),
                "errors": len(result.errors)
            }
            self.result = 100 * (
                (result.testsRun -
                 (len(result.failures) + len(result.errors))) /
                result.testsRun)
            return testcase.TestCase.EX_OK
        except AssertionError:
            self.__logger.error("No suite is defined")
            return testcase.TestCase.EX_RUN_ERROR
        except ZeroDivisionError:
            self.__logger.error("No test has been run")
            return testcase.TestCase.EX_RUN_ERROR
        except Exception:  # pylint: disable=broad-except
            self.__logger.exception("something wrong occurs")
            return testcase.TestCase.EX_RUN_ERROR
Ejemplo n.º 23
0
        session = gensec_server.session_info()

        token = session.security_token
        pac_sids = []
        for s in token.sids:
            pac_sids.append(str(s))

        sidset1 = set(pac_sids)
        sidset2 = set(self.user_sids)
        if len(sidset1.difference(sidset2)):
            print("token sids don't match")
            print("tokengroups: %s" % tokengroups)
            print("calculated : %s" % sids);
            print("difference : %s" % sidset1.difference(sidset2))
            self.fail(msg="calculated groups don't match against user PAC tokenGroups")


if not "://" in url:
    if os.path.isfile(url):
        url = "tdb://%s" % url
    else:
        url = "ldap://%s" % url

samdb = SamDB(url, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(TokenTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 24
0
                              attrs=["serverReferenceBL","msDS-isRODC"], controls=["search_options:1:2"])
        for ldb_msg in res:
            if "serverReferenceBL" not in ldb_msg:
                print("Computer entry %s doesn't have a serverReferenceBL attribute" % ldb_msg['dn'])
            else:
                self.assertTrue("msDS-isRODC" in ldb_msg)

if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

ldb_options = []
if host.startswith("ldap://"):
    # user 'paged_search' module when connecting remotely
    ldb_options = ["modules:paged_searches"]

ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp, options=ldb_options)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(SchemaTests)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(SchemaTests_msDS_IntId)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(SchemaTests_msDS_isRODC)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 25
0
    def test_search_01000(self):
        self.run_search_bundle(1000, self.ldb_admin)

    def test_search2_01000(self):
        # allow the user to see objects but not attributes, all attributes will be filtered out
        mod = "(A;;LC;;;%s)(D;;RP;;;%s)" % (str(
            self.user_sid), str(self.user_sid))
        self.sd_utils.dacl_add_ace("CN=Users,%s" % self.base_dn, mod)
        self.run_search_bundle(1000, self.ldb_user)


# Important unit running information

if not "://" in host:
    host = "ldap://%s" % host

ldb_options = ["modules:paged_searches"]
ldb = SamDB(host,
            credentials=creds,
            session_info=system_session(),
            lp=lp,
            options=ldb_options)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(SpeedTestAddDel)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(AclSearchSpeedTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 26
0
            "updated urgent attributes test description", FLAG_MOD_REPLACE,
            "description")
        ldb.modify(m)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])

        # urgent replication should NOT be enabled when deleting
        self.delete_force(self.ldb,
                          "cn=user UrgAttr test,cn=users," + self.base_dn)
        res = self.ldb.load_partition_usn(self.base_dn)
        self.assertNotEquals(res["uSNHighest"], res["uSNUrgent"])


if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

ldb = SamDB(host,
            credentials=creds,
            session_info=system_session(lp),
            lp=lp,
            global_schema=False)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(UrgentReplicationTests)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 27
0
            self.ldb.add_ldif(ldif)
        except LdbError, (num, _):
            self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)

        # add object with SID instead of DN
        object_name4 = "obj-DN-Binary4" + time.strftime("%s", time.gmtime())
        ldif = self._get_object_ldif(object_name4, self.dn_binary_class_name, self.dn_binary_class_ldap_display_name,
                               self.dn_binary_attribute, ": B:4:1234:<SID=%s>" % self.ldb.get_domain_sid())
        try:
            self.ldb.add_ldif(ldif)
        except LdbError, (num, _):
            self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)

        # add object with random string instead of DN
        object_name5 = "obj-DN-Binary5" + time.strftime("%s", time.gmtime())
        ldif = self._get_object_ldif(object_name5, self.dn_binary_class_name, self.dn_binary_class_ldap_display_name,
                               self.dn_binary_attribute, ": B:4:1234:randomSTRING")
        try:
            self.ldb.add_ldif(ldif)
        except LdbError, (num, _):
            self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)
        pass

ldb = samba.tests.connect_samdb(host, credentials=creds, session_info=system_session(lp), lp=lp)
runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(SyntaxTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 28
0
        self.delete_deleted(ldb, usr1)
        self.delete_deleted(ldb, usr2)
        self.delete_deleted(ldb, grp1)
        self.delete_deleted(ldb, sit1)
        self.delete_deleted(ldb, ss1)
        self.delete_deleted(ldb, srv1)
        self.delete_deleted(ldb, srv2)

        self.assertTrue("CN=Deleted Objects" in str(objDeleted1.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted2.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted3.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted4.dn))
        self.assertTrue("CN=Deleted Objects" in str(objDeleted5.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted6.dn))
        self.assertFalse("CN=Deleted Objects" in str(objDeleted7.dn))

if not "://" in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

ldb = SamDB(host, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(BasicDeleteTests)).wasSuccessful():
    rc = 1

sys.exit(rc)
Ejemplo n.º 29
0
        creds_tmp.set_workstation(creds.get_workstation())
        creds_tmp.set_gensec_features(creds_tmp.get_gensec_features()
                                      | gensec.FEATURE_SEAL)
        ldb_target = SamDB(url=host, credentials=creds_tmp, lp=lp)
        return ldb_target

    def test_search_01000(self):
        self.run_search_bundle(1000, self.ldb_admin)

    def test_search2_01000(self):
        # allow the user to see objects but not attributes, all attributes will be filtered out
        mod = "(A;;LC;;;%s)(D;;RP;;;%s)" % (str(self.user_sid), str(self.user_sid))
        self.sd_utils.dacl_add_ace("CN=Users,%s" % self.base_dn, mod)
        self.run_search_bundle(1000, self.ldb_user)

# Important unit running information

if not "://" in host:
    host = "ldap://%s" % host

ldb_options = ["modules:paged_searches"]
ldb = SamDB(host, credentials=creds, session_info=system_session(), lp=lp, options=ldb_options)

runner = SubunitTestRunner()
rc = 0
if not runner.run(unittest.makeSuite(SpeedTestAddDel)).wasSuccessful():
    rc = 1
if not runner.run(unittest.makeSuite(AclSearchSpeedTest)).wasSuccessful():
    rc = 1
sys.exit(rc)
Ejemplo n.º 30
0
        cmd = cmd_sambatool.subcommands['domain'].subcommands['provision']
        result = cmd._run("samba-tool domain provision",
                          '--targetdir=%s' % self.tmpdir, '--use-ntvfs')

    def test_03_00_provision_server_role(self):
        for role in ('member', 'server', 'member', 'standalone'):
            self._test_provision_subprocess(options=['--server-role', role],
                                            subdir=role)

    def test_04_00_provision_blank(self):
        for i in range(2):
            self._test_provision_subprocess(options=['--blank'], subdir=i)

    def test_05_00_provision_partitions_only(self):
        self._test_provision_subprocess(options=['--partitions-only'])


if "://" not in host:
    if os.path.isfile(host):
        host = "tdb://%s" % host
    else:
        host = "ldap://%s" % host

if ANCIENT_SAMBA:
    runner = SubunitTestRunner()
    if not runner.run(unittest.makeSuite(UserTests)).wasSuccessful():
        sys.exit(1)
    sys.exit(0)
else:
    TestProgram(module=__name__, opts=subunitopts)
Ejemplo n.º 31
0
        """test removal of 1 site"""

        self.ldb_admin.transaction_start()
        ok = sites.delete_site(self.ldb_admin, self.ldb_admin.get_config_basedn(),
                            "testsamba")

        self.ldb_admin.transaction_commit()

        self.assertRaises(sites.SiteNotFoundException,
                            sites.delete_site, self.ldb_admin, self.ldb_admin.get_config_basedn(),
                            "testsamba")


    def test_delete_not_empty(self):
        """test removal of 1 site with servers"""

        self.assertRaises(sites.SiteServerNotEmptyException,
                            sites.delete_site, self.ldb_admin, self.ldb_admin.get_config_basedn(),
                            "Default-First-Site-Name")


ldb = SamDB(ldapshost, credentials=creds, session_info=system_session(lp), lp=lp)

runner = SubunitTestRunner()
rc = 0

if not runner.run(unittest.makeSuite(SimpleSitesTests)).wasSuccessful():
    rc = 1

sys.exit(rc)