<s> from __future__ import unicode_literals <EOL> import os , sys <EOL> import operator <EOL> import win32api <EOL> import win32con <EOL> import win32security <EOL> import ntsecuritycon <EOL> import tempfile <EOL> from winsys . _compat import unittest <EOL> from winsys . tests import utils as testutils <EOL> from winsys import accounts <EOL> from winsys . _security import _aces , _acls <EOL> everyone , _ , _ = win32security . LookupAccountName ( None , "<STR_LIT>" ) <EOL> me , _ , _ = win32security . LookupAccountName ( None , win32api . GetUserNameEx ( win32con . NameSamCompatible ) ) <EOL> @ unittest . skipUnless ( testutils . i_am_admin ( ) , "<STR_LIT>" ) <EOL> class TestACLs ( unittest . TestCase ) : <EOL> def test_acl_None ( self ) : <EOL> acl = _acls . acl ( None ) <EOL> assert isinstance ( acl , _acls . ACL ) and acl . pyobject ( ) is None <EOL> def test_acl_PyACL ( self ) : <EOL> dacl = win32security . ACL ( ) <EOL> dacl . AddAccessAllowedAceEx ( win32security . ACL_REVISION_DS , <NUM_LIT:0> , ntsecuritycon . FILE_READ_DATA , everyone ) <EOL> acl = _acls . acl ( dacl ) . pyobject ( ) <EOL> assert dacl . GetAceCount ( ) == <NUM_LIT:1> <EOL> assert dacl . GetAce ( <NUM_LIT:0> ) == ( ( win32security . ACCESS_ALLOWED_ACE_TYPE , <NUM_LIT:0> ) , ntsecuritycon . FILE_READ_DATA , everyone ) <EOL> def test_acl_ACL ( self ) : <EOL> acl0 = _acls . ACL ( ) <EOL> acl = _acls . acl ( acl0 ) <EOL> assert acl is acl0 <EOL> def test_acl_iterable ( self ) : <EOL> daces0 = [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] <EOL> def iteraces ( ) : <EOL> for dace in daces0 : <EOL> yield dace <EOL> assert list ( _acls . dacl ( iteraces ( ) ) ) == list ( _aces . dace ( dace ) for dace in daces0 ) <EOL> def test_ACL_iterated ( self ) : <EOL> acl = _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] ) <EOL> assert list ( acl ) == [ <EOL> _aces . dace ( ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ) , <EOL> _aces . dace ( ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> ] <EOL> def test_ACL_append ( self ) : <EOL> acl = _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) ] ) <EOL> acl . append ( ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ) <EOL> assert list ( acl ) == [ <EOL> _aces . dace ( ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ) , <EOL> _aces . dace ( ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> ] <EOL> def test_ACL_getitem ( self ) : <EOL> acl = _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] ) <EOL> assert acl [ <NUM_LIT:0> ] == ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) <EOL> def test_ACL_setitem ( self ) : <EOL> acl = _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] ) <EOL> acl [ <NUM_LIT:0> ] = ( ( me , "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> assert acl [ <NUM_LIT:0> ] == ( me , "<STR_LIT:R>" , "<STR_LIT>" ) <EOL> def test_ACL_delitem ( self ) : <EOL> acl = _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] ) <EOL> del acl [ <NUM_LIT:0> ] <EOL> assert list ( acl ) == [ <EOL> _aces . dace ( ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ) , <EOL> ] <EOL> def test_ACL_len ( self ) : <EOL> aces = [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] <EOL> acl = _acls . acl ( aces ) <EOL> assert len ( acl ) == len ( aces ) <EOL> def test_ACL_nonzero ( self ) : <EOL> assert not _acls . acl ( None ) <EOL> assert not _acls . acl ( [ ] ) <EOL> assert _acls . acl ( [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) ] ) <EOL> def test_ACL_contains ( self ) : <EOL> aces = [ ( "<STR_LIT>" , "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] <EOL> acl = _acls . acl ( aces ) <EOL> for ace in aces : <EOL> assert ace in acl <EOL> assert ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) not in acl <EOL> def test_DACL_public ( self ) : <EOL> acl = _acls . DACL . public ( ) <EOL> assert list ( acl ) == [ ( "<STR_LIT>" , "<STR_LIT:F>" , "<STR_LIT>" ) ] <EOL> def test_DACL_private ( self ) : <EOL> acl = _acls . DACL . private ( ) <EOL> assert list ( acl ) == [ ( me , "<STR_LIT:F>" , "<STR_LIT>" ) ] <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) <EOL> if sys . stdout . isatty ( ) : <EOL> raw_input ( "<STR_LIT>" ) </s>
