def setUp(self): self.temp_file = temp.file(parent=RUNTIME_VARS.TMP) win_dacl.set_owner(obj_name=self.temp_file, principal=self.current_user) win_dacl.set_inheritance(obj_name=self.temp_file, enabled=True) self.assertEqual(win_dacl.get_owner(obj_name=self.temp_file), self.current_user)
def test_inheritance(self): """ Test the set_inheritance function Test the get_inheritance function """ self.assertTrue( win_dacl.set_inheritance( obj_name=self.obj_name, enabled=True, obj_type=self.obj_type, clear=False, )) self.assertTrue( win_dacl.get_inheritance(obj_name=self.obj_name, obj_type=self.obj_type)) self.assertTrue( win_dacl.set_inheritance( obj_name=self.obj_name, enabled=False, obj_type=self.obj_type, clear=False, )) self.assertFalse( win_dacl.get_inheritance(obj_name=self.obj_name, obj_type=self.obj_type))
def test_check_perms_reset_test_true(self): """ Test resetting perms with test=True. This shows minimal changes """ # Turn off inheritance win_dacl.set_inheritance(obj_name=self.temp_file, enabled=False, clear=True) # Set some permissions win_dacl.set_permissions( obj_name=self.temp_file, principal="Administrator", permissions="full_control", ) expected = { "comment": "", "changes": { "perms": { "Administrators": { "grant": "full_control" }, "Users": { "grant": "read_execute" }, }, "remove_perms": { "Administrator": { "grant": { "applies to": "Not Inherited (file)", "permissions": "Full control", } } }, }, "name": self.temp_file, "result": None, } with patch.dict(win_dacl.__opts__, {"test": True}): ret = win_file.check_perms( path=self.temp_file, grant_perms={ "Users": { "perms": "read_execute" }, "Administrators": { "perms": "full_control" }, }, inheritance=False, reset=True, ) self.assertDictEqual(expected, ret)