def Run(self): # Fix the time to avoid regressions. with test_lib.FakeTime(42): client_id = self.SetupClient(0).Basename() if data_store.AFF4Enabled(): # Delete the certificates as it's being regenerated every time the # client is created. with aff4.FACTORY.Open(client_id, mode="rw", token=self.token) as client_obj: client_obj.DeleteAttribute(client_obj.Schema.CERT) flow_id = api_regression_test_lib.StartFlow(client_id, discovery.Interrogate, token=self.token) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id, "F:ABCDEF12") self.Check("GetFlow", args=flow_plugin.ApiGetFlowArgs(client_id=client_id, flow_id=flow_id), replace=replace) self._TerminateFlow(client_id, flow_id) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id, "F:ABCDEF13") # Fetch the same flow which is now should be marked as pending # termination. self.Check("GetFlow", args=flow_plugin.ApiGetFlowArgs(client_id=client_id, flow_id=flow_id), replace=replace)
def Run(self): # Fix the time to avoid regressions. with test_lib.FakeTime(42): client_id = self.SetupClient(0) flow_id = flow_test_lib.StartFlow( discovery.Interrogate, client_id=client_id, creator=self.token.username) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id, "F:ABCDEF12") self.Check( "GetFlow", args=flow_plugin.ApiGetFlowArgs(client_id=client_id, flow_id=flow_id), replace=replace) flow_base.TerminateFlow(client_id, flow_id, "Pending termination: Some reason") replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id, "F:ABCDEF13") # Fetch the same flow which is now should be marked as pending # termination. self.Check( "GetFlow", args=flow_plugin.ApiGetFlowArgs(client_id=client_id, flow_id=flow_id), replace=replace)
def Run(self): acl_test_lib.CreateUser(self.token.username) with test_lib.FakeTime(42): client_id = self.SetupClient(0) with test_lib.FakeTime(43): flow_id_1 = flow_test_lib.StartFlow( discovery.Interrogate, client_id, creator=self.token.username) with test_lib.FakeTime(44): flow_id_2 = flow_test_lib.StartFlow( processes.ListProcesses, client_id, creator=self.token.username) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_1, "F:ABCDEF10") replace.update( api_regression_test_lib.GetFlowTestReplaceDict(client_id, flow_id_2, "F:ABCDEF11")) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs(client_id=client_id), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, top_flows_only=True, ), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, min_started_at=rdfvalue.RDFDatetimeSeconds(44), top_flows_only=True, ), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, max_started_at=rdfvalue.RDFDatetimeSeconds(43), top_flows_only=True, ), replace=replace)
def ReplaceFlowId(): flows = data_store.REL_DB.ReadAllFlowObjects(client_id=client_id) self.assertNotEmpty(flows) flow_id = flows[0].flow_id return api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id)
def ReplaceFlowId(): if data_store.RelationalDBFlowsEnabled(): flows = data_store.REL_DB.ReadAllFlowObjects(client_id=client_id) self.assertNotEmpty(flows) flow_id = flows[0].flow_id else: flows_dir_fd = aff4.FACTORY.Open( client_urn.Add("flows"), token=self.token) flow_id = list(flows_dir_fd.ListChildren())[0].Basename() return api_regression_test_lib.GetFlowTestReplaceDict(client_id, flow_id)
def Run(self): acl_test_lib.CreateUser(self.token.username) with test_lib.FakeTime(42): client_id = self.SetupClient(0).Basename() with test_lib.FakeTime(43): flow_id_1 = api_regression_test_lib.StartFlow( client_id, discovery.Interrogate, token=self.token) with test_lib.FakeTime(44): flow_id_2 = api_regression_test_lib.StartFlow( client_id, processes.ListProcesses, token=self.token) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_1, "F:ABCDEF10") replace.update( api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_2, "F:ABCDEF11")) self.Check("ListFlows", args=flow_plugin.ApiListFlowsArgs(client_id=client_id), replace=replace)
def Run(self): client_id = self.SetupClient(0) with test_lib.FakeTime(42): flow_id = self._StartFlow(client_id, processes.ListProcesses) replace = api_regression_test_lib.GetFlowTestReplaceDict(client_id, flow_id) self.Check( "ListClientActionRequests", args=client_plugin.ApiListClientActionRequestsArgs(client_id=client_id), replace=replace) self.Check( "ListClientActionRequests", args=client_plugin.ApiListClientActionRequestsArgs( client_id=client_id, fetch_responses=True), replace=replace)
def Run(self): client_id = self.SetupClient(0) with test_lib.FakeTime(42): flow_id = flow_test_lib.StartFlow( processes.ListProcesses, client_id, creator=self.test_username) test_process = rdf_client.Process(name="test_process") mock = flow_test_lib.MockClient( client_id, action_mocks.ListProcessesMock([test_process])) mock.Next() replace = api_regression_test_lib.GetFlowTestReplaceDict(client_id, flow_id) self.Check( "ListFlowRequests", args=flow_plugin.ApiListFlowRequestsArgs( client_id=client_id, flow_id=flow_id), replace=replace)