Ejemplo n.º 1
0
  def testWhitelist_GlobalRule(self):
    change = test_utils.CreateRuleChangeSet(
        self.binary.key,
        rule_keys=[self.global_rule.key],
        change_type=constants.RULE_POLICY.WHITELIST)
    self.PatchApiRequests(api.Computer(id=5678))

    change_set._CommitBlockableChangeSet(self.binary.key)

    self.mock_ctx.ExecuteRequest.assert_has_calls([
        mock.call(
            'POST', api_route='fileRule',
            data={'fileCatalogId': 1234, 'fileState': 2}, query_args=None)])

    self.assertTrue(self.global_rule.key.get().is_committed)
    self.assertIsNone(change.key.get())
Ejemplo n.º 2
0
  def testWhitelist_LocalRule_NotFulfilled(self):
    change = test_utils.CreateRuleChangeSet(
        self.binary.key,
        rule_keys=[self.local_rule.key],
        change_type=constants.RULE_POLICY.WHITELIST)
    computer = api.Computer(id=5678, sync_percent=100)
    computer.last_poll_date = datetime.datetime.utcnow()
    self.PatchApiRequests([], computer)

    change_set._CommitBlockableChangeSet(self.binary.key)

    self.mock_ctx.ExecuteRequest.assert_has_calls([
        mock.call(
            'GET', api_route='fileInstance',
            query_args=[r'q=computerId:5678', 'q=fileCatalogId:1234'])])

    self.assertIsNotNone(self.local_rule.key.get().is_fulfilled)
    self.assertFalse(self.local_rule.key.get().is_fulfilled)
    self.assertTrue(self.local_rule.key.get().is_committed)
    self.assertIsNone(change.key.get())