Example #1
0
  def testUpdatesResultsOfRunningFlowDynamically(self):
    flow_args = webhistory.CollectBrowserHistoryArgs(
        browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
    flow_id = flow_test_lib.StartFlow(
        webhistory.CollectBrowserHistory,
        creator=self.token.username,
        client_id=self.client_id,
        flow_args=flow_args)

    self.Open(f"/v2/clients/{self.client_id}")
    self.Click("css=.flow-title:contains('Browser History')")

    progress_0_results = webhistory.CollectBrowserHistoryProgress(browsers=[
        webhistory.BrowserProgress(
            browser=webhistory.Browser.CHROME,
            status=webhistory.BrowserProgress.Status.IN_PROGRESS,
            num_collected_files=0,
        )
    ])
    with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory,
                                            progress_0_results):
      self.WaitUntil(self.IsElementPresent, "css=div.title:contains('Chrome')")
      self.WaitUntilNot(self.IsElementPresent,
                        "css=.header:contains('arrow_right')")

    flow_test_lib.AddResultsToFlow(
        self.client_id,
        flow_id, [_GenResults(webhistory.Browser.CHROME, i) for i in range(10)],
        tag="CHROME")
    progress_10_results = webhistory.CollectBrowserHistoryProgress(browsers=[
        webhistory.BrowserProgress(
            browser=webhistory.Browser.CHROME,
            status=webhistory.BrowserProgress.Status.IN_PROGRESS,
            num_collected_files=10,
        )
    ])
    with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory,
                                            progress_10_results):
      self.WaitUntil(self.IsElementPresent,
                     "css=.header:contains('arrow_right')")
      self.Click("css=div.title:contains('Chrome')")
      self.WaitUntilEqual(10, self.GetCssCount, "css=tr:contains('/home/foo')")

    flow_test_lib.AddResultsToFlow(
        self.client_id,
        flow_id, [_GenResults(webhistory.Browser.CHROME, 11)],
        tag="CHROME")
    progress_11_results = webhistory.CollectBrowserHistoryProgress(browsers=[
        webhistory.BrowserProgress(
            browser=webhistory.Browser.CHROME,
            status=webhistory.BrowserProgress.Status.IN_PROGRESS,
            num_collected_files=11,
        )
    ])
    with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory,
                                            progress_11_results):
      self.WaitUntilEqual(11, self.GetCssCount, "css=tr:contains('/home/foo')")
Example #2
0
    def testShowsDownloadButtonOnFlowCompletion(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=0,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Make sure that the flow panel is already displayed...
            self.WaitUntil(self.IsElementPresent,
                           "css=.flow-title:contains('Browser History')")
            # ...and then check for the presence of the 'Download all' button.
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=a[mat-stroked-button]:contains('Download all')")

        flow_test_lib.MarkFlowAsFinished(self.client_id, flow_id)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=1,
                    ),
                ])):
            with flow_test_lib.FlowResultMetadataOverride(
                    webhistory.CollectBrowserHistory,
                    rdf_flow_objects.FlowResultMetadata(
                        is_metadata_set=True,
                        num_results_per_type_tag=[
                            rdf_flow_objects.FlowResultCount(
                                type=webhistory.CollectBrowserHistoryResult.
                                __name__,
                                count=1)
                        ])):
                # The flow details view should get updated automatically.
                self.WaitUntil(
                    self.IsElementPresent,
                    "css=a[mat-stroked-button]:contains('Download')")
