mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
tests/ntacls: fix pep8 warnings
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Jun 28 12:14:59 CEST 2018 on sn-devel-144
This commit is contained in:
parent
3262f01d36
commit
975b751bb6
@ -18,11 +18,12 @@
|
||||
|
||||
"""Tests for samba.ntacls."""
|
||||
|
||||
import os
|
||||
|
||||
from samba.ntacls import setntacl, getntacl, XattrBackendError
|
||||
from samba.param import LoadParm
|
||||
from samba.dcerpc import security
|
||||
from samba.tests import TestCaseInTempDir, SkipTest
|
||||
import os
|
||||
|
||||
NTACL_SDDL = "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)"
|
||||
DOMAIN_SID = "S-1-5-21-2212615479-2695158682-2101375467"
|
||||
@ -30,46 +31,6 @@ DOMAIN_SID = "S-1-5-21-2212615479-2695158682-2101375467"
|
||||
|
||||
class NtaclsTests(TestCaseInTempDir):
|
||||
|
||||
def test_setntacl(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb",os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID)
|
||||
os.unlink(os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_getntacl(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb",os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID)
|
||||
facl = getntacl(lp,self.tempf)
|
||||
anysid = security.dom_sid(security.SID_NT_SELF)
|
||||
self.assertEquals(facl.as_sddl(anysid), NTACL_SDDL)
|
||||
os.unlink(os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_getntacl_param(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID,"tdb", os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
facl=getntacl(lp,self.tempf,"tdb",os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
domsid=security.dom_sid(security.SID_NT_SELF)
|
||||
self.assertEquals(facl.as_sddl(domsid), NTACL_SDDL)
|
||||
os.unlink(os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_invalidbackend(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
self.assertRaises(XattrBackendError, setntacl, lp, self.tempf, NTACL_SDDL, DOMAIN_SID, "ttdb", os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_forcenative(self):
|
||||
if os.getuid() == 0:
|
||||
raise SkipTest("Running test as root, test skipped")
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb", os.path.join(self.tempdir,"eadbtest.tdb"))
|
||||
self.assertRaises(Exception, setntacl, lp, self.tempf, NTACL_SDDL,
|
||||
DOMAIN_SID, "native")
|
||||
|
||||
def setUp(self):
|
||||
super(NtaclsTests, self).setUp()
|
||||
self.tempf = os.path.join(self.tempdir, "test")
|
||||
@ -78,3 +39,47 @@ class NtaclsTests(TestCaseInTempDir):
|
||||
def tearDown(self):
|
||||
os.unlink(self.tempf)
|
||||
super(NtaclsTests, self).tearDown()
|
||||
|
||||
def test_setntacl(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb", os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID)
|
||||
os.unlink(os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_getntacl(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb", os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID)
|
||||
facl = getntacl(lp, self.tempf)
|
||||
anysid = security.dom_sid(security.SID_NT_SELF)
|
||||
self.assertEquals(facl.as_sddl(anysid), NTACL_SDDL)
|
||||
os.unlink(os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_getntacl_param(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
setntacl(lp, self.tempf, NTACL_SDDL, DOMAIN_SID, "tdb",
|
||||
os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
facl = getntacl(lp, self.tempf, "tdb", os.path.join(
|
||||
self.tempdir, "eadbtest.tdb"))
|
||||
domsid = security.dom_sid(security.SID_NT_SELF)
|
||||
self.assertEquals(facl.as_sddl(domsid), NTACL_SDDL)
|
||||
os.unlink(os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_invalidbackend(self):
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
self.assertRaises(XattrBackendError, setntacl, lp, self.tempf,
|
||||
NTACL_SDDL, DOMAIN_SID, "ttdb",
|
||||
os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
|
||||
def test_setntacl_forcenative(self):
|
||||
if os.getuid() == 0:
|
||||
raise SkipTest("Running test as root, test skipped")
|
||||
lp = LoadParm()
|
||||
open(self.tempf, 'w').write("empty")
|
||||
lp.set("posix:eadb", os.path.join(self.tempdir, "eadbtest.tdb"))
|
||||
self.assertRaises(Exception, setntacl, lp, self.tempf, NTACL_SDDL,
|
||||
DOMAIN_SID, "native")
|
||||
|
Loading…
Reference in New Issue
Block a user