示例#1
0
文件: flow_test.py 项目: tkuennen/grr
    def testWorksCorrectlyWithTestOutputPluginOnFlowWithSingleResult(self):
        with test_lib.FakeTime(42):
            flow_urn = flow.GRRFlow.StartFlow(
                flow_name=flow_test_lib.DummyFlowWithSingleReply.__name__,
                client_id=self.client_id,
                token=self.token)

            for _ in flow_test_lib.TestFlowHelper(flow_urn, token=self.token):
                pass

        result = self.handler.Handle(flow_plugin.ApiGetExportedFlowResultsArgs(
            client_id=self.client_id,
            flow_id=flow_urn.Basename(),
            plugin_name=test_plugins.TestInstantOutputPlugin.plugin_name),
                                     token=self.token)

        chunks = list(result.GenerateContent())

        self.assertListEqual(chunks, [
            "Start: %s" % utils.SmartStr(flow_urn),
            "Values of type: RDFString",
            "First pass: oh (source=%s)" % utils.SmartStr(self.client_id),
            "Second pass: oh (source=%s)" % utils.SmartStr(self.client_id),
            "Finish: %s" % utils.SmartStr(flow_urn)
        ])  # pyformat: disable
示例#2
0
    def MockMethodIsCalled():
      try:
        mock_method.assert_called_once_with(
            api_flow.ApiGetExportedFlowResultsArgs(
                client_id=self.client_id.Basename(),
                flow_id=flow_urn.Basename(),
                plugin_name="csv-zip"),
            token=mock.ANY)

        return True
      except AssertionError:
        return False
    def testAllClientFlowsMethodsAreAccessChecked(self):
        args = api_flow.ApiListFlowsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlows,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiGetFlowArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFlow,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiCreateFlowArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.CreateFlow,
                                        "CheckClientAccess",
                                        args=args)
        self.CheckMethodIsAccessChecked(self.router.CreateFlow,
                                        "CheckIfCanStartFlow",
                                        args=args)

        args = api_flow.ApiCancelFlowArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.CancelFlow,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowRequestsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowRequests,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowResultsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowResults,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiGetExportedFlowResultsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetExportedFlowResults,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiGetFlowResultsExportCommandArgs(
            client_id=self.client_id)
        self.CheckMethodIsAccessChecked(
            self.router.GetFlowResultsExportCommand,
            "CheckClientAccess",
            args=args)

        args = api_flow.ApiGetFlowFilesArchiveArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFlowFilesArchive,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowOutputPluginsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowOutputPlugins,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowOutputPluginLogsArgs(
            client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowOutputPluginLogs,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowOutputPluginErrorsArgs(
            client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowOutputPluginErrors,
                                        "CheckClientAccess",
                                        args=args)

        args = api_flow.ApiListFlowLogsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.ListFlowLogs,
                                        "CheckClientAccess",
                                        args=args)