예제 #1
0
    def test_get_dict_object(self):
        d = {
            'a': {
                'b': {
                    'c': 'C'
                }
            }
        }

        self.assertEqual(ServerInfo.get_dict_object(d, ['a', 'b', 'c']), 'C')
예제 #2
0
    def test_is_shc_captain(self):
        if self.username is not None and self.password is not None:
            import splunk
            try:
                session_key = splunk.auth.getSessionKey(username=self.username, password=self.password)

                # This assumes you are testing against a non-SHC environment
                self.assertEqual(ServerInfo.is_shc_captain(session_key), None)
            except splunk.SplunkdConnectionException:
                pass
        else:
            self.skipTest('Skipping test since Splunk authentication data is not available')
예제 #3
0
    def convertParams(self, name, cleaned_params, to_string=False):
        if not self.added_thread_limit_validator:
            # Only allow a thread limit of 25 if this is on cloud
            if ServerInfo.is_on_cloud(session_key=self.getSessionKey()):
                self.field_validators[self.PARAM_THREAD_LIMIT] = IntegerFieldValidator(1, 25)
            else:
                self.field_validators[self.PARAM_THREAD_LIMIT] = IntegerFieldValidator(1, 5000)

            self.added_thread_limit_validator = True

        # Call the super class convertParams()
        return super(WebsiteMonitoringRestHandler, self).convertParams(name, cleaned_params, to_string)
예제 #4
0
    def test_is_fips_mode(self):
        if self.username is not None and self.password is not None:
            from splunk.auth import getSessionKey
            from splunk import SplunkdConnectionException
            try:
                session_key = getSessionKey(username=self.username,
                                            password=self.password)

                # This assumes you are testing against a non-FIPS environment
                self.assertEqual(ServerInfo.is_fips_mode(session_key), False)
            except SplunkdConnectionException:
                pass
        else:
            self.skipTest(
                'Skipping test since Splunk authentication data is not available'
            )
예제 #5
0
    def handleList(self, confInfo):
        """
        Provide the list of configuration options.

        Arguments
        confInfo -- The object containing the information about what is being requested.
        """

        # Read the current settings from the conf file
        confDict = self.readConf(self.conf_file)

        # Set the settings
        if confDict != None:
            for stanza, settings in confDict.items():
                for key, val in settings.items():
                    if key == self.PARAM_THREAD_LIMIT and int(val) > 25 and ServerInfo.is_on_cloud(session_key=self.getSessionKey()):
                        confInfo[stanza].append(key, 25)
                    else:
                        confInfo[stanza].append(key, val)