def testGetOsqueryResultsChecksClientAccessIfNotPartOfHunt(self): client_id = self.SetupClient(0) flow_id = flow_test_lib.StartFlow(osquery.OsqueryFlow, client_id=client_id) args = api_osquery.ApiGetOsqueryResultsArgs( client_id=client_id, flow_id=flow_id) self.CheckMethodIsAccessChecked( self.router.GetOsqueryResults, "CheckClientAccess", args=args)
def testGetOsqueryResultsRefusesAccessIfWrongFlow(self): client_id = self.SetupClient(0) flow_id = flow_test_lib.StartFlow(flow_test_lib.DummyFlow, client_id=client_id) args = api_osquery.ApiGetOsqueryResultsArgs(client_id=client_id, flow_id=flow_id) with self.assertRaises(ValueError): self.router.GetOsqueryResults(args=args, context=self.context)
def testGetOsqueryResultsGrantsAccessIfPartOfHunt(self): client_id = self.SetupClient(0) hunt_id = self.CreateHunt() flow_id = flow_test_lib.StartFlow(osquery.OsqueryFlow, client_id=client_id, parent_hunt_id=hunt_id) args = api_osquery.ApiGetOsqueryResultsArgs(client_id=client_id, flow_id=flow_id) self.CheckMethodIsNotAccessChecked(self.router.GetOsqueryResults, args=args)
def testGetOsqueryResultsRefusesAccessIfPartOfHuntButWrongFlow(self): client_id = self.SetupClient(0) hunt_id = self.CreateHunt() flow_id = flow_test_lib.StartFlow( flow_test_lib.DummyFlow, client_id=client_id, parent=flow.FlowParent.FromHuntID(hunt_id)) args = api_osquery.ApiGetOsqueryResultsArgs( client_id=client_id, flow_id=flow_id) with self.assertRaises(ValueError): self.router.GetOsqueryResults(args=args, context=self.context)
def testGetOsqueryResultsRaisesIfFlowIsNotFound(self): args = api_osquery.ApiGetOsqueryResultsArgs(client_id=self.client_id, flow_id="12345678") with self.assertRaises(api_call_handler_base.ResourceNotFoundError): self.router.GetOsqueryResults(args, context=self.context)