summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-03-29 15:43:43 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-03-29 18:05:29 +0200
commit89aa3b766b926d19dac4805a7e72433e497ce872 (patch)
treeaf8db31d184f734fee3abfe853374f8dd91cd663 /source4/scripting/python
parent87ad4e990be2a763af9f45c0857b5de654cf2e1b (diff)
downloadsamba-89aa3b766b926d19dac4805a7e72433e497ce872.tar.gz
samba-89aa3b766b926d19dac4805a7e72433e497ce872.tar.bz2
samba-89aa3b766b926d19dac4805a7e72433e497ce872.zip
s4-python: Format to PEP8, simplify tests.
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/ms_schema.py26
-rw-r--r--source4/scripting/python/samba/tests/ntacls.py155
-rw-r--r--source4/scripting/python/samba/upgrade.py6
3 files changed, 84 insertions, 103 deletions
diff --git a/source4/scripting/python/samba/ms_schema.py b/source4/scripting/python/samba/ms_schema.py
index 9f5ebcf8cc..2c773bd005 100644
--- a/source4/scripting/python/samba/ms_schema.py
+++ b/source4/scripting/python/samba/ms_schema.py
@@ -34,19 +34,19 @@ bitFields["searchflags"] = {
# ADTS: 2.2.10
bitFields["systemflags"] = {
- 'FLAG_ATTR_NOT_REPLICATED': 31, 'FLAG_CR_NTDS_NC': 31, # NR
- 'FLAG_ATTR_REQ_PARTIAL_SET_MEMBER': 30, 'FLAG_CR_NTDS_DOMAIN': 30, # PS
- 'FLAG_ATTR_IS_CONSTRUCTED': 29, 'FLAG_CR_NTDS_NOT_GC_REPLICATED': 29, # CS
- 'FLAG_ATTR_IS_OPERATIONAL': 28, # OP
- 'FLAG_SCHEMA_BASE_OBJECT': 27, # BS
- 'FLAG_ATTR_IS_RDN': 26, # RD
- 'FLAG_DISALLOW_MOVE_ON_DELETE': 6, # DE
- 'FLAG_DOMAIN_DISALLOW_MOVE': 5, # DM
- 'FLAG_DOMAIN_DISALLOW_RENAME': 4, # DR
- 'FLAG_CONFIG_ALLOW_LIMITED_MOVE': 3, # AL
- 'FLAG_CONFIG_ALLOW_MOVE': 2, # AM
- 'FLAG_CONFIG_ALLOW_RENAME': 1, # AR
- 'FLAG_DISALLOW_DELETE': 0 # DD
+ 'FLAG_ATTR_NOT_REPLICATED': 31, 'FLAG_CR_NTDS_NC': 31, # NR
+ 'FLAG_ATTR_REQ_PARTIAL_SET_MEMBER': 30, 'FLAG_CR_NTDS_DOMAIN': 30, # PS
+ 'FLAG_ATTR_IS_CONSTRUCTED': 29, 'FLAG_CR_NTDS_NOT_GC_REPLICATED': 29, # CS
+ 'FLAG_ATTR_IS_OPERATIONAL': 28, # OP
+ 'FLAG_SCHEMA_BASE_OBJECT': 27, # BS
+ 'FLAG_ATTR_IS_RDN': 26, # RD
+ 'FLAG_DISALLOW_MOVE_ON_DELETE': 6, # DE
+ 'FLAG_DOMAIN_DISALLOW_MOVE': 5, # DM
+ 'FLAG_DOMAIN_DISALLOW_RENAME': 4, # DR
+ 'FLAG_CONFIG_ALLOW_LIMITED_MOVE': 3, # AL
+ 'FLAG_CONFIG_ALLOW_MOVE': 2, # AM
+ 'FLAG_CONFIG_ALLOW_RENAME': 1, # AR
+ 'FLAG_DISALLOW_DELETE': 0 # DD
}
# ADTS: 2.2.11
diff --git a/source4/scripting/python/samba/tests/ntacls.py b/source4/scripting/python/samba/tests/ntacls.py
index 0add258a3e..c8476dbcc8 100644
--- a/source4/scripting/python/samba/tests/ntacls.py
+++ b/source4/scripting/python/samba/tests/ntacls.py
@@ -26,94 +26,75 @@ import os
class NtaclsTests(TestCase):
- def test_setntacl(self):
- random.seed()
- lp=LoadParm()
- path=None
- try:
- path=os.environ['SELFTEST_PREFIX']
- except:
- self.assertTrue(path!=None, "SELFTEST_PREFIX env not set")
- acl="O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
- tempf=os.path.join(path,"pytests"+str(int(100000*random.random())))
- ntacl=xattr.NTACL()
- ntacl.version = 1
- open(tempf, 'w').write("empty")
- lp.set("posix:eadb",os.path.join(path,"eadbtest.tdb"))
- setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467")
- os.unlink(tempf)
+ def test_setntacl(self):
+ random.seed()
+ lp = LoadParm()
+ path = os.environ['SELFTEST_PREFIX']
+ acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
+ tempf = os.path.join(path,"pytests"+str(int(100000*random.random())))
+ ntacl = xattr.NTACL()
+ ntacl.version = 1
+ open(tempf, 'w').write("empty")
+ lp.set("posix:eadb",os.path.join(path,"eadbtest.tdb"))
+ setntacl(lp, tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467")
+ os.unlink(tempf)
- def test_setntacl_getntacl(self):
- random.seed()
- lp=LoadParm()
- path=None
- try:
- path=os.environ['SELFTEST_PREFIX']
- except:
- self.assertTrue(path!=None, "SELFTEST_PREFIX env not set")
- acl="O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
- tempf=os.path.join(path,"pytests"+str(int(100000*random.random())))
- ntacl=xattr.NTACL()
- ntacl.version = 1
- open(tempf, 'w').write("empty")
- lp.set("posix:eadb",os.path.join(path,"eadbtest.tdb"))
- setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467")
- facl=getntacl(lp,tempf)
- anysid=security.dom_sid(security.SID_NT_SELF)
- self.assertEquals(facl.info.as_sddl(anysid),acl)
- os.unlink(tempf)
+ def test_setntacl_getntacl(self):
+ random.seed()
+ lp = LoadParm()
+ path = None
+ path = os.environ['SELFTEST_PREFIX']
+ acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
+ tempf = os.path.join(path,"pytests"+str(int(100000*random.random())))
+ ntacl = xattr.NTACL()
+ ntacl.version = 1
+ open(tempf, 'w').write("empty")
+ lp.set("posix:eadb",os.path.join(path,"eadbtest.tdb"))
+ setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467")
+ facl = getntacl(lp,tempf)
+ anysid = security.dom_sid(security.SID_NT_SELF)
+ self.assertEquals(facl.info.as_sddl(anysid),acl)
+ os.unlink(tempf)
- def test_setntacl_getntacl_param(self):
- random.seed()
- lp=LoadParm()
- acl="O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
- path=None
- try:
- path=os.environ['SELFTEST_PREFIX']
- except:
- self.assertTrue(path!=None, "SELFTEST_PREFIX env not set")
- tempf=os.path.join(path,"pytests"+str(int(100000*random.random())))
- ntacl=xattr.NTACL()
- ntacl.version = 1
- open(tempf, 'w').write("empty")
- setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467","tdb",os.path.join(path,"eadbtest.tdb"))
- facl=getntacl(lp,tempf,"tdb",os.path.join(path,"eadbtest.tdb"))
- domsid=security.dom_sid(security.SID_NT_SELF)
- self.assertEquals(facl.info.as_sddl(domsid),acl)
- os.unlink(tempf)
+ def test_setntacl_getntacl_param(self):
+ random.seed()
+ lp = LoadParm()
+ acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
+ path = os.environ['SELFTEST_PREFIX']
+ tempf = os.path.join(path,"pytests"+str(int(100000*random.random())))
+ ntacl = xattr.NTACL()
+ ntacl.version = 1
+ open(tempf, 'w').write("empty")
+ setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467","tdb",os.path.join(path,"eadbtest.tdb"))
+ facl=getntacl(lp,tempf,"tdb",os.path.join(path,"eadbtest.tdb"))
+ domsid=security.dom_sid(security.SID_NT_SELF)
+ self.assertEquals(facl.info.as_sddl(domsid),acl)
+ os.unlink(tempf)
- def test_setntacl_invalidbackend(self):
- random.seed()
- lp=LoadParm()
- acl="O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
- path=None
- try:
- path=os.environ['SELFTEST_PREFIX']
- except:
- self.assertTrue(path!=None, "SELFTEST_PREFIX env not set")
- tempf=os.path.join(path,"pytests"+str(int(100000*random.random())))
- ntacl=xattr.NTACL()
- ntacl.version = 1
- open(tempf, 'w').write("empty")
- self.assertRaises(XattrBackendError,setntacl,lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467","ttdb",os.path.join(path,"eadbtest.tdb"))
-
- def test_setntacl_forcenative(self):
- if os.getuid() != 0:
- random.seed()
- lp=LoadParm()
- acl="O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
- path=None
- try:
- path=os.environ['SELFTEST_PREFIX']
- except:
- self.assertTrue(path!=None, "SELFTEST_PREFIX env not set")
- tempf=os.path.join(path,"pytests"+str(int(100000*random.random())))
- ntacl=xattr.NTACL()
- ntacl.version = 1
- open(tempf, 'w').write("empty")
- lp.set("posix:eadb",os.path.join(path,"eadbtest.tdb"))
- self.assertRaises(Exception,setntacl,lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467","native")
- os.unlink(tempf)
- else:
- print "Running test as root, test skipped"
+ def test_setntacl_invalidbackend(self):
+ random.seed()
+ lp = LoadParm()
+ acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
+ path = os.environ['SELFTEST_PREFIX']
+ tempf = os.path.join(path,"pytests"+str(int(100000*random.random())))
+ ntacl = xattr.NTACL()
+ ntacl.version = 1
+ open(tempf, 'w').write("empty")
+ self.assertRaises(XattrBackendError, setntacl, lp, tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467","ttdb", os.path.join(path,"eadbtest.tdb"))
+ def test_setntacl_forcenative(self):
+ if os.getuid() != 0:
+ random.seed()
+ lp = LoadParm()
+ acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
+ path = os.environ['SELFTEST_PREFIX']
+ tempf = os.path.join(path,"pytests"+str(int(100000*random.random())))
+ ntacl = xattr.NTACL()
+ ntacl.version = 1
+ open(tempf, 'w').write("empty")
+ lp.set("posix:eadb", os.path.join(path,"eadbtest.tdb"))
+ self.assertRaises(Exception, setntacl, lp, tempf ,acl,
+ "S-1-5-21-2212615479-2695158682-2101375467","native")
+ os.unlink(tempf)
+ else:
+ print "Running test as root, test skipped"
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index a2c78de4cf..b20cecf77d 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -1,8 +1,8 @@
#!/usr/bin/python
#
-# backend code for upgrading from Samba3
-# Copyright Jelmer Vernooij 2005-2007
-# Released under the GNU GPL v3 or later
+# backend code for upgrading from Samba3
+# Copyright Jelmer Vernooij 2005-2007
+# Released under the GNU GPL v3 or later
#
"""Support code for upgrading from Samba 3 to Samba 4."""