def test_integration_assign_user_to_investigation(self): log = logging.getLogger("Test") test_conn = Connection() test_action = AssignUserToInvestigation() test_conn.logger = log test_action.logger = log try: with open("../tests/assign_user_to_investigation.json") as file: test_json = json.loads(file.read()).get("body") connection_params = test_json.get("connection") action_params = test_json.get("input") except Exception as e: message = """ Could not find or read sample tests from /tests directory An exception here likely means you didn't fill out your samples correctly in the /tests directory Please use 'icon-plugin generate samples', and fill out the resulting test files in the /tests directory """ self.fail(message) test_conn.connect(connection_params) test_action.connection = test_conn results = test_action.run(action_params) keys = results.keys() self.assertTrue("success" in keys) self.assertTrue(results.get("success")) self.assertTrue("investigation" in keys) self.assertIsNotNone(results.get("investigation"))
def setup(self): log = logging.getLogger("Test") test_conn = Connection() test_action = AdvancedQueryOnLog() test_conn.logger = log test_action.logger = log try: with open("../tests/advanced_query_on_log.json") as file: test_json = json.loads(file.read()).get("body") connection_params = test_json.get("connection") action_params = test_json.get("input") except Exception as e: self.fail("Likely could not find tests in test directory. Generate and fill out samples to fix this.") return action_params, connection_params, test_action, test_conn
def test_integration_set_status_of_investigation_action(self): """ TODO: Implement assertions at the end of this test case This is an integration test that will connect to the services your plugin uses. It should be used as the basis for tests below that can run independent of a "live" connection. This test assumes a normal plugin structure with a /tests directory. In that /tests directory should be json samples that contain all the data needed to run this test. To generate samples run: icon-plugin generate samples """ log = logging.getLogger("Test") test_conn = Connection() test_action = SetStatusOfInvestigationAction() test_conn.logger = log test_action.logger = log try: with open("../tests/set_status_of_investigation_action.json") as file: test_json = json.loads(file.read()).get("body") connection_params = test_json.get("connection") action_params = test_json.get("input") except Exception as e: message = """ Could not find or read sample tests from /tests directory An exception here likely means you didn't fill out your samples correctly in the /tests directory Please use 'icon-plugin generate samples', and fill out the resulting test files in the /tests directory """ self.fail(message) test_conn.connect(connection_params) test_action.connection = test_conn results = test_action.run(action_params) # TODO: Remove this line self.fail("Unimplemented test case") # TODO: The following assert should be updated to look for data from your action # For example: self.assertEquals({"success": True}, results) self.assertEquals({}, results)