mirror of
https://github.com/samba-team/samba.git
synced 2025-07-23 20:59:10 +03:00
python: Use samba.tests.TestCase, make sure base class tearDown and
setUp methods are called, fix formatting.
This commit is contained in:
@ -23,11 +23,13 @@ Note that this just tests the bindings work. It does not intend to test
|
|||||||
the functionality, that's already done in other tests.
|
the functionality, that's already done in other tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
|
||||||
from samba import credentials
|
from samba import credentials
|
||||||
|
import samba.tests
|
||||||
|
|
||||||
|
class CredentialsTests(samba.tests.TestCase):
|
||||||
|
|
||||||
class CredentialsTests(unittest.TestCase):
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(CredentialsTests, self).setUp()
|
||||||
self.creds = credentials.Credentials()
|
self.creds = credentials.Credentials()
|
||||||
|
|
||||||
def test_set_username(self):
|
def test_set_username(self):
|
||||||
|
@ -23,16 +23,16 @@ Note that this just tests the bindings work. It does not intend to test
|
|||||||
the functionality, that's already done in other tests.
|
the functionality, that's already done in other tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
|
||||||
from samba import gensec
|
from samba import gensec
|
||||||
from samba.tests import env_loadparm
|
import samba.tests
|
||||||
|
|
||||||
class CredentialsTests(unittest.TestCase):
|
class CredentialsTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(CredentialsTests, self).setUp()
|
||||||
settings = {}
|
settings = {}
|
||||||
settings["target_hostname"] = "localhost"
|
settings["target_hostname"] = "localhost"
|
||||||
settings["lp_ctx"] = env_loadparm()
|
settings["lp_ctx"] = samba.tests.env_loadparm()
|
||||||
self.gensec = gensec.Security.start_client(settings)
|
self.gensec = gensec.Security.start_client(settings)
|
||||||
|
|
||||||
def test_info(self):
|
def test_info(self):
|
||||||
|
@ -23,10 +23,11 @@ Note that this just tests the bindings work. It does not intend to test
|
|||||||
the functionality, that's already done in other tests.
|
the functionality, that's already done in other tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
|
||||||
from samba import auth
|
from samba import auth
|
||||||
|
import samba.tests
|
||||||
|
|
||||||
|
class AuthTests(samba.tests.TestCase):
|
||||||
|
|
||||||
class AuthTests(unittest.TestCase):
|
|
||||||
def test_system_session(self):
|
def test_system_session(self):
|
||||||
auth.system_session()
|
auth.system_session()
|
||||||
|
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
# Simple tests for the ldb python bindings.
|
# Simple tests for the ldb python bindings.
|
||||||
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
|
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
|
||||||
|
|
||||||
import os, sys
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# Required for the standalone LDB build
|
|
||||||
sys.path.append("build/lib.linux-i686-2.4")
|
|
||||||
|
|
||||||
import ldb
|
import ldb
|
||||||
|
|
||||||
def filename():
|
def filename():
|
||||||
|
@ -81,6 +81,7 @@ class BasicTests(unittest.TestCase):
|
|||||||
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
|
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(BasicTests, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
self.gc_ldb = gc_ldb
|
self.gc_ldb = gc_ldb
|
||||||
self.base_dn = self.find_basedn(ldb)
|
self.base_dn = self.find_basedn(ldb)
|
||||||
@ -2569,8 +2570,11 @@ nTSecurityDescriptor:: """ + desc_base64
|
|||||||
finally:
|
finally:
|
||||||
self.delete_force(self.ldb, user_dn)
|
self.delete_force(self.ldb, user_dn)
|
||||||
|
|
||||||
|
|
||||||
class BaseDnTests(unittest.TestCase):
|
class BaseDnTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(BaseDnTests, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
|
|
||||||
def test_rootdse_attrs(self):
|
def test_rootdse_attrs(self):
|
||||||
|
@ -45,6 +45,7 @@ creds = credopts.get_credentials(lp)
|
|||||||
|
|
||||||
|
|
||||||
class SchemaTests(unittest.TestCase):
|
class SchemaTests(unittest.TestCase):
|
||||||
|
|
||||||
def delete_force(self, ldb, dn):
|
def delete_force(self, ldb, dn):
|
||||||
try:
|
try:
|
||||||
ldb.delete(dn)
|
ldb.delete(dn)
|
||||||
@ -63,6 +64,7 @@ class SchemaTests(unittest.TestCase):
|
|||||||
return res[0]["defaultNamingContext"][0]
|
return res[0]["defaultNamingContext"][0]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SchemaTests, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
self.schema_dn = self.find_schemadn(ldb)
|
self.schema_dn = self.find_schemadn(ldb)
|
||||||
self.base_dn = self.find_basedn(ldb)
|
self.base_dn = self.find_basedn(ldb)
|
||||||
@ -214,6 +216,7 @@ name: """ + object_name + """
|
|||||||
class SchemaTests_msDS_IntId(unittest.TestCase):
|
class SchemaTests_msDS_IntId(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SchemaTests_msDS_IntId, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
|
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
|
||||||
self.assertEquals(len(res), 1)
|
self.assertEquals(len(res), 1)
|
||||||
@ -481,9 +484,11 @@ systemOnly: FALSE
|
|||||||
else:
|
else:
|
||||||
self.assertTrue("msDS-IntId" not in ldb_msg)
|
self.assertTrue("msDS-IntId" not in ldb_msg)
|
||||||
|
|
||||||
|
|
||||||
class SchemaTests_msDS_isRODC(unittest.TestCase):
|
class SchemaTests_msDS_isRODC(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SchemaTests_msDS_isRODC, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
|
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
|
||||||
self.assertEquals(len(res), 1)
|
self.assertEquals(len(res), 1)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -75,6 +74,7 @@ class PasswordTests(samba.tests.TestCase):
|
|||||||
return res[0]["defaultNamingContext"][0]
|
return res[0]["defaultNamingContext"][0]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(PasswordTests, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
self.base_dn = self.find_basedn(ldb)
|
self.base_dn = self.find_basedn(ldb)
|
||||||
|
|
||||||
@ -558,6 +558,7 @@ userPassword: thatsAcomplPASS4
|
|||||||
"userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] })
|
"userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] })
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
super(PasswordTests, self).tearDown()
|
||||||
self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn)
|
self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn)
|
||||||
self.delete_force(self.ldb, "cn=testuser2,cn=users," + self.base_dn)
|
self.delete_force(self.ldb, "cn=testuser2,cn=users," + self.base_dn)
|
||||||
# Close the second LDB connection (with the user credentials)
|
# Close the second LDB connection (with the user credentials)
|
||||||
|
@ -19,7 +19,6 @@ from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT
|
|||||||
from samba.ndr import ndr_pack, ndr_unpack
|
from samba.ndr import ndr_pack, ndr_unpack
|
||||||
from samba.dcerpc import security
|
from samba.dcerpc import security
|
||||||
|
|
||||||
from samba import Ldb
|
|
||||||
from samba import gensec
|
from samba import gensec
|
||||||
from samba.samdb import SamDB
|
from samba.samdb import SamDB
|
||||||
from samba.credentials import Credentials
|
from samba.credentials import Credentials
|
||||||
@ -28,6 +27,7 @@ from samba.dsdb import DS_DOMAIN_FUNCTION_2008
|
|||||||
from samba.dcerpc.security import (
|
from samba.dcerpc.security import (
|
||||||
SECINFO_OWNER, SECINFO_GROUP, SECINFO_DACL, SECINFO_SACL)
|
SECINFO_OWNER, SECINFO_GROUP, SECINFO_DACL, SECINFO_SACL)
|
||||||
from subunit.run import SubunitTestRunner
|
from subunit.run import SubunitTestRunner
|
||||||
|
import samba.tests
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
parser = optparse.OptionParser("sec_descriptor [options] <host>")
|
parser = optparse.OptionParser("sec_descriptor [options] <host>")
|
||||||
@ -54,7 +54,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL)
|
|||||||
# Tests start here
|
# Tests start here
|
||||||
#
|
#
|
||||||
|
|
||||||
class DescriptorTests(unittest.TestCase):
|
class DescriptorTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def delete_force(self, ldb, dn):
|
def delete_force(self, ldb, dn):
|
||||||
try:
|
try:
|
||||||
@ -271,6 +271,7 @@ member: """ + self.get_users_domain_dn(username)
|
|||||||
self.ldb_admin.enable_account("(sAMAccountName=" + username + ")")
|
self.ldb_admin.enable_account("(sAMAccountName=" + username + ")")
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(DescriptorTests, self).setUp()
|
||||||
self.ldb_admin = ldb
|
self.ldb_admin = ldb
|
||||||
self.base_dn = self.find_basedn(self.ldb_admin)
|
self.base_dn = self.find_basedn(self.ldb_admin)
|
||||||
self.configuration_dn = self.find_configurationdn(self.ldb_admin)
|
self.configuration_dn = self.find_configurationdn(self.ldb_admin)
|
||||||
@ -307,7 +308,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
|
|||||||
self.delete_force(self.ldb_admin, "CN=test-container1,CN=DisplaySpecifiers," + self.configuration_dn)
|
self.delete_force(self.ldb_admin, "CN=test-container1,CN=DisplaySpecifiers," + self.configuration_dn)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
DescriptorTests.setUp(self)
|
super(OwnerGroupDescriptorTests, self).setUp()
|
||||||
self.deleteAll()
|
self.deleteAll()
|
||||||
### Create users
|
### Create users
|
||||||
# User 1
|
# User 1
|
||||||
@ -453,6 +454,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
|
|||||||
self.DS_BEHAVIOR = "ds_behavior_win2008"
|
self.DS_BEHAVIOR = "ds_behavior_win2008"
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
super(DescriptorTests, self).tearDown()
|
||||||
self.deleteAll()
|
self.deleteAll()
|
||||||
|
|
||||||
def check_user_belongs(self, user_dn, groups=[]):
|
def check_user_belongs(self, user_dn, groups=[]):
|
||||||
@ -1364,10 +1366,7 @@ class DaclDescriptorTests(DescriptorTests):
|
|||||||
self.delete_force(self.ldb_admin, "OU=test_inherit_ou," + self.base_dn)
|
self.delete_force(self.ldb_admin, "OU=test_inherit_ou," + self.base_dn)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
DescriptorTests.setUp(self)
|
super(DaclDescriptorTests, self).setUp()
|
||||||
self.deleteAll()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.deleteAll()
|
self.deleteAll()
|
||||||
|
|
||||||
def create_clean_ou(self, object_dn):
|
def create_clean_ou(self, object_dn):
|
||||||
@ -1696,13 +1695,10 @@ class SdFlagsDescriptorTests(DescriptorTests):
|
|||||||
self.delete_force(self.ldb_admin, "OU=test_sdflags_ou," + self.base_dn)
|
self.delete_force(self.ldb_admin, "OU=test_sdflags_ou," + self.base_dn)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
DescriptorTests.setUp(self)
|
super(SdFlagsDescriptorTests, self).setUp()
|
||||||
self.test_descr = "O:AUG:AUD:(D;;CC;;;LG)S:(OU;;WP;;;AU)"
|
self.test_descr = "O:AUG:AUD:(D;;CC;;;LG)S:(OU;;WP;;;AU)"
|
||||||
self.deleteAll()
|
self.deleteAll()
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.deleteAll()
|
|
||||||
|
|
||||||
def test_301(self):
|
def test_301(self):
|
||||||
""" Modify a descriptor with OWNER_SECURITY_INFORMATION set.
|
""" Modify a descriptor with OWNER_SECURITY_INFORMATION set.
|
||||||
See that only the owner has been changed.
|
See that only the owner has been changed.
|
||||||
@ -1849,6 +1845,7 @@ class SdFlagsDescriptorTests(DescriptorTests):
|
|||||||
self.assertFalse("S:" in desc_sddl)
|
self.assertFalse("S:" in desc_sddl)
|
||||||
self.assertFalse("G:" in desc_sddl)
|
self.assertFalse("G:" in desc_sddl)
|
||||||
|
|
||||||
|
|
||||||
class RightsAttributesTests(DescriptorTests):
|
class RightsAttributesTests(DescriptorTests):
|
||||||
|
|
||||||
def deleteAll(self):
|
def deleteAll(self):
|
||||||
@ -1857,7 +1854,7 @@ class RightsAttributesTests(DescriptorTests):
|
|||||||
self.delete_force(self.ldb_admin, "OU=test_domain_ou1," + self.base_dn)
|
self.delete_force(self.ldb_admin, "OU=test_domain_ou1," + self.base_dn)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
DescriptorTests.setUp(self)
|
super(RightsAttributesTests, self).setUp()
|
||||||
self.deleteAll()
|
self.deleteAll()
|
||||||
### Create users
|
### Create users
|
||||||
# User 1
|
# User 1
|
||||||
@ -1866,9 +1863,6 @@ class RightsAttributesTests(DescriptorTests):
|
|||||||
self.create_enable_user("testuser_attr2")
|
self.create_enable_user("testuser_attr2")
|
||||||
self.add_user_to_group(self.ldb_admin, "testuser_attr2", "Domain Admins")
|
self.add_user_to_group(self.ldb_admin, "testuser_attr2", "Domain Admins")
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.deleteAll()
|
|
||||||
|
|
||||||
def test_sDRightsEffective(self):
|
def test_sDRightsEffective(self):
|
||||||
object_dn = "OU=test_domain_ou1," + self.base_dn
|
object_dn = "OU=test_domain_ou1," + self.base_dn
|
||||||
self.delete_force(self.ldb_admin, object_dn)
|
self.delete_force(self.ldb_admin, object_dn)
|
||||||
|
@ -15,6 +15,7 @@ from samba.auth import system_session
|
|||||||
from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
|
from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
|
||||||
MessageElement, Dn, FLAG_MOD_REPLACE)
|
MessageElement, Dn, FLAG_MOD_REPLACE)
|
||||||
from samba.samdb import SamDB
|
from samba.samdb import SamDB
|
||||||
|
import samba.tests
|
||||||
|
|
||||||
from subunit.run import SubunitTestRunner
|
from subunit.run import SubunitTestRunner
|
||||||
import unittest
|
import unittest
|
||||||
@ -37,7 +38,7 @@ host = args[0]
|
|||||||
lp = sambaopts.get_loadparm()
|
lp = sambaopts.get_loadparm()
|
||||||
creds = credopts.get_credentials(lp)
|
creds = credopts.get_credentials(lp)
|
||||||
|
|
||||||
class UrgentReplicationTests(unittest.TestCase):
|
class UrgentReplicationTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def delete_force(self, ldb, dn):
|
def delete_force(self, ldb, dn):
|
||||||
try:
|
try:
|
||||||
@ -52,6 +53,7 @@ class UrgentReplicationTests(unittest.TestCase):
|
|||||||
return res[0]["defaultNamingContext"][0]
|
return res[0]["defaultNamingContext"][0]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(UrgentReplicationTests, self).setUp()
|
||||||
self.ldb = ldb
|
self.ldb = ldb
|
||||||
self.base_dn = self.find_basedn(ldb)
|
self.base_dn = self.find_basedn(ldb)
|
||||||
|
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from samba.messaging import Messaging
|
from samba.messaging import Messaging
|
||||||
from unittest import TestCase
|
from samba.tests import TestCase
|
||||||
|
|
||||||
class MessagingTests(TestCase):
|
class MessagingTests(TestCase):
|
||||||
|
|
||||||
def get_context(self, *args, **kwargs):
|
def get_context(self, *args, **kwargs):
|
||||||
kwargs["messaging_path"] = "."
|
kwargs["messaging_path"] = "."
|
||||||
return Messaging(*args, **kwargs)
|
return Messaging(*args, **kwargs)
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
|
||||||
from samba import registry
|
from samba import registry
|
||||||
import samba.tests
|
import samba.tests
|
||||||
|
|
||||||
class HelperTests(unittest.TestCase):
|
class HelperTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_predef_to_name(self):
|
def test_predef_to_name(self):
|
||||||
self.assertEquals("HKEY_LOCAL_MACHINE",
|
self.assertEquals("HKEY_LOCAL_MACHINE",
|
||||||
registry.get_predef_name(0x80000002))
|
registry.get_predef_name(0x80000002))
|
||||||
@ -33,6 +33,7 @@ class HelperTests(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class HiveTests(samba.tests.TestCaseInTempDir):
|
class HiveTests(samba.tests.TestCaseInTempDir):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(HiveTests, self).setUp()
|
super(HiveTests, self).setUp()
|
||||||
self.hive_path = os.path.join(self.tempdir, "ldb_new.ldb")
|
self.hive_path = os.path.join(self.tempdir, "ldb_new.ldb")
|
||||||
@ -41,6 +42,7 @@ class HiveTests(samba.tests.TestCaseInTempDir):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
del self.hive
|
del self.hive
|
||||||
os.unlink(self.hive_path)
|
os.unlink(self.hive_path)
|
||||||
|
super(HiveTests, self).tearDown()
|
||||||
|
|
||||||
def test_ldb_new(self):
|
def test_ldb_new(self):
|
||||||
self.assertTrue(self.hive is not None)
|
self.assertTrue(self.hive is not None)
|
||||||
@ -52,6 +54,7 @@ class HiveTests(samba.tests.TestCaseInTempDir):
|
|||||||
# self.hive.del_value("FOO")
|
# self.hive.del_value("FOO")
|
||||||
|
|
||||||
|
|
||||||
class RegistryTests(unittest.TestCase):
|
class RegistryTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_new(self):
|
def test_new(self):
|
||||||
self.registry = registry.Registry()
|
self.registry = registry.Registry()
|
||||||
|
@ -17,11 +17,13 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
import unittest
|
import samba.tests
|
||||||
from samba.dcerpc import security
|
from samba.dcerpc import security
|
||||||
|
|
||||||
class SecurityTokenTests(unittest.TestCase):
|
class SecurityTokenTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SecurityTokenTests, self).setUp()
|
||||||
self.token = security.token()
|
self.token = security.token()
|
||||||
|
|
||||||
def test_is_system(self):
|
def test_is_system(self):
|
||||||
@ -45,9 +47,10 @@ class SecurityTokenTests(unittest.TestCase):
|
|||||||
self.assertTrue(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
|
self.assertTrue(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
|
||||||
|
|
||||||
|
|
||||||
class SecurityDescriptorTests(unittest.TestCase):
|
class SecurityDescriptorTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SecurityDescriptorTests, self).setUp()
|
||||||
self.descriptor = security.descriptor()
|
self.descriptor = security.descriptor()
|
||||||
|
|
||||||
def test_from_sddl(self):
|
def test_from_sddl(self):
|
||||||
@ -62,11 +65,12 @@ class SecurityDescriptorTests(unittest.TestCase):
|
|||||||
self.assertRaises(TypeError,security.descriptor.from_sddl, "foo",security.dom_sid("S-2-0-0"))
|
self.assertRaises(TypeError,security.descriptor.from_sddl, "foo",security.dom_sid("S-2-0-0"))
|
||||||
|
|
||||||
def test_from_sddl_invalidtype1(self):
|
def test_from_sddl_invalidtype1(self):
|
||||||
self.assertRaises(TypeError,security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0"))
|
self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0"))
|
||||||
|
|
||||||
def test_from_sddl_invalidtype1(self):
|
def test_from_sddl_invalidtype2(self):
|
||||||
sddl = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
sddl = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
||||||
self.assertRaises(TypeError,security.descriptor.from_sddl, sddl,"S-2-0-0")
|
self.assertRaises(TypeError, security.descriptor.from_sddl, sddl,
|
||||||
|
"S-2-0-0")
|
||||||
|
|
||||||
def test_as_sddl(self):
|
def test_as_sddl(self):
|
||||||
text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
|
||||||
@ -106,7 +110,8 @@ class SecurityDescriptorTests(unittest.TestCase):
|
|||||||
self.assertEquals((security.dom_sid("S-2-0"), 7), dom.split())
|
self.assertEquals((security.dom_sid("S-2-0"), 7), dom.split())
|
||||||
|
|
||||||
|
|
||||||
class DomSidTests(unittest.TestCase):
|
class DomSidTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_parse_sid(self):
|
def test_parse_sid(self):
|
||||||
sid = security.dom_sid("S-1-5-21")
|
sid = security.dom_sid("S-1-5-21")
|
||||||
self.assertEquals("S-1-5-21", str(sid))
|
self.assertEquals("S-1-5-21", str(sid))
|
||||||
@ -126,10 +131,13 @@ class DomSidTests(unittest.TestCase):
|
|||||||
self.assertTrue(repr(sid).startswith("dom_sid('S-1-5-21-"))
|
self.assertTrue(repr(sid).startswith("dom_sid('S-1-5-21-"))
|
||||||
|
|
||||||
|
|
||||||
class PrivilegeTests(unittest.TestCase):
|
class PrivilegeTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_privilege_name(self):
|
def test_privilege_name(self):
|
||||||
self.assertEquals("SeShutdownPrivilege", security.privilege_name(security.SEC_PRIV_SHUTDOWN))
|
self.assertEquals("SeShutdownPrivilege",
|
||||||
|
security.privilege_name(security.SEC_PRIV_SHUTDOWN))
|
||||||
|
|
||||||
def test_privilege_id(self):
|
def test_privilege_id(self):
|
||||||
self.assertEquals(security.SEC_PRIV_SHUTDOWN, security.privilege_id("SeShutdownPrivilege"))
|
self.assertEquals(security.SEC_PRIV_SHUTDOWN,
|
||||||
|
security.privilege_id("SeShutdownPrivilege"))
|
||||||
|
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from samba import param
|
from samba import param
|
||||||
import unittest
|
import samba.tests
|
||||||
|
|
||||||
|
class LoadParmTestCase(samba.tests.TestCase):
|
||||||
|
|
||||||
class LoadParmTestCase(unittest.TestCase):
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
file = param.LoadParm()
|
file = param.LoadParm()
|
||||||
self.assertTrue(file is not None)
|
self.assertTrue(file is not None)
|
||||||
|
@ -30,9 +30,10 @@ from testtools.testcase import TestCase, TestSkipped
|
|||||||
|
|
||||||
|
|
||||||
class LdbTestCase(TestCase):
|
class LdbTestCase(TestCase):
|
||||||
|
|
||||||
"""Trivial test case for running tests against a LDB."""
|
"""Trivial test case for running tests against a LDB."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(LdbTestCase, self).setUp()
|
||||||
self.filename = os.tempnam()
|
self.filename = os.tempnam()
|
||||||
self.ldb = samba.Ldb(self.filename)
|
self.ldb = samba.Ldb(self.filename)
|
||||||
|
|
||||||
@ -63,14 +64,16 @@ class SubstituteVarTestCase(TestCase):
|
|||||||
self.assertEquals("", samba.substitute_var("", {}))
|
self.assertEquals("", samba.substitute_var("", {}))
|
||||||
|
|
||||||
def test_nothing(self):
|
def test_nothing(self):
|
||||||
self.assertEquals("foo bar", samba.substitute_var("foo bar", {"bar": "bla"}))
|
self.assertEquals("foo bar",
|
||||||
|
samba.substitute_var("foo bar", {"bar": "bla"}))
|
||||||
|
|
||||||
def test_replace(self):
|
def test_replace(self):
|
||||||
self.assertEquals("foo bla", samba.substitute_var("foo ${bar}", {"bar": "bla"}))
|
self.assertEquals("foo bla",
|
||||||
|
samba.substitute_var("foo ${bar}", {"bar": "bla"}))
|
||||||
|
|
||||||
def test_broken(self):
|
def test_broken(self):
|
||||||
self.assertEquals("foo ${bdkjfhsdkfh sdkfh ",
|
self.assertEquals("foo ${bdkjfhsdkfh sdkfh ",
|
||||||
samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"}))
|
samba.substitute_var("foo ${bdkjfhsdkfh sdkfh ", {"bar": "bla"}))
|
||||||
|
|
||||||
def test_unknown_var(self):
|
def test_unknown_var(self):
|
||||||
self.assertEquals("foo ${bla} gsff",
|
self.assertEquals("foo ${bla} gsff",
|
||||||
@ -78,7 +81,8 @@ class SubstituteVarTestCase(TestCase):
|
|||||||
|
|
||||||
def test_check_all_substituted(self):
|
def test_check_all_substituted(self):
|
||||||
samba.check_all_substituted("nothing to see here")
|
samba.check_all_substituted("nothing to see here")
|
||||||
self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}")
|
self.assertRaises(Exception, samba.check_all_substituted,
|
||||||
|
"Not subsituted: ${FOOBAR}")
|
||||||
|
|
||||||
|
|
||||||
class LdbExtensionTests(TestCaseInTempDir):
|
class LdbExtensionTests(TestCaseInTempDir):
|
||||||
@ -88,7 +92,8 @@ class LdbExtensionTests(TestCaseInTempDir):
|
|||||||
l = samba.Ldb(path)
|
l = samba.Ldb(path)
|
||||||
try:
|
try:
|
||||||
l.add({"dn": "foo=dc", "bar": "bla"})
|
l.add({"dn": "foo=dc", "bar": "bla"})
|
||||||
self.assertEquals("bla", l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar"))
|
self.assertEquals("bla",
|
||||||
|
l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar"))
|
||||||
finally:
|
finally:
|
||||||
del l
|
del l
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
@ -16,5 +16,5 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
|
||||||
|
|
||||||
|
@ -19,31 +19,32 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from samba.dcerpc import ClientConnection
|
from samba.dcerpc import ClientConnection
|
||||||
from unittest import TestCase
|
import samba.tests
|
||||||
from samba.tests import env_loadparm
|
|
||||||
|
|
||||||
|
class BareTestCase(samba.tests.TestCase):
|
||||||
class BareTestCase(TestCase):
|
|
||||||
|
|
||||||
def test_bare(self):
|
def test_bare(self):
|
||||||
# Connect to the echo pipe
|
# Connect to the echo pipe
|
||||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
|
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||||
|
lp_ctx=samba.tests.env_loadparm())
|
||||||
self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
||||||
|
|
||||||
def test_alter_context(self):
|
def test_alter_context(self):
|
||||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||||
("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=env_loadparm())
|
("12345778-1234-abcd-ef00-0123456789ac", 1),
|
||||||
|
lp_ctx=samba.tests.env_loadparm())
|
||||||
y = ClientConnection("ncalrpc:localhost",
|
y = ClientConnection("ncalrpc:localhost",
|
||||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||||
basis_connection=x, lp_ctx=env_loadparm())
|
basis_connection=x, lp_ctx=samba.tests.env_loadparm())
|
||||||
x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
|
x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
|
||||||
# FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
# FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
|
||||||
|
|
||||||
def test_two_connections(self):
|
def test_two_connections(self):
|
||||||
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
x = ClientConnection("ncalrpc:localhost[DEFAULT]",
|
||||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm())
|
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||||
|
lp_ctx=samba.tests.env_loadparm())
|
||||||
y = ClientConnection("ncalrpc:localhost",
|
y = ClientConnection("ncalrpc:localhost",
|
||||||
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
("60a15ec5-4de8-11d7-a637-005056a20182", 1),
|
||||||
basis_connection=x, lp_ctx=env_loadparm())
|
basis_connection=x, lp_ctx=samba.tests.env_loadparm())
|
||||||
self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))
|
self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
import unittest
|
|
||||||
from samba.dcerpc import misc
|
from samba.dcerpc import misc
|
||||||
|
import samba.tests
|
||||||
|
|
||||||
text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
|
text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
|
||||||
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
|
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
|
||||||
|
|
||||||
class GUIDTests(unittest.TestCase):
|
class GUIDTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_str(self):
|
def test_str(self):
|
||||||
guid = misc.GUID(text1)
|
guid = misc.GUID(text1)
|
||||||
@ -45,7 +45,7 @@ class GUIDTests(unittest.TestCase):
|
|||||||
self.assertEquals(guid1, guid2)
|
self.assertEquals(guid1, guid2)
|
||||||
|
|
||||||
|
|
||||||
class PolicyHandleTests(unittest.TestCase):
|
class PolicyHandleTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
x = misc.policy_handle(text1, 1)
|
x = misc.policy_handle(text1, 1)
|
||||||
|
@ -24,6 +24,7 @@ from samba.tests import RpcInterfaceTestCase
|
|||||||
class WinregTests(RpcInterfaceTestCase):
|
class WinregTests(RpcInterfaceTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(WinregTests, self).setUp()
|
||||||
self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
|
self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
|
||||||
self.get_credentials())
|
self.get_credentials())
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
from samba.dcerpc import echo
|
from samba.dcerpc import echo
|
||||||
from samba.ndr import ndr_pack, ndr_unpack
|
from samba.ndr import ndr_pack, ndr_unpack
|
||||||
import unittest
|
from samba.tests import RpcInterfaceTestCase, TestCase
|
||||||
from samba.tests import RpcInterfaceTestCase
|
|
||||||
|
|
||||||
|
|
||||||
class RpcEchoTests(RpcInterfaceTestCase):
|
class RpcEchoTests(RpcInterfaceTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(RpcEchoTests, self).setUp()
|
||||||
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
|
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
|
||||||
|
|
||||||
def test_two_contexts(self):
|
def test_two_contexts(self):
|
||||||
@ -59,7 +59,7 @@ class RpcEchoTests(RpcInterfaceTestCase):
|
|||||||
self.assertEquals(None, self.conn.server_name)
|
self.assertEquals(None, self.conn.server_name)
|
||||||
|
|
||||||
|
|
||||||
class NdrEchoTests(unittest.TestCase):
|
class NdrEchoTests(TestCase):
|
||||||
|
|
||||||
def test_info1_push(self):
|
def test_info1_push(self):
|
||||||
x = echo.info1()
|
x = echo.info1()
|
||||||
|
@ -32,6 +32,7 @@ def toArray((handle, array, num_entries)):
|
|||||||
class SamrTests(RpcInterfaceTestCase):
|
class SamrTests(RpcInterfaceTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(SamrTests, self).setUp()
|
||||||
self.conn = samr.samr("ncalrpc:", self.get_loadparm())
|
self.conn = samr.samr("ncalrpc:", self.get_loadparm())
|
||||||
|
|
||||||
def test_connect5(self):
|
def test_connect5(self):
|
||||||
|
@ -23,6 +23,7 @@ from samba.tests import RpcInterfaceTestCase
|
|||||||
class UnixinfoTests(RpcInterfaceTestCase):
|
class UnixinfoTests(RpcInterfaceTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(UnixinfoTests, self).setUp()
|
||||||
self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
|
self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
|
||||||
|
|
||||||
def test_getpwuid(self):
|
def test_getpwuid(self):
|
||||||
|
@ -17,11 +17,10 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from samba.netcmd import Command
|
from samba.netcmd import Command
|
||||||
|
import samba.tests
|
||||||
|
|
||||||
class CommandTests(unittest.TestCase):
|
class CommandTests(samba.tests.TestCase):
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self):
|
||||||
class cmd_foo(Command):
|
class cmd_foo(Command):
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
import os
|
import os
|
||||||
from samba.provision import setup_secretsdb, findnss
|
from samba.provision import setup_secretsdb, findnss
|
||||||
import samba.tests
|
import samba.tests
|
||||||
from samba.tests import env_loadparm
|
from samba.tests import env_loadparm, TestCase
|
||||||
import unittest
|
|
||||||
|
|
||||||
setup_dir = "setup"
|
setup_dir = "setup"
|
||||||
def setup_path(file):
|
def setup_path(file):
|
||||||
@ -42,8 +41,9 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir):
|
|||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
|
|
||||||
class FindNssTests(unittest.TestCase):
|
class FindNssTests(TestCase):
|
||||||
"""Test findnss() function."""
|
"""Test findnss() function."""
|
||||||
|
|
||||||
def test_nothing(self):
|
def test_nothing(self):
|
||||||
def x(y):
|
def x(y):
|
||||||
raise KeyError
|
raise KeyError
|
||||||
|
@ -24,8 +24,8 @@ from samba.samba3 import (WinsDatabase, SmbpasswdFile, ACB_NORMAL,
|
|||||||
from samba.tests import TestCase
|
from samba.tests import TestCase
|
||||||
import os
|
import os
|
||||||
|
|
||||||
DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
|
DATADIR = os.path.join(os.path.dirname(__file__),
|
||||||
print "Samba 3 data dir: %s" % DATADIR
|
"../../../../../testdata/samba3")
|
||||||
|
|
||||||
class RegistryTestCase(TestCase):
|
class RegistryTestCase(TestCase):
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ class RegistryTestCase(TestCase):
|
|||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.registry.close()
|
self.registry.close()
|
||||||
|
super(RegistryTestCase, self).tearDown()
|
||||||
|
|
||||||
def test_length(self):
|
def test_length(self):
|
||||||
self.assertEquals(28, len(self.registry))
|
self.assertEquals(28, len(self.registry))
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
from samba.shares import SharesContainer
|
from samba.shares import SharesContainer
|
||||||
from unittest import TestCase
|
from samba.tests import TestCase
|
||||||
|
|
||||||
|
|
||||||
class MockService(object):
|
class MockService(object):
|
||||||
|
@ -21,6 +21,7 @@ from samba.upgrade import import_wins
|
|||||||
from samba.tests import LdbTestCase
|
from samba.tests import LdbTestCase
|
||||||
|
|
||||||
class WinsUpgradeTests(LdbTestCase):
|
class WinsUpgradeTests(LdbTestCase):
|
||||||
|
|
||||||
def test_upgrade(self):
|
def test_upgrade(self):
|
||||||
winsdb = {
|
winsdb = {
|
||||||
"FOO#20": (200, ["127.0.0.1", "127.0.0.2"], 0x60)
|
"FOO#20": (200, ["127.0.0.1", "127.0.0.2"], 0x60)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
import samba.xattr_native, samba.xattr_tdb
|
import samba.xattr_native, samba.xattr_tdb
|
||||||
from samba.dcerpc import xattr
|
from samba.dcerpc import xattr
|
||||||
from samba.ndr import ndr_pack
|
from samba.ndr import ndr_pack
|
||||||
from testtools.testcase import TestCase, TestSkipped
|
from samba.tests import TestCase, TestSkipped
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -26,11 +26,9 @@
|
|||||||
# PYTHONPATH="$samba4srcdir/torture/libnet/python" $SUBUNITRUN samr-test -Ukma-exch.devel/Administrator%333
|
# PYTHONPATH="$samba4srcdir/torture/libnet/python" $SUBUNITRUN samr-test -Ukma-exch.devel/Administrator%333
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from samba import net
|
from samba import net
|
||||||
import unittest
|
|
||||||
import samba.tests
|
import samba.tests
|
||||||
|
|
||||||
if not "ACCOUNT_NAME" in os.environ.keys():
|
if not "ACCOUNT_NAME" in os.environ.keys():
|
||||||
@ -48,7 +46,7 @@ creds = samba.tests.cmdline_credentials
|
|||||||
# Tests start here
|
# Tests start here
|
||||||
#
|
#
|
||||||
|
|
||||||
class Libnet_SetPwdTest(unittest.TestCase):
|
class Libnet_SetPwdTest(samba.tests.TestCase):
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user