示例#1
0
文件: hunt_test.py 项目: x35029/grr
    def testPausingAndRestartingDoesNotStartHuntTwiceOnTheSameClient(self):
        hunt_id, client_ids = self._CreateAndRunHunt(
            num_clients=10,
            client_rule_set=foreman_rules.ForemanClientRuleSet(),
            client_rate=0,
            args=self.GetFileHuntArgs())

        for client_id in client_ids:
            flows = data_store.REL_DB.ReadAllFlowObjects(
                client_id=client_id.Basename())
            self.assertLen(flows, 1)

        hunt.PauseHunt(hunt_id)
        hunt.StartHunt(hunt_id)

        self._RunHunt(client_ids)

        for client_id in client_ids:
            flows = data_store.REL_DB.ReadAllFlowObjects(
                client_id=client_id.Basename())
            self.assertLen(flows, 1)
示例#2
0
  def testHuntOverviewShowsStartAndExpirationTime(self):
    duration = rdfvalue.Duration.From(3, rdfvalue.DAYS)
    init_start_time = rdfvalue.RDFDatetime.FromHumanReadable("1973-01-01 08:34")
    last_start_time = rdfvalue.RDFDatetime.FromHumanReadable("1981-03-04 12:52")
    expiration_time = init_start_time + duration

    hunt_id = self.CreateHunt(duration=duration)

    # Navigate to the hunt view.
    self.Open("/")
    self.WaitUntil(self.IsElementPresent, "client_query")
    self.Click("css=a[grrtarget=hunts]")
    self.WaitUntil(self.IsTextPresent, hunt_id)

    # Select the hunt.
    self.Click("css=td:contains('{}')".format(hunt_id))

    self.RequestAndGrantHuntApproval(hunt_id)

    self.assertFalse(self.IsTextPresent(str(init_start_time)))
    self.assertFalse(self.IsTextPresent(str(expiration_time)))
    self.assertFalse(self.IsTextPresent(str(last_start_time)))

    with test_lib.FakeTime(init_start_time):
      hunt.StartHunt(hunt_id)

    self.Refresh()
    self.WaitUntil(self.IsTextPresent, str(init_start_time))
    self.WaitUntil(self.IsTextPresent, str(expiration_time))
    self.assertFalse(self.IsTextPresent(str(last_start_time)))

    with test_lib.FakeTime(last_start_time):
      hunt.PauseHunt(hunt_id)
      hunt.StartHunt(hunt_id)

    self.Refresh()
    self.WaitUntil(self.IsTextPresent, str(init_start_time))
    self.WaitUntil(self.IsTextPresent, str(expiration_time))
    self.WaitUntil(self.IsTextPresent, str(last_start_time))