<s> """<STR_LIT>""" <EOL> from samba . ntacls import setntacl , getntacl , XattrBackendError <EOL> from samba . dcerpc import xattr , security <EOL> from samba . param import LoadParm <EOL> from samba . tests import TestCaseInTempDir , TestSkipped <EOL> import random <EOL> import os <EOL> class NtaclsTests ( TestCaseInTempDir ) : <EOL> def test_setntacl ( self ) : <EOL> lp = LoadParm ( ) <EOL> acl = "<STR_LIT>" <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> lp . set ( "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> setntacl ( lp , self . tempf , acl , "<STR_LIT>" ) <EOL> os . unlink ( os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> def test_setntacl_getntacl ( self ) : <EOL> lp = LoadParm ( ) <EOL> acl = "<STR_LIT>" <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> lp . set ( "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> setntacl ( lp , self . tempf , acl , "<STR_LIT>" ) <EOL> facl = getntacl ( lp , self . tempf ) <EOL> anysid = security . dom_sid ( security . SID_NT_SELF ) <EOL> self . assertEquals ( facl . as_sddl ( anysid ) , acl ) <EOL> os . unlink ( os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> def test_setntacl_getntacl_param ( self ) : <EOL> lp = LoadParm ( ) <EOL> acl = "<STR_LIT>" <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> setntacl ( lp , self . tempf , acl , "<STR_LIT>" , "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> facl = getntacl ( lp , self . tempf , "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> domsid = security . dom_sid ( security . SID_NT_SELF ) <EOL> self . assertEquals ( facl . as_sddl ( domsid ) , acl ) <EOL> os . unlink ( os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> def test_setntacl_invalidbackend ( self ) : <EOL> lp = LoadParm ( ) <EOL> acl = "<STR_LIT>" <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> self . assertRaises ( XattrBackendError , setntacl , lp , self . tempf , acl , "<STR_LIT>" , "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> def test_setntacl_forcenative ( self ) : <EOL> if os . getuid ( ) == <NUM_LIT:0> : <EOL> raise TestSkipped ( "<STR_LIT>" ) <EOL> lp = LoadParm ( ) <EOL> acl = "<STR_LIT>" <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> lp . set ( "<STR_LIT>" , os . path . join ( self . tempdir , "<STR_LIT>" ) ) <EOL> self . assertRaises ( Exception , setntacl , lp , self . tempf , acl , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> def setUp ( self ) : <EOL> super ( NtaclsTests , self ) . setUp ( ) <EOL> self . tempf = os . path . join ( self . tempdir , "<STR_LIT:test>" ) <EOL> open ( self . tempf , '<STR_LIT:w>' ) . write ( "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> os . unlink ( self . tempf ) <EOL> super ( NtaclsTests , self ) . tearDown ( ) </s>
