class AccountTestCase(unittest.TestCase): """Test case for account methods.""" test_user = '******' def setup_class(self): self.patcher = patch('passivetotal.api.Client._get', fake_request) self.patcher.start() self.client = AccountClient('--No-User--', '--No-Key--') def teardown_class(self): self.patcher.stop() def test_account_details(self): response = self.client.get_account_details() assert (response.get('firstName', '')) == 'John' assert (response.get('lastName', '')) == 'Doe' assert (response.get('organization', '')) == 'PassiveTotal' def test_account_history(self): response = self.client.get_account_history() assert('history' in response) assert(response['history'][0]['username']) == self.test_user def test_account_monitors(self): response = self.client.get_account_monitors() assert('monitors' in response) assert(response['monitors'][0]['focus']) == "37.139.30.161" def test_account_notifications(self): response = self.client.get_account_notifications() assert('notifications' in response) assert(response['notifications'][0]['username']) == self.test_user def test_account_sources(self): response = self.client.get_account_sources() assert('sources' in response) assert(response['sources'][0]['source']) == 'riskiq' def test_account_organization(self): response = self.client.get_account_organization() assert(response['admins'][0]) == '*****@*****.**' def test_account_organization_teamstream(self): response = self.client.get_account_organization_teamstream() assert('teamstream' in response) assert(response['teamstream'][0]['username']) == self.test_user
class AccountTestCase(unittest.TestCase): """Test case for account methods.""" test_user = '******' def setup_class(self): self.patcher = patch('passivetotal.api.Client._get', fake_request) self.patcher.start() self.client = AccountClient('--No-User--', '--No-Key--') def teardown_class(self): self.patcher.stop() def test_account_details(self): response = self.client.get_account_details() assert (response.get('firstName', '')) == 'John' assert (response.get('lastName', '')) == 'Doe' assert (response.get('organization', '')) == 'PassiveTotal' def test_account_history(self): response = self.client.get_account_history() assert ('history' in response) assert (response['history'][0]['username']) == self.test_user def test_account_monitors(self): response = self.client.get_account_monitors() assert ('monitors' in response) assert (response['monitors'][0]['focus']) == "37.139.30.161" def test_account_notifications(self): response = self.client.get_account_notifications() assert ('notifications' in response) assert (response['notifications'][0]['username']) == self.test_user def test_account_sources(self): response = self.client.get_account_sources() assert ('sources' in response) assert (response['sources'][0]['source']) == 'riskiq' def test_account_organization(self): response = self.client.get_account_organization() assert (response['admins'][0]) == '*****@*****.**' def test_account_organization_teamstream(self): response = self.client.get_account_organization_teamstream() assert ('teamstream' in response) assert (response['teamstream'][0]['username']) == self.test_user
def setup_class(self): self.patcher = patch('passivetotal.api.Client._get', fake_request) self.patcher.start() self.client = AccountClient('--No-User--', '--No-Key--')
from passivetotal.libs.account import AccountClient from utilities import build_headers from utilities import get_config from utilities import setup_logging logger = setup_logging() try: logger.info("Starting command processing") input_events, dummyresults, settings = splunk.Intersplunk.getOrganizedResults( ) keywords, options = splunk.Intersplunk.getKeywordsAndOptions() configuration = get_config("passivetotal", "api-setup") username = configuration.get('username', None) api_key = configuration.get('apikey', None) output_events = list() tmp = AccountClient( username, api_key, headers=build_headers()).get_account_organization_teamstream() for item in tmp.get('teamstream', []): if item['type'] != 'search': continue output_events.append(item) splunk.Intersplunk.outputResults(output_events) except Exception, e: stack = traceback.format_exc() splunk.Intersplunk.generateErrorResults(str(e)) logger.error(str(e) + ". Traceback: " + str(stack))
import traceback from passivetotal.libs.account import AccountClient from utilities import build_headers from utilities import get_config from utilities import setup_logging logger = setup_logging() try: logger.info("Starting command processing") input_events, dummyresults, settings = splunk.Intersplunk.getOrganizedResults() keywords, options = splunk.Intersplunk.getKeywordsAndOptions() configuration = get_config("passivetotal", "api-setup") username = configuration.get('username', None) api_key = configuration.get('apikey', None) output_events = list() tmp = AccountClient(username, api_key, headers=build_headers()).get_account_organization_teamstream() for item in tmp.get('teamstream', []): if item['type'] != 'search': continue output_events.append(item) splunk.Intersplunk.outputResults(output_events) except Exception, e: stack = traceback.format_exc() splunk.Intersplunk.generateErrorResults(str(e)) logger.error(str(e) + ". Traceback: " + str(stack))