mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updating the reverse octal lookup dictionary. Updating tests.
This commit is contained in:
parent
24c907be01
commit
bfdb6691ff
2 changed files with 8 additions and 12 deletions
|
@ -63,14 +63,7 @@ def present(name, acl_type, acl_name='', perms='', recurse=False):
|
|||
'comment': ''}
|
||||
|
||||
_octal = {'r': 4, 'w': 2, 'x': 1, '-': 0}
|
||||
_octal_lookup = {'0': '-',
|
||||
'1': 'x',
|
||||
'2': 'w',
|
||||
'3': 'wx',
|
||||
'4': 'r',
|
||||
'5': 'rx',
|
||||
'6': 'rw',
|
||||
'7': 'rwx'}
|
||||
_octal_lookup = {0: '-', 1: 'r', 2: 'w', 4: 'x'}
|
||||
|
||||
if not os.path.exists(name):
|
||||
ret['comment'] = '{0} does not exist'.format(name)
|
||||
|
@ -122,7 +115,10 @@ def present(name, acl_type, acl_name='', perms='', recurse=False):
|
|||
if not need_refresh:
|
||||
ret['comment'] = 'Permissions are in the desired state'
|
||||
else:
|
||||
new_perms = _octal_lookup[six.text_type(user[_search_name]['octal'])]
|
||||
_num = user[_search_name]['octal']
|
||||
new_perms = '{}{}{}'.format(_octal_lookup[_num&1],
|
||||
_octal_lookup[_num&2],
|
||||
_octal_lookup[_num&4])
|
||||
changes = {'new': {'acl_name': acl_name,
|
||||
'acl_type': acl_type,
|
||||
'perms': perms},
|
||||
|
|
|
@ -65,7 +65,7 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with patch.dict(linux_acl.__salt__, {'acl.getfacl': mock}):
|
||||
# Update - test=True
|
||||
with patch.dict(linux_acl.__opts__, {'test': True}):
|
||||
comt = ('Updated permissions will be applied for {0}: rx -> {1}'
|
||||
comt = ('Updated permissions will be applied for {0}: r-x -> {1}'
|
||||
''.format(acl_name, perms))
|
||||
ret = {'name': name,
|
||||
'comment': comt,
|
||||
|
@ -75,7 +75,7 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'perms': perms},
|
||||
'old': {'acl_name': acl_name,
|
||||
'acl_type': acl_type,
|
||||
'perms': 'rx'}},
|
||||
'perms': 'r-x'}},
|
||||
'result': None}
|
||||
|
||||
self.assertDictEqual(linux_acl.present(name, acl_type, acl_name,
|
||||
|
@ -91,7 +91,7 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'perms': perms},
|
||||
'old': {'acl_name': acl_name,
|
||||
'acl_type': acl_type,
|
||||
'perms': 'rx'}},
|
||||
'perms': 'r-x'}},
|
||||
'pchanges': {},
|
||||
'result': True}
|
||||
self.assertDictEqual(linux_acl.present(name, acl_type,
|
||||
|
|
Loading…
Add table
Reference in a new issue