Example #3
0
    def testCorrectlyDisplaysCollectedResult(self):
        flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
        flow_test_lib.StartFlow(file.CollectSingleFile,
                                creator=self.test_username,
                                client_id=self.client_id,
                                flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                file.CollectSingleFile,
                rdf_file_finder.CollectSingleFileProgress(
                    status=rdf_file_finder.CollectSingleFileProgress.Status.
                    COLLECTED,
                    result=self._GenSampleResult())):

            self.Open(f"/v2/clients/{self.client_id}")
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-single-file-details .collected-result:contains('/etc/hosts')"
            )
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-single-file-details .collected-result:contains('4.14 KiB')"
            )
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=collect-single-file-details .requested-path")
Example #4
0
    def testDisplaysFailedResult(self):
        flow_args = rdf_file_finder.CollectFilesByKnownPathArgs(
            paths=["/file0", "/file1"])
        flow_id = flow_test_lib.StartFlow(file.CollectFilesByKnownPath,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id, flow_id,
            [self._GenFailedResult(i) for i in range(2)])

        with flow_test_lib.FlowProgressOverride(
                file.CollectFilesByKnownPath,
                rdf_file_finder.CollectFilesByKnownPathProgress(num_failed=2)):
            self.Open(f"/v2/clients/{self.client_id}")
            self.Click(
                "css=collect-files-by-known-path-details result-accordion:contains('/file0 + 1 more')"
            )

            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .mat-tab-label-content:contains('2 errors')"
            )
            for i in range(2):
                self.WaitUntil(
                    self.IsElementPresent,
                    f"css=collect-files-by-known-path-details .results:contains('errormsg{i}')"
                )
Example #5
0
    def testCorrectlyDisplaysMultiGetFileResults(self):
        flow_args = transfer.MultiGetFileArgs(pathspecs=[
            rdf_paths.PathSpec.OS(path=f"/somefile{i}") for i in range(10)
        ])
        flow_id = flow_test_lib.StartFlow(transfer.MultiGetFile,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                transfer.MultiGetFile,
                transfer.MultiGetFileProgress(num_pending_hashes=0,
                                              num_pending_files=2,
                                              num_skipped=0,
                                              num_collected=3,
                                              num_failed=5)):
            self.Open(f"/v2/clients/{self.client_id}")
            self.WaitUntil(self.IsElementPresent,
                           "css=.flow-title:contains('MultiGetFile')")

            flow_test_lib.AddResultsToFlow(
                self.client_id, flow_id,
                [self._GenSampleResult(i) for i in range(3)])

            self.Click(
                "css=multi-get-file-flow-details result-accordion .title:contains('/somefile0 + 9 more')"
            )
            for i in range(3):
                self.WaitUntil(
                    self.IsElementPresent,
                    f"css=multi-get-file-flow-details td:contains('/somefile{i}')"
                )
Example #6
0
    def testDisplaysOnlyWhenCollected(self):
        flow_args = rdf_file_finder.CollectFilesByKnownPathArgs(
            paths=["/file0"])
        flow_test_lib.StartFlow(file.CollectFilesByKnownPath,
                                creator=self.test_username,
                                client_id=self.client_id,
                                flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                file.CollectFilesByKnownPath,
                rdf_file_finder.CollectFilesByKnownPathProgress(
                    num_in_progress=1)):
            self.Open(f"/v2/clients/{self.client_id}")
            self.WaitUntil(
                self.IsElementPresent,
                "css=.flow-title:contains('File contents by exact path')")
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details result-accordion:contains('/file0')"
            )
            self.Click(
                "css=collect-files-by-known-path-details result-accordion:contains('/file0')"
            )
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .results:contains('No data')"
            )
Example #7
0
    def testCorrectlyDisplaysSuccessStateForSingleBrowser(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                creator=self.token.username,
                                client_id=self.client_id,
                                flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=1,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            self.WaitUntil(
                self.IsElementPresent,
                "css=.row:contains('Chrome') .success:contains('1 file collected')"
            )
            # Check that other browsers are not shown.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Opera')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Safari')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Internet Explorer')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Firefox')")
Example #8
0
    def testDisplaysAndHidesResultsForSingleBrowser(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(browsers=[
            webhistory.CollectBrowserHistoryArgs.Browser.CHROME,
            webhistory.CollectBrowserHistoryArgs.Browser.OPERA,
        ])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id, [_GenResults(webhistory.Browser.CHROME, 0)],
            tag="CHROME")
        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id, [_GenResults(webhistory.Browser.OPERA, 0)],
            tag="OPERA")
        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=1,
                    ),
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.OPERA,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=1,
                    )
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            self.Click("css=.flow-title:contains('Browser History')")

            self.ScrollIntoView("css=div.title:contains('Chrome')")
            self.Click("css=div.title:contains('Chrome')")
            self.WaitUntil(self.IsElementPresent,
                           "css=.results tr:contains('/home/foo/chrome-0')")
            # Only Chrome's results should be shown.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.results tr:contains('/home/foo/opera-0')")
            # Second click should toggle the browser results view.
            self.Click("css=div.title:contains('Chrome')")
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=.results tr:contains('/home/foo/chrome-0')")

            self.Click("css=div.title:contains('Opera')")
            self.WaitUntil(self.IsElementPresent,
                           "css=.results tr:contains('/home/foo/opera-0')")
            # Only Opera's results should be shown.
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=.results tr:contains('/home/foo/chrome-0')")
            # Second click should toggle the browser results view.
            self.Click("css=div.title:contains('Opera')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.results tr:contains('/home/foo/opera-9')")
