def testDoesNothingIfArgsHaveNoChanges(self): before = hunt_plugin.ApiHunt().InitFromAff4Object( aff4.FACTORY.Open(self.hunt.urn, token=self.token)) self.handler.Handle(self.args, token=self.token) after = hunt_plugin.ApiHunt().InitFromAff4Object( aff4.FACTORY.Open(self.hunt.urn, token=self.token)) self.assertEqual(before, after)
def testDoesNotModifyHuntIfStateChangeFails(self): with self.assertRaises(hunt_plugin.InvalidHuntStateError): self.args.client_limit = 42 self.args.state = "COMPLETED" self.handler.Handle(self.args, token=self.token) after = hunt_plugin.ApiHunt().InitFromAff4Object( aff4.FACTORY.Open(self.hunt.urn, token=self.token)) self.assertNotEqual(after.client_limit, 42)
def testModifiesHuntCorrectly(self): self.args.client_rate = 100 self.args.client_limit = 42 self.args.expires = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(42) self.handler.Handle(self.args, token=self.token) after = hunt_plugin.ApiHunt().InitFromAff4Object( aff4.FACTORY.Open(self.hunt.urn, token=self.token)) self.assertEqual(after.client_rate, 100) self.assertEqual(after.client_limit, 42) self.assertEqual(after.expires, rdfvalue.RDFDatetime.FromSecondsSinceEpoch(42))