コード例 #1
0
ファイル: unit.py プロジェクト: SSITB/splunk-modular-input
    def test_get_dict_object(self):
        d = {
            'a': {
                'b': {
                    'c': 'C'
                }
            }
        }

        self.assertEqual(ServerInfo.get_dict_object(d, ['a', 'b', 'c']), 'C')
コード例 #2
0
ファイル: unit.py プロジェクト: SSITB/splunk-modular-input
    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)