Example #1
0
def check_contact_permissions(command, auth):
    cmd_group,param = get_command_group_and_arg(command)
    LOGGER.debug("cmd_group: %s, param: %s", cmd_group, param)

    LOGGER.debug("Checking if contact {0} has permissions to execute {1}".format(auth,command))

    check_function_name = "check_auth_%s" % cmd_group.lower()
    if not eval(check_function_name)(auth, param):
        raise ValueError('{0} is not allowed to run {1} or target is empty'.format(auth,command))
    else:
        LOGGER.debug("Access allowed")
Example #2
0
def check_contact_permissions(command, auth):
    cmd_group, param = get_command_group_and_arg(command)
    LOGGER.debug("cmd_group: %s, param: %s", cmd_group, param)

    LOGGER.debug(
        "Checking if contact {0} has permissions to execute {1}".format(
            auth, command))

    check_function_name = "check_auth_%s" % cmd_group.lower()
    if not eval(check_function_name)(auth, param):
        raise ValueError(
            '{0} is not allowed to run {1} or target is empty'.format(
                auth, command))
    else:
        LOGGER.debug("Access allowed")
 def test_get_command_group_and_arg_for_servicegroup_commands_with_semicolon(self):
     group,arg = get_command_group_and_arg("DISABLE_SERVICEGROUP_HOST_CHECKS;")
     self.assertEqual(group, "SERVICEGROUPNAME_CMDS")
     self.assertEqual(arg, '')
 def test_get_command_group_and_arg_for_servicegroup_commands_without_host(self):
     group,arg = get_command_group_and_arg("DISABLE_SERVICEGROUP_HOST_CHECKS")
     self.assertEqual(group, "SERVICEGROUPNAME_CMDS")
     self.assertEqual(arg, None)
 def test_get_command_group_and_arg_for_hostname_commands_with_host(self):
     hostname = "HOST"
     group,arg = get_command_group_and_arg("ACKNOWLEDGE_HOST_PROBLEM;%s" % hostname)
     self.assertEqual(group, "HOSTNAME_CMDS")
     self.assertEqual(arg, hostname)
 def test_get_command_group_and_arg_for_disabled_commands(self):
     group,arg = get_command_group_and_arg("DEL_DOWNTIME_BY_START_TIME_COMMENT")
     self.assertEqual(group, "DISABLED_CMDS")
 def test_get_command_group_and_arg_for_global_command(self):
     group,arg = get_command_group_and_arg("CHANGE_GLOBAL_HOST_EVENT_HANDLER")
     self.assertEqual(group, "GLOBAL_CMDS")
Example #8
0
 def test_get_command_group_and_arg_for_servicegroup_commands_with_semicolon(
         self):
     group, arg = get_command_group_and_arg(
         "DISABLE_SERVICEGROUP_HOST_CHECKS;")
     self.assertEqual(group, "SERVICEGROUPNAME_CMDS")
     self.assertEqual(arg, '')
Example #9
0
 def test_get_command_group_and_arg_for_servicegroup_commands_without_host(
         self):
     group, arg = get_command_group_and_arg(
         "DISABLE_SERVICEGROUP_HOST_CHECKS")
     self.assertEqual(group, "SERVICEGROUPNAME_CMDS")
     self.assertEqual(arg, None)
Example #10
0
 def test_get_command_group_and_arg_for_hostname_commands_with_host(self):
     hostname = "HOST"
     group, arg = get_command_group_and_arg("ACKNOWLEDGE_HOST_PROBLEM;%s" %
                                            hostname)
     self.assertEqual(group, "HOSTNAME_CMDS")
     self.assertEqual(arg, hostname)
Example #11
0
 def test_get_command_group_and_arg_for_disabled_commands(self):
     group, arg = get_command_group_and_arg(
         "DEL_DOWNTIME_BY_START_TIME_COMMENT")
     self.assertEqual(group, "DISABLED_CMDS")
Example #12
0
 def test_get_command_group_and_arg_for_global_command(self):
     group, arg = get_command_group_and_arg(
         "CHANGE_GLOBAL_HOST_EVENT_HANDLER")
     self.assertEqual(group, "GLOBAL_CMDS")