Example #9
0
    def testDisplaysMultipleResultsForSingleBrowser(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id,
            [_GenResults(webhistory.Browser.CHROME, i) for i in range(200)],
            tag="CHROME")

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=200,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            # Expand the browser.
            self.Click("css=div.title:contains('Chrome')")
            # Update pagination to display all the results.
            self.MatSelect("css=.top-paginator mat-select", "100")
            # Check that only first 100 results are visible. First row is the table
            # header, so we start with 1.
            self.WaitUntil(self.IsElementPresent, "css=.results tr:nth(1)")
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=.results tr:nth(101):contains('/home/foo/chrome-99')")

            # Check that clicking Load More loads the rest. The button can be hidden
            # under the approval bottom sheet, so for now we workaround by clicking it
            # programmatically and not with a mouse event.
            self.WaitUntil(self.IsElementPresent,
                           "css=button:contains('Load More')")
            self.driver.execute_script(
                """$("button:contains('Load More')").click();""")
            # Update pagination to display all the results.
            self.MatSelect("css=.top-paginator mat-select", "500")

            self.WaitUntil(
                self.IsElementPresent,
                "css=.results tr:nth(200):contains('/home/foo/chrome-199')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.results tr:nth(201)")

            # Check that the "load more" button disappears when everything is loaded.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=button:contains('Load More')")
Example #10
0
    def testShowsDownloadButtonOnFlowCompletion(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.token.username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=0,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Make sure that the flow panel is already displayed...
            self.WaitUntil(self.IsElementPresent,
                           "css=.flow-title:contains('Browser History')")
            # ...and then check for the presence of the 'Download all' button.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=button:contains('Download all')")

        flow_test_lib.MarkFlowAsFinished(self.client_id, flow_id)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=1,
                    ),
                ])):
            # The flow details view should get updated automatically.
            self.WaitUntil(self.IsElementPresent,
                           "css=button:contains('Download all')")
Example #11
0
    def testDisplaysSuccessAndFailedResultAndWarning(self):
        flow_args = rdf_file_finder.CollectFilesByKnownPathArgs(
            paths=["/file0", "/file1"])
        flow_id = flow_test_lib.StartFlow(file.CollectFilesByKnownPath,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(self.client_id, flow_id, [
            self._GenFailedResult(0),
            self._GenCollectedResult(1),
        ])

        with flow_test_lib.FlowProgressOverride(
                file.CollectFilesByKnownPath,
                rdf_file_finder.CollectFilesByKnownPathProgress(
                    num_collected=1, num_raw_fs_access_retries=1,
                    num_failed=1)):
            self.Open(f"/v2/clients/{self.client_id}")
            self.Click(
                "css=collect-files-by-known-path-details result-accordion:contains('/file0 + 1 more')"
            )

            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .results:contains('1 file fetched by parsing the raw disk image with libtsk or libfsntfs.')"
            )

            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .mat-tab-label-content:contains('1 successful file collection')"
            )
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .results:contains('1 B')"
            )

            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .mat-tab-label-content:contains('1 error')"
            )
            self.Click(
                "css=collect-files-by-known-path-details .mat-tab-label-content:contains('1 error')"
            )
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-files-by-known-path-details .results:contains('errormsg0')"
            )
Example #12
0
  def testCorrectlyDisplaysNotFoundResult(self):
    flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
    flow_test_lib.StartFlow(
        file.CollectSingleFile,
        creator=self.token.username,
        client_id=self.client_id,
        flow_args=flow_args)

    with flow_test_lib.FlowProgressOverride(
        file.CollectSingleFile,
        rdf_file_finder.CollectSingleFileProgress(
            status=rdf_file_finder.CollectSingleFileProgress.Status.NOT_FOUND)):
      self.Open(f"/v2/clients/{self.client_id}")
      self.WaitUntil(
          self.IsElementPresent,
          "css=collect-single-file-details .error:contains('Not found')")
