コード例 #1
0
ファイル: flow_test.py プロジェクト: viszsec/grr
    def testUnscheduleFlowRemovesScheduledFlow(self, db: abstract_db.Database):
        token = _CreateToken(db)
        client_id = db_test_utils.InitializeClient(db)

        handler = flow_plugin.ApiScheduleFlowHandler()
        sf1 = handler.Handle(flow_plugin.ApiCreateFlowArgs(
            client_id=client_id,
            flow=flow_plugin.ApiFlow(
                name=file.CollectSingleFile.__name__,
                args=rdf_file_finder.CollectSingleFileArgs(path="/foo"),
                runner_args=rdf_flow_runner.FlowRunnerArgs(cpu_limit=60))),
                             token=token)
        sf2 = handler.Handle(flow_plugin.ApiCreateFlowArgs(
            client_id=client_id,
            flow=flow_plugin.ApiFlow(
                name=file.CollectSingleFile.__name__,
                args=rdf_file_finder.CollectSingleFileArgs(path="/foo"),
                runner_args=rdf_flow_runner.FlowRunnerArgs(cpu_limit=60))),
                             token=token)

        handler = flow_plugin.ApiUnscheduleFlowHandler()
        args = flow_plugin.ApiUnscheduleFlowArgs(
            client_id=client_id, scheduled_flow_id=sf1.scheduled_flow_id)
        handler.Handle(args, token=token)

        handler = flow_plugin.ApiListScheduledFlowsHandler()
        args = flow_plugin.ApiListScheduledFlowsArgs(client_id=client_id,
                                                     creator=token.username)
        results = handler.Handle(args, token=token)

        self.assertEqual(results.scheduled_flows, [sf2])
コード例 #2
0
 def UnscheduleFlow(
     self,
     args: api_flow.ApiUnscheduleFlowArgs,
     context: Optional[api_call_context.ApiCallContext] = None,
 ) -> api_flow.ApiUnscheduleFlowHandler:
     return api_flow.ApiUnscheduleFlowHandler()
コード例 #3
0
 def UnscheduleFlow(
     self,
     args: api_flow.ApiUnscheduleFlowArgs,
     token: Optional[access_control.ACLToken] = None
 ) -> api_flow.ApiUnscheduleFlowHandler:
   return api_flow.ApiUnscheduleFlowHandler()