mirror of
https://github.com/samba-team/samba.git
synced 2025-07-23 20:59:10 +03:00
s4-python: Format to PEP8, simplify tests.
This commit is contained in:
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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."""
|
||||
|
Reference in New Issue
Block a user