Example #13
0
    def testDisplaysMultipleResultsForSingleBrowser(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.token.username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id,
            [_GenResults(webhistory.Browser.CHROME, i) for i in range(200)],
            tag="CHROME")

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=200,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            # Expand the browser.
            self.Click("css=div.title:contains('Chrome')")
            # Check that only first 100 results are visible. First row is the table
            # header, so we start with 1.
            self.WaitUntil(self.IsElementPresent, "css=.results tr:nth(1)")
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=.results tr:nth(101):contains('/home/foo/chrome-100')")

            # Check that clicking Load More loads the rest.
            self.Click("css=button:contains('Load More')")
            self.WaitUntil(
                self.IsElementPresent,
                "css=.results tr:nth(200):contains('/home/foo/chrome-199')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.results tr:nth(201)")

            # Check that the "load more" button disappears when everything is loaded.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=button:contains('Load more')")
Example #14
0
    def testCorrectlyDisplaysError(self):
        flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
        flow_id = flow_test_lib.StartFlow(file.CollectSingleFile,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)
        flow_test_lib.MarkFlowAsFailed(self.client_id, flow_id)

        with flow_test_lib.FlowProgressOverride(
                file.CollectSingleFile,
                rdf_file_finder.CollectSingleFileProgress(
                    status=rdf_file_finder.CollectSingleFileProgress.Status.
                    FAILED,
                    error_description="Something went wrong")):
            self.Open(f"/v2/clients/{self.client_id}")
            self.WaitUntil(
                self.IsElementPresent,
                "css=flow-details :contains('Something went wrong')")
Example #15
0
    def testAllowsCopyingResultPathToClipboard(self):
        # TODO: remove the skip instruction as soon as latest Chrome
        # and WebDriver versions are used in the CI infrastructure.
        self.skipTest("Temporarily disabling: running this test requires "
                      "having latest Chrome/WebDriver versions in the CI "
                      "setup.")

        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id, [_GenResults(webhistory.Browser.CHROME, 0)],
            tag="CHROME")

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=1,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            # Expand the browser.
            self.Click("css=div.title:contains('Chrome')")
            # Hover and click on the copy button.
            self.MoveMouseTo(
                "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path"
            )
            # Click on the now visible button.
            self.Click(
                "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path "
                "button.copy-button")

            clip_value = self.GetClipboard()
            self.assertEqual(clip_value, "/home/foo/chrome-0")
Example #16
0
    def testCorrectlyDisplaysInProgressStatus(self):
        flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
        flow_test_lib.StartFlow(file.CollectSingleFile,
                                creator=self.test_username,
                                client_id=self.client_id,
                                flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                file.CollectSingleFile,
                rdf_file_finder.CollectSingleFileProgress(
                    status=rdf_file_finder.CollectSingleFileProgress.Status.
                    IN_PROGRESS)):
            self.Open(f"/v2/clients/{self.client_id}")
            self.WaitUntil(self.IsElementPresent,
                           "css=.flow-title:contains('File content')")
            self.WaitUntil(
                self.IsElementPresent,
                "css=collect-single-file-details .requested-path:contains('/etc/hosts')"
            )
            self.WaitUntilNot(
                self.IsElementPresent,
                "css=collect-single-file-details .collected-result")
Example #17
0
    def testCorrectlyDisplaysInProgressStateForMultipleBrowsers(self):
        # Start the flow with 2 browsers scheduled for collection.
        flow_args = webhistory.CollectBrowserHistoryArgs(browsers=[
            webhistory.CollectBrowserHistoryArgs.Browser.CHROME,
            webhistory.CollectBrowserHistoryArgs.Browser.OPERA,
        ])
        flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                creator=self.token.username,
                                client_id=self.client_id,
                                flow_args=flow_args)

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=0,
                    ),
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.OPERA,
                        status=webhistory.BrowserProgress.Status.IN_PROGRESS,
                        num_collected_files=0,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            self.WaitUntil(self.IsElementPresent,
                           "css=.row:contains('Chrome') .in-progress")
            self.WaitUntil(self.IsElementPresent,
                           "css=.row:contains('Opera') .in-progress")
            # Check that other browsers are not shown.
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Safari')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Internet Explorer')")
            self.WaitUntilNot(self.IsElementPresent,
                              "css=.row:contains('Firefox')")
Example #18
0
    def testAllowsCopyingResultPathToClipboard(self):
        flow_args = webhistory.CollectBrowserHistoryArgs(
            browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME])
        flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory,
                                          creator=self.token.username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        flow_test_lib.AddResultsToFlow(
            self.client_id,
            flow_id, [_GenResults(webhistory.Browser.CHROME, 0)],
            tag="CHROME")

        with flow_test_lib.FlowProgressOverride(
                webhistory.CollectBrowserHistory,
                webhistory.CollectBrowserHistoryProgress(browsers=[
                    webhistory.BrowserProgress(
                        browser=webhistory.Browser.CHROME,
                        status=webhistory.BrowserProgress.Status.SUCCESS,
                        num_collected_files=1,
                    ),
                ])):
            self.Open(f"/v2/clients/{self.client_id}")
            # Expand the flow.
            self.Click("css=.flow-title:contains('Browser History')")
            # Expand the browser.
            self.Click("css=div.title:contains('Chrome')")
            # Hover and click on the copy button.
            self.MoveMouseTo(
                "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path"
            )
            # Click on the now visible button.
            self.Click(
                "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path "
                "button.copy-button")

            clip_value = self.GetClipboard()
            self.assertEqual(clip_value, "/home/foo/chrome-0")
Example #19
0
  def testCorrectlyDisplaysNonStandardPathTypeNote(self):
    flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
    flow_test_lib.StartFlow(
        file.CollectSingleFile,
        creator=self.token.username,
        client_id=self.client_id,
        flow_args=flow_args)

    with flow_test_lib.FlowProgressOverride(
        file.CollectSingleFile,
        rdf_file_finder.CollectSingleFileProgress(
            status=rdf_file_finder.CollectSingleFileProgress.Status.COLLECTED,
            result=self._GenSampleResult(use_ntfs=True))):

      self.Open(f"/v2/clients/{self.client_id}")
      self.WaitUntil(
          self.IsElementPresent,
          "css=collect-single-file-details .collected-result:contains('/etc/hosts')"
      )
      self.WaitUntil(
          self.IsElementPresent,
          "css=collect-single-file-details .path-type-note:contains("
          "'File was fetched by parsing the raw disk image with libfsntfs')")
Example #20
0
    def testCorrectlyDisplaysDownloadButtonOnSuccess(self):
        flow_args = rdf_file_finder.CollectSingleFileArgs(path="/etc/hosts")
        flow_id = flow_test_lib.StartFlow(file.CollectSingleFile,
                                          creator=self.test_username,
                                          client_id=self.client_id,
                                          flow_args=flow_args)

        self.Open(f"/v2/clients/{self.client_id}")
        self.WaitUntil(
            self.IsElementPresent,
            "css=collect-single-file-details .requested-path:contains('/etc/hosts')"
        )
        self.WaitUntilNot(self.IsElementPresent,
                          "css=a[mat-stroked-button]:contains('Download')")

        flow_test_lib.MarkFlowAsFinished(self.client_id, flow_id)

        with flow_test_lib.FlowProgressOverride(
                file.CollectSingleFile,
                rdf_file_finder.CollectSingleFileProgress(
                    status=rdf_file_finder.CollectSingleFileProgress.Status.
                    COLLECTED,
                    result=self._GenSampleResult())):
            with flow_test_lib.FlowResultMetadataOverride(
                    file.CollectSingleFile,
                    rdf_flow_objects.FlowResultMetadata(
                        is_metadata_set=True,
                        num_results_per_type_tag=[
                            rdf_flow_objects.FlowResultCount(
                                type=rdf_file_finder.CollectSingleFileResult.
                                __name__,
                                count=1)
                        ])):
                self.WaitUntil(
                    self.IsElementPresent,
                    "css=a[mat-stroked-button]:contains('Download')")